DataDictionaryObjectInterface Class Reference

#include <datadictionaryobject.h>

Inheritance diagram for DataDictionaryObjectInterface:

Detailed Description

Class to store and find any data type under any type of key.

DataDictionaryObjectRef values;
values.Set(Data("MachineName"_s), Data(Application::GetMachineInfo().Get(MACHINEINFO::COMPUTERNAME)));
values.Set(Data(Int(100)), Data(Application::GetMachineInfo().Get(MACHINEINFO::OSVERSION)));
values.Set(Data(Vector(1, 0, 0)), Data(String::IntToString(Application::GetMachineInfo().Get(MACHINEINFO::NUMBEROFPROCESSORS))));
static String IntToString(Int32 v)
Definition: c4d_string.h:495
static MAXON_METHOD DataDictionary GetMachineInfo()
MAXON_FUNCTION Result< typename std::conditional< std::is_void< T >::value, typename IsFidClass< KEY >::type, T >::type > Get(KEY &&key) const
Definition: datadictionaryobject.h:129
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
Vec3< Float, 1 > Vector
Definition: vector.h:56

Public Types

using Iterator = DataDictionaryIterator
 
using ConstIterator = DataDictionaryIterator
 

Public Member Functions

MAXON_METHOD Result< void > SetData (ForwardingDataPtr &&key, Data &&data)
 
MAXON_FUNCTION Result< void > SetData (ForwardingDataPtr &&key, const Data &data)
 
MAXON_METHOD Result< DataGetData (const ConstDataPtr &key) const
 
template<typename KEY >
MAXON_FUNCTION Bool Contains (KEY &&key) const
 
MAXON_METHOD Result< void > EraseData (const ConstDataPtr &key)
 
MAXON_METHOD void Reset ()
 
MAXON_METHOD Bool IsEmpty () const
 
MAXON_FUNCTION Bool IsPopulated () const
 
template<typename REFCLASS , typename T = void, typename KEY >
MAXON_FUNCTION Result< typename std::conditional< std::is_void< T >::value, typename IsFidClass< KEY >::type, T >::typeGet (KEY &&key) const
 
template<typename REFCLASS , typename T , typename KEY >
MAXON_FUNCTION std::conditional< IsFidClass< KEY >::value &&GetCollectionKind< T >::value !=COLLECTION_KIND::ARRAY, typename IsFidClass< KEY >::type, T >::type Get (KEY &&key, const T &defaultValue) const
 
template<typename REFCLASS , typename T , typename KEY >
MAXON_FUNCTION std::conditional< IsFidClass< KEY >::value &&GetCollectionKind< T >::value !=COLLECTION_KIND::ARRAY, typename IsFidClass< KEY >::type, T >::type Get (KEY &&key, T &&defaultValue) const
 
template<typename T = void, typename KEY >
MAXON_FUNCTION std::conditional< std::is_void< T >::value, typename IsFidClass< KEY >::type, T >::type GetOrDefault (KEY &&key) const
 
template<typename REFCLASS , typename T , typename KEY >
MAXON_FUNCTION Result< void > Set (KEY &&key, T &&data)
 
template<typename REFCLASS , typename KEY >
MAXON_FUNCTION Result< void > Erase (KEY &&key)
 
MAXON_METHOD void InitIterator (DataDictionaryIteratorInterface *iterator, Bool end) const
 
MAXON_FUNCTION ConstIterator Begin () const
 
MAXON_FUNCTION ConstIterator End () const
 
template<typename T , typename KEY >
std::conditional< std::is_void< T >::value, typename IsFidClass< KEY >::type, T >::type GetOrDefault (KEY &&key) const
 

