Skip to content
Snippets Groups Projects
Commit 0ea49404 authored by florian's avatar florian
Browse files

Merge branch 'dev' into f-extended-c

parents 7f07dded 0f96286c
No related branches found
No related tags found
3 merge requests!12F consolidation,!9Draft: API: remove UniqueResult, lower-case at, size for ResultSet,!8ENH: Add retrieval and queries to Extern C interface
Pipeline #11826 passed
Pipeline: caosdb-cppinttest

#11827

    This commit is part of merge request !8. Comments created here will be created in the context of that merge request.
    ......@@ -107,6 +107,7 @@ trigger_inttest:
    # ... or use main if possible...
    - if [[ "$CI_COMMIT_REF_NAME" == "main" ]] ; then
    CPPINT_REF=main ;
    F_BRANCH=main ;
    fi
    - if echo "$CI_COMMIT_REF_NAME" | grep -c "^v" ; then
    CPPINT_REF=main ;
    ......
    ......@@ -113,6 +113,7 @@ public:
    friend class ConfigurationManager;
    private:
    auto ConvertLogLevel(const std::string &string_level) const -> int;
    auto CreateConsoleSinkConfiguration(const object &from,
    const std::string &name, int level) const
    -> std::shared_ptr<caosdb::logging::SinkConfiguration>;
    ......@@ -236,7 +237,9 @@ private:
    ConnectionConfigurationHelper connection_configuration_helper;
    LoggingConfigurationHelper logging_configuration_helper;
    inline ConfigurationManager() { InitializeDefaults(); };
    inline ConfigurationManager(){
    // InitializeDefaults();
    };
    /**
    * Initialize this ConfigurationManager with the defaults.
    ......
    ......@@ -283,8 +283,7 @@ private:
    */
    class Parent {
    public:
    explicit inline Parent(caosdb::entity::v1alpha1::Parent *wrapped)
    : wrapped(wrapped){};
    explicit inline Parent(ProtoParent *wrapped) : wrapped(wrapped){};
    Parent();
    /**
    ......@@ -369,7 +368,7 @@ private:
    /**
    * Message which serves as storage backend.
    */
    mutable caosdb::entity::v1alpha1::Parent *wrapped;
    mutable ProtoParent *wrapped;
    // Messages errors;
    // Messages warnings;
    // Messages infos;
    ......@@ -401,8 +400,7 @@ private:
    */
    class Property {
    public:
    explicit inline Property(caosdb::entity::v1alpha1::Property *wrapped)
    : wrapped(wrapped){};
    explicit inline Property(ProtoProperty *wrapped) : wrapped(wrapped){};
    Property();
    /**
    ......@@ -447,6 +445,10 @@ public:
    * Set the name of this property.
    */
    auto SetName(const std::string &name) -> void;
    /**
    * Set the description of this property.
    */
    auto SetDescription(const std::string &description) -> void;
    /**
    * Set the importance of this property.
    */
    ......@@ -485,7 +487,7 @@ public:
    private:
    static auto CreateProtoProperty() -> ProtoProperty *;
    mutable caosdb::entity::v1alpha1::Property *wrapped;
    mutable ProtoProperty *wrapped;
    };
    /**
    ......@@ -583,7 +585,11 @@ public:
    auto SetRole(const std::string &role) -> void;
    auto SetName(const std::string &name) -> void;
    /**
    * Set the description of this entity.
    */
    auto SetDescription(const std::string &description) -> void;
    auto SetValue(const std::string &value) -> void;
    auto SetUnit(const std::string &unit) -> void;
    // Currently no references or lists.
    ......
    ......@@ -38,10 +38,10 @@ namespace caosdb::logging {
    const std::string logger_name = "caosdb::logging";
    typedef boost::log::sources::severity_channel_logger<int, std::string>
    typedef boost::log::sources::severity_channel_logger_mt<int, std::string>
    boost_logger_class;
    BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(logger, boost_logger_class)
    BOOST_LOG_GLOBAL_LOGGER(logger, boost_logger_class)
    /**
    * This class stores the integer log level.
    ......
    ......@@ -302,8 +302,9 @@ auto LoggingConfigurationHelper::CreateSinkConfiguration(
    assert(from.contains("destination"));
    const auto &destination =
    std::string(from.at("destination").as_string().c_str());
    int level = from.contains("level")
    ? static_cast<int>(from.at("level").as_int64())
    ? ConvertLogLevel(from.at("level").as_string().c_str())
    : default_level;
    if (destination == "file") {
    ......@@ -317,38 +318,43 @@ auto LoggingConfigurationHelper::CreateSinkConfiguration(
    }
    }
    auto LoggingConfigurationHelper::CreateLoggingConfiguration(
    const object &from) const -> LoggingConfiguration {
    auto default_level_str = from.contains("level")
    ? std::string(from.at("level").as_string().c_str())
    : "";
    int default_level = 0;
    auto LoggingConfigurationHelper::ConvertLogLevel(
    const std::string &string_level) const -> int {
    static std::map<std::string, int> log_level_names = {
    {"", CAOSDB_DEFAULT_LOG_LEVEL}, {"off", CAOSDB_LOG_LEVEL_OFF},
    {"fatal", CAOSDB_LOG_LEVEL_FATAL}, {"error", CAOSDB_LOG_LEVEL_ERROR},
    {"warn", CAOSDB_LOG_LEVEL_WARN}, {"info", CAOSDB_LOG_LEVEL_INFO},
    {"debug", CAOSDB_LOG_LEVEL_DEBUG}, {"trace", CAOSDB_LOG_LEVEL_TRACE},
    {"all", CAOSDB_LOG_LEVEL_ALL}};
    try {
    default_level = CAOSDB_DEFAULT_LOG_LEVEL;
    return log_level_names.at(string_level);
    } catch (const std::out_of_range &exc) {
    throw ConfigurationError("Unknown log level: " + default_level_str);
    throw ConfigurationError("Unknown log level: " + string_level);
    }
    }
    auto LoggingConfigurationHelper::CreateLoggingConfiguration(
    const object &from) const -> LoggingConfiguration {
    auto default_level_str = from.contains("level")
    ? std::string(from.at("level").as_string().c_str())
    : "";
    int default_level = ConvertLogLevel(default_level_str);
    auto result = LoggingConfiguration(default_level);
    if (default_level == CAOSDB_LOG_LEVEL_OFF) {
    return result;
    }
    const auto &sinks = from.at("sinks").as_object();
    if (!sinks.empty()) {
    const auto *elem = sinks.begin();
    if (from.contains("sinks")) {
    const auto &sinks = from.at("sinks").as_object();
    if (!sinks.empty()) {
    const auto *elem = sinks.begin();
    while (elem != sinks.end()) {
    result.AddSink(CreateSinkConfiguration(
    elem->value().as_object(), elem->key().to_string(), default_level));
    elem = std::next(elem);
    while (elem != sinks.end()) {
    result.AddSink(CreateSinkConfiguration(
    elem->value().as_object(), elem->key().to_string(), default_level));
    elem = std::next(elem);
    }
    }
    }
    ......
    ......@@ -121,6 +121,10 @@ auto Property::SetName(const std::string &name) -> void {
    this->wrapped->set_name(name);
    }
    auto Property::SetDescription(const std::string &description) -> void {
    this->wrapped->set_description(description);
    }
    auto Property::SetImportance(const std::string &importance) -> void {
    this->wrapped->set_importance(importance);
    }
    ......
    ......@@ -44,6 +44,10 @@
    namespace caosdb::logging {
    BOOST_LOG_GLOBAL_LOGGER_INIT(logger, boost_logger_class) {
    boost_logger_class lg;
    return lg;
    }
    LoggingConfiguration::LoggingConfiguration(int level)
    : LevelConfiguration(level) {}
    ......@@ -156,6 +160,11 @@ auto initialize_logging_defaults() -> int {
    // Called if custom logging settings are specified.
    auto initialize_logging(const LoggingConfiguration &configuration) -> void {
    // first: turn everything off
    boost::log::settings off_settings;
    off_settings["Core.DisableLogging"] = true;
    boost::log::init_from_settings(off_settings);
    boost::log::settings new_settings;
    if (configuration.GetLevel() == CAOSDB_LOG_LEVEL_OFF) {
    ......
    ......@@ -37,6 +37,7 @@
    namespace caosdb::entity {
    using caosdb::entity::v1alpha1::IdResponse;
    using ProtoEntity = caosdb::entity::v1alpha1::Entity;
    using ProtoParent = caosdb::entity::v1alpha1::Parent;
    using caosdb::utility::get_arena;
    TEST(test_entity, test_parent_setters) {
    ......@@ -367,4 +368,25 @@ TEST(test_entity, test_property_iterator) {
    }
    EXPECT_EQ(counter, 5);
    }
    TEST(test_entity, test_description) {
    Entity entity;
    Property property;
    Parent parent;
    EXPECT_EQ(entity.GetDescription(), "");
    EXPECT_EQ(property.GetDescription(), "");
    EXPECT_EQ(parent.GetDescription(), "");
    entity.SetDescription("desc entity");
    property.SetDescription("desc property");
    // Parent has not setter
    ProtoParent protoParent;
    protoParent.set_description("desc parent");
    parent = Parent(&protoParent);
    EXPECT_EQ(entity.GetDescription(), "desc entity");
    EXPECT_EQ(property.GetDescription(), "desc property");
    EXPECT_EQ(parent.GetDescription(), "desc parent");
    }
    } // namespace caosdb::entity
    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