MADARA  3.4.1
BaseContainer.cpp
Go to the documentation of this file.
1 #include "BaseContainer.h"
3 
4 namespace logger = madara::logger;
5 
7  const std::string& name, const KnowledgeUpdateSettings& settings)
8  : name_(name), settings_(settings)
9 {
10 }
11 
13  const BaseContainer& rhs)
14  : name_(rhs.name_), settings_(rhs.settings_)
15 {
16 }
17 
19 
21  const KnowledgeUpdateSettings& settings)
22 {
23  MADARA_GUARD_TYPE guard(mutex_);
24 
25  settings_ = settings;
26 }
27 
30 {
31  MADARA_GUARD_TYPE guard(mutex_);
32 
33  return settings_;
34 }
35 
37  BaseContainer& conditional)
38 {
39  bool result(false);
40 
42  "BaseContainer::is_true: calling condition.is_true()\n");
43 
44  if (conditional.is_true_())
45  {
47  "BaseContainer::is_true: condition.is_true() returned true\n");
48 
49  this->modify_();
50  result = true;
51  }
52 
53  return result;
54 }
55 
57  BaseContainer& conditional)
58 {
59  bool result(false);
60 
62  "BaseContainer::is_false: calling !condition.is_true()\n");
63 
64  if (!conditional.is_true_())
65  {
67  "BaseContainer::is_false: !condition.is_true() returned true\n");
68  this->modify_();
69  result = true;
70  }
71 
72  return result;
73 }
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
Definition: Logger.h:41
Settings for applying knowledge updates.
This class is an abstract base class for all containers.
Definition: BaseContainer.h:34
BaseContainer(const std::string &name="", const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Constructor.
virtual bool modify_if_false(BaseContainer &conditional)
Modifies the container if the argument is false.
virtual bool modify_if_true(BaseContainer &conditional)
Modifies the container if the argument is true.
KnowledgeUpdateSettings get_settings(void)
Gets the update settings for the container.
virtual bool is_true_(void) const =0
Polymorphic is true method which can be used to determine if all values in a container are true.
void set_settings(const KnowledgeUpdateSettings &settings)
Sets the update settings for the container.
constexpr string_t string
T get(const KnowledgeRecord &kr)
Get the value of a KnowlegeRecord.
Definition: GetRecord.h:121
Provides knowledge logging services to files and terminals.
Definition: GlobalLogger.h:12
MADARA_EXPORT utility::Refcounter< logger::Logger > global_logger