Skip to content
Snippets Groups Projects
Commit 68b8cec0 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

WIP ENH: set_datatype for Property.m, null output for logging.

parent 9f590cc7
No related branches found
No related tags found
1 merge request!3Full functionality of libcaosdb
Pipeline #12743 failed
...@@ -109,7 +109,7 @@ classdef Caosdb < handle ...@@ -109,7 +109,7 @@ classdef Caosdb < handle
try try
% collection = maox_retrieve(obj.connection, ids); % collection = maox_retrieve(obj.connection, ids);
disp("start transaction for ID retrieval"); % disp("start transaction for ID retrieval");
[entities, count_results] = maox_run_transaction(obj.connection, ids); [entities, count_results] = maox_run_transaction(obj.connection, ids);
catch catch
rethrow(lasterror()); rethrow(lasterror());
......
...@@ -29,9 +29,9 @@ classdef Entity < handle ...@@ -29,9 +29,9 @@ classdef Entity < handle
end end
properties (Access = private) properties (Access = private)
datatype_ % 1x1 struct with the following fields: datatype_ % 1x1 struct with the following fields:
% - is_list logical % - isList logical
% - is_reference logical % - isReference logical
% - dtype_name string. Either the atomic datatype or the reference name. % - dtypeName string. Either the atomic datatype or the reference name.
parents_ % Cell array of Parent objects. Struct array with the following fields: parents_ % Cell array of Parent objects. Struct array with the following fields:
% - id % - id
% - name % - name
......
...@@ -23,10 +23,15 @@ classdef Property < handle ...@@ -23,10 +23,15 @@ classdef Property < handle
name name
description description
importance importance
datatype
unit unit
value value
end end
properties (Access = private)
datatype_ % 1x1 struct with the following fields:
% - isList logical
% - isReference logical
% - dtypeName string. Either the atomic datatype or the reference name.
end
methods methods
...@@ -39,7 +44,7 @@ classdef Property < handle ...@@ -39,7 +44,7 @@ classdef Property < handle
obj.name = data.name; obj.name = data.name;
obj.description = data.description; obj.description = data.description;
obj.importance = data.importance; obj.importance = data.importance;
obj.datatype = data.datatype; obj.datatype_ = data.datatype;
obj.unit = data.unit; obj.unit = data.unit;
obj.value = data.value; obj.value = data.value;
end end
...@@ -61,5 +66,27 @@ classdef Property < handle ...@@ -61,5 +66,27 @@ classdef Property < handle
struct_array = res; struct_array = res;
end end
% Setters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function set_datatype(obj, dtype_name, is_reference, is_list)
if nargin < 4
is_list = false;
end
if nargin < 3
is_reference = false;
end
assert(nargin >= 2, "maox:InvalidArgument", "Need at least an atomic datatype.");
dtype.isList = is_list;
dtype.isReference = is_reference;
if ~is_reference
assert(any(strcmp({ "UNSPECIFIED", "TEXT", "DOUBLE", "DATETIME", "INTEGER", "BOOLEAN"}, ...
dtype_name)), ...
"maox:InvalidArgument", ["Unrecognized atomic datatype: " dtype_name]);
end
dtype.dtypeName = dtype_name;
obj.datatype_ = dtype;
end
end end
end end
...@@ -43,8 +43,18 @@ namespace ce = caosdb::entity; ...@@ -43,8 +43,18 @@ namespace ce = caosdb::entity;
namespace cu = caosdb::utility; namespace cu = caosdb::utility;
// Workaround for issue caosdb-cpplib#17 // Workaround for issue caosdb-cpplib#17
#define CAOSDB_LOG_TRACE(name) std::clog << std::endl << "[" << name << "] " #undef CAOSDB_LOG_TRACE
#define CAOSDB_LOG_DEBUG(name) std::clog << std::endl << "[" << name << "] " #undef CAOSDB_LOG_DEBUG
#undef CAOSDB_LOG_INFO
// #define CAOSDB_LOG_TRACE(name) std::clog << std::endl << "[" << name << "] "
// #define CAOSDB_LOG_DEBUG(name) std::clog << std::endl << "[" << name << "] "
// #define CAOSDB_LOG_INFO(name) std::clog << std::endl << "[" << name << "] "
std::ostream nullout(nullptr);
#define CAOSDB_LOG_TRACE(name) nullout
#define CAOSDB_LOG_DEBUG(name) nullout
#define CAOSDB_LOG_INFO(name) nullout
auto logger_name = string("maoxdb"); auto logger_name = string("maoxdb");
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "caosdb/utility.h" #include "caosdb/utility.h"
#include "mex.h" #include "mex.h"
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/iostreams/stream.hpp>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
......
...@@ -36,8 +36,18 @@ using caosdb::entity::Entity; ...@@ -36,8 +36,18 @@ using caosdb::entity::Entity;
using std::string; using std::string;
// Workaround for issue caosdb-cpplib#17 // Workaround for issue caosdb-cpplib#17
#define CAOSDB_LOG_TRACE(name) std::clog << std::endl << "[" << name << "] " #undef CAOSDB_LOG_TRACE
#undef CAOSDB_LOG_DEBUG
#undef CAOSDB_LOG_INFO
// #define CAOSDB_LOG_TRACE(name) std::clog << std::endl << "[" << name << "] "
#define CAOSDB_LOG_DEBUG(name) std::clog << std::endl << "[" << name << "] " #define CAOSDB_LOG_DEBUG(name) std::clog << std::endl << "[" << name << "] "
#define CAOSDB_LOG_INFO(name) std::clog << std::endl << "[" << name << "] "
std::ostream nullout(nullptr);
#define CAOSDB_LOG_TRACE(name) nullout
// #define CAOSDB_LOG_DEBUG(name) nullout
// #define CAOSDB_LOG_INFO(name) nullout
auto logger_name = "maox_transaction"; auto logger_name = "maox_transaction";
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment