diff --git a/.miss_hit b/.miss_hit index 1ec1ed2e3f9ad6a09619d69746c5b79685c6d89f..025b96a2a7564bc4ee528971fd7c4ad201a2e3d1 100644 --- a/.miss_hit +++ b/.miss_hit @@ -2,6 +2,6 @@ # See https://florianschanda.github.io/miss_hit/style_checker.html line_length: 100 -regex_function_name: "[_a-z]+(_[a-z]+)*" +# regex_function_name: "[a-z]+(_[a-z]+)*" suppress_rule: "whitespace_comments" tab_width: 2 diff --git a/src/Caosdb.m b/src/Caosdb.m index 7345ca240266d0d738377d564a35dda6c4ce6434..484759be541f0e8f37e88628e42927fb3f89f782 100644 --- a/src/Caosdb.m +++ b/src/Caosdb.m @@ -1,8 +1,8 @@ -% (C) Copyright 2021 IndiScale GmbH <info@indiscale.com> -% (C) Copyright 2021 Timm FItschen <t.fitschen@indiscale.com> -% % This file is a part of the CaosDB Project. % +% Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> +% Copyright (C) 2021 Daniel Hornung <d.hornung@indiscale.com> +% % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU Affero General Public License as % published by the Free Software Foundation, either version 3 of the @@ -17,8 +17,8 @@ % along with this program. If not, see <https://www.gnu.org/licenses/>. % -*- texinfo -*- -% @deftypefn {Loadable Function} {} caosdb ([@var{OPTIONS}]) -% This is the main function of the CaosDB client for Octave. +% @deftypefn {Class} {} Caosdb () +% This is the main class of the CaosDB client for Octave. % % Print usage help and return: % @example @@ -40,3 +40,34 @@ %!demo %! ## Print Help: %! caosdb --help; +classdef Caosdb < handle + properties + connection = "" % Will use the default connection + end + + methods + + function obj = Caosdb(connection) + if nargin == 0 + connection = ""; + end + obj.connection = connection; + end + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % info % + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + function res = info(obj) + disp(["connection: >", obj.connection, "<"]); + try + info_result = maox_info(obj.connection); + res = info_result; + catch + disp("some error!"); + disp(lasterror()); + res = NA; + end + end + + end +end diff --git a/src/caosdbClass.m b/src/caosdbClass.m deleted file mode 100644 index 869845eac8b3321117f61525d5e714431bec2697..0000000000000000000000000000000000000000 --- a/src/caosdbClass.m +++ /dev/null @@ -1,29 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Hello % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -classdef caosdbClass < handle - properties - connection; % Will use the default connection - endproperties - - methods - function obj = caosdbClass(connection="") - obj.connection = connection; - endfunction - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% info % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - function res = info(obj) - disp(["connection: >", obj.connection, "<"]); - try - info_result = maox_info(obj.connection); - res = info_result; - catch - disp("some error!") - disp(lasterror()) - res = NA; - end_try_catch - endfunction - endmethods -endclassdef diff --git a/src/lib/maoxdb.cpp b/src/lib/maoxdb.cpp index edb040d636d173eef5df4714390107720a9cee50..0e6dfa155df02fec9ffe5321e22e4061d5611439 100644 --- a/src/lib/maoxdb.cpp +++ b/src/lib/maoxdb.cpp @@ -34,10 +34,12 @@ using std::string; /** * Extract useful strings from an Exception: ID and description. */ -std::pair<string, string> exceptionToMessage(const caosdb::exceptions::Exception &exc) { +std::pair<string, string> +exceptionToMessage(const caosdb::exceptions::Exception &exc) { string id = std::to_string(exc.GetCode()); - string text = caosdb::get_status_description(exc.GetCode()) + "\n" + exc.what(); + string text = + caosdb::get_status_description(exc.GetCode()) + "\n" + exc.what(); return std::pair<string, string>(id, text); } @@ -50,4 +52,4 @@ void throwOctException(const caosdb::exceptions::Exception &exc) { mexErrMsgIdAndTxt(excContent.first.c_str(), excContent.second.c_str()); } -} +} // namespace maoxdb diff --git a/src/lib/maoxdb.hpp b/src/lib/maoxdb.hpp index b3d98be8d3c73595f59cb7ea51a72a23385d0aac..46ff817090dcd6353d2ecdf93bc09a7948e8af21 100644 --- a/src/lib/maoxdb.hpp +++ b/src/lib/maoxdb.hpp @@ -42,24 +42,27 @@ void test(); /** * @brief Handle a CaosDB Exception and transform into error code and message. * - * @details This function does all the processing to transform the information in an Exception - * object into a form that can conveniently be handled by Octave via the mexErrMsgIdAndTxt function. + * @details This function does all the processing to transform the information + * in an Exception object into a form that can conveniently be handled by Octave + * via the mexErrMsgIdAndTxt function. * * @param exc The Exception object. * - * @return pair<string msgId, string msgText> The message ID and message text which can be passed to - * Octave. + * @return pair<string msgId, string msgText> The message ID and message text + * which can be passed to Octave. * - * @note Additional utility functions should be easy to implement when the libcaosdb error handling - * changes. + * @note Additional utility functions should be easy to implement when the + * libcaosdb error handling changes. */ -std::pair<string, string> exceptionToMessage(const caosdb::exceptions::Exception &exc); +std::pair<string, string> +exceptionToMessage(const caosdb::exceptions::Exception &exc); /** * @brief Throw a CaosDB Exception inside Octave. * - * @details This function does all the processing to transform the information in an Exception - * object into a form that is accepted by Octave's error handling.d + * @details This function does all the processing to transform the information + * in an Exception object into a form that is accepted by Octave's error + * handling.d * * Internally, this function uses the exceptionToMessage function. * @@ -67,6 +70,6 @@ std::pair<string, string> exceptionToMessage(const caosdb::exceptions::Exception */ void throwOctException(const caosdb::exceptions::Exception &exc); -} // maoxdb +} // namespace maoxdb #endif /* MAOXDB_H */ diff --git a/src/lib/test.cpp b/src/lib/test.cpp index 41d1bb70d8ea96ec861e2807fab80487f7b604f5..6b871fff6774428aa9d8fbf2eb2418878093b334 100644 --- a/src/lib/test.cpp +++ b/src/lib/test.cpp @@ -9,4 +9,4 @@ void test() { auto *mx_str = mxCreateString("Hello World!"); } -} // maoxdb +} // namespace maoxdb diff --git a/src/private/maox_info.cpp b/src/private/maox_info.cpp index de36999e5f83caac106fe218ea73cce3c2956dd9..9009e3d194c7ef6d52b0003c552e5a49b8d0589c 100644 --- a/src/private/maox_info.cpp +++ b/src/private/maox_info.cpp @@ -7,7 +7,7 @@ #include <cstring> // for strcmp #include <memory> // for unique_ptr, __shared_ptr_access, shar... #include <string> // for allocator, char_traits, operator+ -#include "maoxdb.hpp" // caosDB utils for mex files +#include "maoxdb.hpp" // caosDB utils for mex files using caosdb::connection::Connection; using caosdb::connection::ConnectionManager;