15 template <
template <
class>
class t_Pointer,
class t_Base,
class t_Instantiator>
18 #define ARILES_SECTION_ID "Any" 19 #include ARILES_INITIALIZE 24 if ((
"" != id_) && (NULL != value_.get()))
29 if ((
"" == id_) && (NULL == value_.get()))
50 Any(
const std::string &
id)
56 void build(
const std::string &
id)
59 value_ = t_Instantiator::instantiate(id_);
60 ARILES_ASSERT(NULL != value_.get(),
"Could not instantiate class.");
66 return (
"" != id_ && NULL != value_.get());
76 template <
class t_Derived>
79 return (dynamic_cast<t_Derived *>(value_.get()));
83 template <
class t_Derived>
84 const t_Derived *
cast()
const 86 return (dynamic_cast<const t_Derived *>(value_.get()));
96 template <
class t_Derived>
97 t_Derived *
cast(
const std::string &config_section_id)
99 if (
true == isInitialized())
101 if (config_section_id == value_->getConfigSectionID())
103 return (dynamic_cast<t_Derived *>(value_.get()));
110 template <
class t_Derived>
111 const t_Derived *
cast(
const std::string &config_section_id)
const 113 if (
true == isInitialized())
115 if (config_section_id == value_->getConfigSectionID())
117 return (dynamic_cast<t_Derived *>(value_.get()));
127 ARILES_ASSERT(
true == isInitialized(),
"Not initialized");
128 return (value_.get());
134 ARILES_ASSERT(
true == isInitialized(),
"Not initialized");
135 return (value_.get());
141 ARILES_ASSERT(
true == isInitialized(),
"Not initialized");
148 ARILES_ASSERT(
true == isInitialized(),
"Not initialized");
158 true == isConsitent(),
159 "Could not write config: entry is in an inconsistent (partially initialized) state.");
162 if (
true == isInitialized())
171 if (
true == reader(id_,
"id", parameters))
176 reader(*value_,
"value", parameters);
183 if (
true == isInitialized())
202 template <
class t_Other>
208 if (getNumberOfEntries() != other.getNumberOfEntries())
214 if (this->id_ != other.id_)
219 if (NULL != value_.get() && NULL != other.value_.get())
222 return (visitor.
compare(*value_, *(other.value_), param));
235 template <
class t_Po
inter>
238 #define ARILES_SECTION_ID "NonNullPointer" 239 #include ARILES_INITIALIZE 276 Handler::allocate(value_);
288 ARILES_ASSERT(
false == isNull(),
"Not initialized");
289 return (value_.get());
293 typename Handler::Value &operator*()
const 295 ARILES_ASSERT(
false == isNull(),
"Not initialized");
302 ARILES_ASSERT(
false == isNull(),
"Could not write config: entry is not initialized");
303 value_->writeConfigEntries(writer, parameters);
309 Handler::allocate(value_);
310 value_->readConfigEntries(reader, parameters);
316 ARILES_ASSERT(
false == isNull(),
"Not initialized");
322 Handler::allocate(value_);
323 value_->setDefaults();
329 ARILES_ASSERT(
false == isNull(),
"Not initialized");
330 return (value_->getNumberOfEntries());
336 return (Handler::isNull(value_));
340 template <
class t_Other>
344 return (value_->arilesCompare(*other.value_, param));
#define ARILES_TRACE_FUNCTION
t_Pointer< t_Base > value_
bool isInitialized() const
bool arilesCompare(const t_Other &other, const ariles::ComparisonParameters ¶m) const
bool compare(const t_Left &left, const t_Right &right, const Parameters ¶m)
bool compare_number_of_entries_
NonNullPointer(const typename Handler::Value &value)
t_Derived * cast(const std::string &config_section_id)
These casts succeed if the Ariles config section id matches the given string.
void writeConfigEntries(ariles::WriterBase &writer, const ariles::ConfigurableFlags ¶m) const
Handler::Value * operator->() const
void writeConfigEntries(ariles::WriterBase &writer, const ariles::ConfigurableFlags ¶meters) const
const t_Derived * cast() const
std::size_t getNumberOfEntries() const
Get number of entries in the corresponding configuration node.
void readConfigEntries(ariles::ReaderBase &reader, const ariles::ConfigurableFlags ¶meters)
std::size_t getNumberOfEntries() const
Get number of entries in the corresponding configuration node.
NonNullPointer(const t_Pointer &value)
t_Derived * cast()
Cast methods are potentially dangerous, no id checks are performed. If value is not initialized the r...
void readConfigEntries(ariles::ReaderBase &reader, const ariles::ConfigurableFlags ¶meters)
const t_Derived * cast(const std::string &config_section_id) const
#define ARILES_WRITE_NAMED_ENTRY(entry, name)
bool arilesCompare(const t_Other &other, const ariles::ComparisonParameters ¶m) const
virtual ~NonNullPointer()
Default configurable base.
#define ARILES_WRITE_ENTRY_(entry)
#define ARILES_VISIBILITY_ATTRIBUTE
PointerHandler< t_Pointer > Handler
const t_Base * operator->() const
Any(const std::string &id)
void build(const std::string &id)