Private Member Functions

 MAXON_INTERFACE (DataDictionaryObjectInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.datadictionaryobject")
 

Member Typedef Documentation

◆ Iterator

◆ ConstIterator

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( DataDictionaryObjectInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.interface.datadictionaryobject"   
)
private

◆ SetData() [1/2]

MAXON_METHOD Result<void> SetData ( ForwardingDataPtr &&  key,
Data &&  data 
)

Set Data under a specific id. the data type needs to be registered.

Parameters
[in]keyId under which the data is stored.
[in,out]dataMove reference to the data.
Returns
OK on success. @MAXON_ANNOTATION{returnsThis}

◆ SetData() [2/2]

MAXON_FUNCTION Result<void> SetData ( ForwardingDataPtr &&  key,
const Data data 
)

Set Data under a specific id.

Parameters
[in]keyId under which the data is stored.
[in]dataReference to the data.
Returns
OK on success. @MAXON_ANNOTATION{returnsThis}

◆ GetData()

MAXON_METHOD Result<Data> GetData ( const ConstDataPtr key) const

Get data stored under a specific id.

Parameters
[in]keyId under which the data is stored.
Returns
Data as Data class.

◆ Contains()

MAXON_FUNCTION Bool Contains ( KEY &&  key) const

Check if there is data stored under a specific key.

Parameters
[in]keyKey under which the data should be stored.
Returns
True if existent.

◆ EraseData()

MAXON_METHOD Result<void> EraseData ( const ConstDataPtr key)

Remove a data entry from the dictionary. This function doesn't check if the dictionary contained the key.

Parameters
[in]keyId under which the data is stored.
Returns
OK on success. This function doesn't check if the dictionary contained the key.

◆ Reset()

MAXON_METHOD void Reset ( )

Frees the entire dictionary. After this call the DataDictionary is empty.

◆ IsEmpty()

MAXON_METHOD Bool IsEmpty ( ) const

Checks if the dictionary is empty.

Returns
True if the dictionary does not contain any elements. @MAXON_ANNOTATION{default=true}

◆ IsPopulated()

MAXON_FUNCTION Bool IsPopulated ( void  ) const

Checks if the dictionary contains anything.

Returns
True if the dictionary contains any elements.

◆ Get() [1/3]

MAXON_FUNCTION Result<typename std::conditional<std::is_void<T>::value, typename IsFidClass<KEY>::type, T>::type> Get ( KEY &&  key) const

Get data stored under a specific key. If the key is not found an error will be returned. This functions offers 2 possible calls. First using an FId "dict.Get(MAXCHINEINFO::COMPUTERNAME)" or second using any type directly together with the result type "dict.Get<String>(Int32(5))". The data type needs to be registered.

Parameters
[in]keyKey under which the data is stored.
Returns
Data converted to the right type on success. @MAXON_ANNOTATION{refclassParameter=REFCLASS}

◆ Get() [2/3]

MAXON_FUNCTION std::conditional<IsFidClass<KEY>::value&& GetCollectionKind<T>::value != COLLECTION_KIND::ARRAY, typename IsFidClass<KEY>::type, T>::type Get ( KEY &&  key,
const T &  defaultValue 
) const

Get data stored under a specific key. If the key is not found the given default value will be returned. This functions offers 2 possible calls. First using an FId "dict.Get(MAXCHINEINFO::COMPUTERNAME, String())" or second using any type directly together with the result type "dict.Get(Int32(5), String())". The data type needs to be registered.

Parameters
[in]keyKey under which the data is stored.
[in]defaultValueDefault value which should be returned if the key cannot be found.
Returns
Data converted to the right type if found in the dictionary, otherwise the default value. @MAXON_ANNOTATION{refclassParameter=REFCLASS}

◆ Get() [3/3]

MAXON_FUNCTION std::conditional<IsFidClass<KEY>::value&& GetCollectionKind<T>::value != COLLECTION_KIND::ARRAY, typename IsFidClass<KEY>::type, T>::type Get ( KEY &&  key,
T &&  defaultValue 
) const

Get data stored under a specific key. If the key is not found the given default value will be returned. This functions offers 2 possible calls. First using an FId "dict.Get(MAXCHINEINFO::COMPUTERNAME, String())" or second using any type directly together with the result type "dict.Get(Int32(5), String())". The data type needs to be registered.

Parameters
[in]keyKey under which the data is stored.
[in]defaultValueDefault value which should be returned if the key cannot be found.
Returns
Data converted to the right type if found in the dictionary, otherwise the default value. @MAXON_ANNOTATION{refclassParameter=REFCLASS}

◆ GetOrDefault()

MAXON_FUNCTION std::conditional<std::is_void<T>::value, typename IsFidClass<KEY>::type, T>::type GetOrDefault ( KEY &&  key) const

Get data stored under a specific key. If the key is not found the given default value will be returned. This functions offers 2 possible calls. First using an FId "dict.Get(MAXCHINEINFO::COMPUTERNAME, String())" or second using any type directly together with the result type "dict.Get(Int32(5), String())". The data type needs to be registered.

Parameters
[in]keyKey under which the data is stored.
Returns
Data converted to the right type if found in the dictionary, otherwise the default value.

◆ Set()

MAXON_FUNCTION Result<void> Set ( KEY &&  key,
T &&  data 
)

Set data under a specific id. this function is template to allow implicit Set calls for each data type. This functions offers 2 possible calls. First using an FId "dict.Set(MAXCHINEINFO::COMPUTERNAME, "data"_s)" or second using any type directly "dict.Set(Int32(5), "data"_s)". The data type needs to be registered.

Parameters
[in]keyKey under which the data is stored.
[in]dataData to be stored in the dictionary.
Returns
OK on success. @MAXON_ANNOTATION{returnsThis,refclassParameter=REFCLASS}

◆ Erase()

MAXON_FUNCTION Result<void> Erase ( KEY &&  key)

Erase data stored under a specific key. This function doesn't check if the dictionary contained the key. This functions offers 2 possible calls. First using an FId "dict.Erase(MAXCHINEINFO::COMPUTERNAME)" or second using any type directly "dict.Erase(Int32(5))". The data type needs to be registered.

Parameters
[in]keyKey under which the data is stored.
Returns
OK on success. This function doesn't check if the dictionary contained the key. @MAXON_ANNOTATION{refclassParameter=REFCLASS}

◆ InitIterator()

MAXON_METHOD void InitIterator ( DataDictionaryIteratorInterface iterator,
Bool  end 
) const

Helper functions for iterator.

◆ Begin()

MAXON_FUNCTION ConstIterator Begin ( ) const

Returns the begin iterator of the DataDictionary. You can use the Iterator to run through all elements of the DataDictionary.

◆ End()

Returns the end iterator of the DataDictionary. You can use the Iterator to run through all elements of the DataDictionary.