85 virtual size_t size()
const = 0;
180 template <
class KeyT,
class ValT>
222 size_t size()
const override {
return m_values.size();}
224 bool empty()
const override {
return m_values.empty();}
231 if (it!=m_values.end())
249 if (it!=m_values.end())
255 throw std::out_of_range(
"Key is not in dictionary");
279 for (
const_iterator it=m_values.begin(); it!=m_values.end(); ++it)
281 if (it->second.IsChanged())
295 for (
iterator it=m_values.begin(); it!=m_values.end(); ++it)
297 it->second.SetChanged(changed);
317 InsertHelper<ContainedType, ValueContainerType>::SetVal(val, container);
323 size_t count=m_values.erase(key);
349 val.Copy(it->second);
350 m_values.insert(std::make_pair(it->first, val));
372 (L
"DictionaryContainer::GetKey: Index outside range!",
__WFILE__, __LINE__);
374 return std::next(m_values.begin(),index)->second;
382 if (typeInfo ==
typeid(
KeyType) || std::is_enum_v<KeyType> )
386 auto result = m_values.insert(
value_type(*
static_cast<const KeyType*
>(key), container));
387 return result.first->second;
390 std::wostringstream os;
391 os << L
"DictionaryContainer::InsertNull: The supplied key has wrong type! "
392 << L
"Expected type: " <<
typeid(
KeyType).name() << L
", got type: "
393 << typeInfo.name() << std::endl;
403 (L
"DictionaryContainer::GetKeyAt: Index outside range!",
__WFILE__, __LINE__);
405 return &(std::next(m_values.begin(),index)->first);
419 if (fromContainerOB != NULL)
427 (L
"DictionaryContainer::Merge: Changed key not found in target!",
431 findIt->second.Copy(*fromContainerOB);
438 throw SoftwareViolationException
439 (L
"DictionaryContainer::Merge: Changed key not found in target!",
442 ObjectContainerBase* intoContainerOB =
dynamic_cast<ObjectContainerBase*
>(&findIt->second);
444 ObjectPtr into = intoContainerOB->GetObjectPointer();
453 if (it->second.IsChanged())
458 throw SoftwareViolationException
459 (L
"DictionaryContainer::Merge: Changed key not found in target!",
463 findIt->second.Copy(it->second);
469 std::map<KeyT, ValT> m_values;
471 template <
class V,
class C>
struct InsertHelper
473 static void SetVal(
const V& v, C& c) {c.SetVal(v);}
476 template <
class V,
class C>
struct InsertHelper< std::shared_ptr<V>, C >
478 static void SetVal(
const std::shared_ptr<V>& v, C& c) {c.SetPtr(v);}
486 throw SoftwareViolationException(L
"Invalid call to Copy or Merge, containers are not of same type",
#define __WFILE__
Definition Exceptions.h:31
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
This namespace contains all functionality of the DOB (Components DOSE and DOTS).
Definition Connection.h:38
This namespace contains the DOB Typesystem functionality and definitions.
Definition ArrayContainer.h:37
std::shared_ptr< const Object > ObjectConstPtr
A smart pointer to a const Object.
Definition Object.h:47
std::shared_ptr< Object > ObjectPtr
A smart pointer to an Object.
Definition Object.h:44
DOTS_CPP_API void MergeChanges(ObjectPtr into, const ObjectConstPtr &from)
Merge the changed members (recursively) from one object into another.
Base class for all Containers.
Definition ContainerBase.h:44
bool m_bIsChanged
The variable containing the change flag.
Definition ContainerBase.h:134
constexpr ContainerBase()
Default Constructor.
Definition ContainerBase.h:51
virtual bool IsChanged() const
Is the change flag set on the container?
Definition ContainerBase.h:92
Base class for all dictionary containers.
Definition DictionaryContainer.h:48
virtual bool empty() const =0
Check if dictionary is empty.
DictionaryContainerBase()
Default Constructor.
Definition DictionaryContainer.h:51
virtual size_t size() const =0
Get the size of the dictionary, i.e number of contained keys.
virtual ContainerBase & InsertNullInternal(const void *key, const std::type_info &typeInfo)=0
virtual ContainerBase & GetValueContainerAt(const size_t index)=0
Get the container of the value at a particular position in the dictionary.
ContainerBase & InsertNull(const KeyT &key)
Adds a new key to the dictionary and return the value container.
Definition DictionaryContainer.h:116
virtual const void * GetKeyAtInternal(const size_t index) const =0
bool IsChangedHere() const
Is the change flag in the container set?
Definition DictionaryContainer.h:63
void SetChangedHere(const bool changed)
Set the change flag in the container.
Definition DictionaryContainer.h:75
const KeyT & GetKeyAt(const size_t index) const
Get the key at a particular position in the dictionary.
Definition DictionaryContainer.h:138
virtual const ContainerBase & GetValueContainerAt(const size_t index) const =0
Const version of GetValueContainerAt()
Container class for dictionaries of key value pairs.
Definition DictionaryContainer.h:182
DictionaryContainer()
Default Constructor.
Definition DictionaryContainer.h:198
void Insert(const KeyType &key, const ContainedType &val)
Definition DictionaryContainer.h:313
ValueContainerType & at(const KeyType &key)
Like operator[], but throws std::out_of_range if key is not in dictionary.
Definition DictionaryContainer.h:246
std::map< KeyType, ValueContainerType > StorageType
Definition DictionaryContainer.h:188
const_iterator begin() const
Definition DictionaryContainer.h:214
bool HasVal() const override
Does the container have a value?
Definition DictionaryContainer.h:206
ValueContainerType::ContainedType ContainedType
Definition DictionaryContainer.h:187
void SetNull() override
Set the container to null.
Definition DictionaryContainer.h:208
KeyT KeyType
Definition DictionaryContainer.h:185
ContainerBase & InsertNullInternal(const void *key, const std::type_info &typeInfo) override
Definition DictionaryContainer.h:380
iterator find(const KeyType &key)
Definition DictionaryContainer.h:219
bool empty() const override
Check if dictionary is empty.
Definition DictionaryContainer.h:224
bool IsNull() const override
Is the container set to null?
Definition DictionaryContainer.h:204
const void * GetKeyAtInternal(const size_t index) const override
Definition DictionaryContainer.h:398
StorageType::iterator iterator
Definition DictionaryContainer.h:190
size_t count(const KeyType &key) const
Definition DictionaryContainer.h:226
ValT ValueContainerType
Definition DictionaryContainer.h:186
size_t size() const override
Get the size of the dictionary, i.e number of contained keys.
Definition DictionaryContainer.h:222
iterator begin()
Definition DictionaryContainer.h:213
size_t erase(const KeyType &key)
Definition DictionaryContainer.h:321
ValueContainerType & operator[](const KeyType &key)
Definition DictionaryContainer.h:228
ContainerBase & GetValueContainerAt(const size_t index) override
Get the container of the value at a particular position in the dictionary.
Definition DictionaryContainer.h:367
const_iterator end() const
Definition DictionaryContainer.h:217
void clear()
clear - Clear the dictionary, i.e remove all keys/values.
Definition DictionaryContainer.h:306
const_iterator find(const KeyType &key) const
Definition DictionaryContainer.h:220
bool IsChanged() const override
IsChanged - Check if the dictionary has changed.
Definition DictionaryContainer.h:272
StorageType::const_iterator const_iterator
Definition DictionaryContainer.h:189
void Copy(const ContainerBase &that) override
Copy - Copy all the members from "that" into "this".
Definition DictionaryContainer.h:337
const ValueContainerType & at(const KeyType &key) const
Like operator[], but throws std::out_of_range if key is not in dictionary.
Definition DictionaryContainer.h:263
void SetChanged(const bool changed) override
SetChanged - Set the change state of the dictionary.
Definition DictionaryContainer.h:292
const ContainerBase & GetValueContainerAt(const size_t index) const override
Const version of GetValueContainerAt()
Definition DictionaryContainer.h:362
iterator end()
Definition DictionaryContainer.h:216
StorageType::value_type value_type
Definition DictionaryContainer.h:191
Meant to be used when something goes very wrong.
Definition Exceptions.h:364
Base class for all object containers.
Definition ObjectContainer.h:45
virtual const ObjectPtr GetObjectPointer() const =0
Get a smart pointer to the contained object.
bool IsChangedHere() const
Is the change flag in the container set?
Definition ObjectContainer.h:73