OpenMAMA C++ API
Wombat::MamaFieldCache Class Reference

The MamaFieldCache class is a collection of unordered MamaFieldCacheField elements. More...

#include <MamaFieldCache.h>

Classes

class  const_iterator
 Iterator type used to iterate over the fields contained in the cache. More...
 
class  iterator
 Iterator type used to iterate over the fields contained in the cache. More...
 
class  MamaFieldCacheIterator
 The MamaFieldCacheIterator class provides a way to iterate over the fields contained in the cache. More...
 

Public Member Functions

 MamaFieldCache ()
 Constructor. More...
 
virtual ~MamaFieldCache ()
 Destructor. More...
 
virtual void create ()
 Create a MamaFieldCache. More...
 
virtual void clear ()
 Clear the MamaFieldCache. More...
 
virtual mama_size_t getSize () const
 Return the number of fields in cache. More...
 
virtual void setTrackModified (bool value)
 Set if field modifications are tracked when creating a delta message. More...
 
virtual bool getTrackModified () const
 Return the value of the track modifications flag. More...
 
virtual void setUseFieldNames (bool value)
 Set if field names are used when adding fields to MamaMsg. More...
 
virtual bool getUseFieldNames () const
 Return the value of the use field names flag. More...
 
virtual void setUseLock (bool value)
 Set if the cache uses a lock when some methods are called for thread safety. More...
 
virtual bool getUseLock () const
 Return the value of the locking flag. More...
 
virtual void lock ()
 Lock the cache. More...
 
virtual void unlock ()
 Unlock the cache. More...
 
virtual const MamaFieldCacheFieldfind (mama_fid_t fid, const char *name=NULL) const
 Retrieve a field from the cache. More...
 
virtual MamaFieldCacheFieldfind (mama_fid_t fid, const char *name=NULL)
 Retrieve a field from the cache. More...
 
virtual void setModified (MamaFieldCacheField &field)
 Set the specified field as modified even if the value has not changed. More...
 
virtual void apply (const MamaFieldCacheField &field)
 Update the cache content with the field given. More...
 
virtual void apply (const MamaMsg &msg, const MamaDictionary *dict=NULL)
 Update the cache content with the data contained in the message. More...
 
virtual void apply (const MamaFieldCacheRecord &record)
 Update the cache content with the data contained in the record. More...
 
virtual void getFullMessage (MamaMsg &msg)
 Populate a MamaMsg with all the fields present in the cache. More...
 
virtual void getDeltaMessage (MamaMsg &msg)
 Populate a MamaMsg with all the fields currently modified in the cache. More...
 
virtual void clearModifiedFields ()
 Clear the list of all the modified fields and reset the modified flags for all the modified fields in the cache. More...
 
virtual const_iterator begin () const
 Return a constant iterator to the first field in the cache and allows to iterate over the fields in the cache. More...
 
virtual iterator begin ()
 Return an iterator to the first field in the cache and allows to iterate over the fields in the cache. More...
 
virtual const_iterator end () const
 Return a const iterator to an invalid element and allows to check if an iterator has arrived to the end (no more elements to iterate). More...
 
virtual iterator end ()
 Return an iterator to an invalid element and allows to check if an iterator has arrived to the end (no more elements to iterate). More...
 

Detailed Description

The MamaFieldCache class is a collection of unordered MamaFieldCacheField elements.

This class provides methods for creating and finding fields, applying changes to the fields in the cache and populating a MamaMsg with the fields in cache.

Constructor & Destructor Documentation

§ MamaFieldCache()

Wombat::MamaFieldCache::MamaFieldCache ( )

Constructor.

Use create to create the actual cache.

§ ~MamaFieldCache()

virtual Wombat::MamaFieldCache::~MamaFieldCache ( )
virtual

Destructor.

This is called automatically when an object is destroyed. This method will clean all the memory allocated.

Member Function Documentation

§ create()

virtual void Wombat::MamaFieldCache::create ( )
virtual

Create a MamaFieldCache.

§ clear()

virtual void Wombat::MamaFieldCache::clear ( )
virtual

Clear the MamaFieldCache.

No fields will be present in the cache after this operation. The cache is ready to be used, as long as create has been called once.

§ getSize()

virtual mama_size_t Wombat::MamaFieldCache::getSize ( ) const
virtual

Return the number of fields in cache.

Returns
The number of fields in cache.

§ setTrackModified()

virtual void Wombat::MamaFieldCache::setTrackModified ( bool  value)
virtual

Set if field modifications are tracked when creating a delta message.

See method getDeltaMessage. When modifications are not tracked, then calling getDeltaMessage is the same as calling getFullMessage.

Parameters
valueSpecify whether field modifications will be tracked.

§ getTrackModified()

virtual bool Wombat::MamaFieldCache::getTrackModified ( ) const
virtual

Return the value of the track modifications flag.

Returns
Whether tracking modifications is enabled or not.

§ setUseFieldNames()

virtual void Wombat::MamaFieldCache::setUseFieldNames ( bool  value)
virtual

Set if field names are used when adding fields to MamaMsg.

See methods getDeltaMessage and getFullMessage.

Parameters
valueSpecify whether field names will be used.

§ getUseFieldNames()

virtual bool Wombat::MamaFieldCache::getUseFieldNames ( ) const
virtual

Return the value of the use field names flag.

Returns
Whether field names are enabled or not.

§ setUseLock()

virtual void Wombat::MamaFieldCache::setUseLock ( bool  value)
virtual

Set if the cache uses a lock when some methods are called for thread safety.

Parameters
valueSpecify whether locking will be used.

§ getUseLock()

virtual bool Wombat::MamaFieldCache::getUseLock ( ) const
virtual

Return the value of the locking flag.

Returns
Whether the cache is using a lock or not.

§ lock()

virtual void Wombat::MamaFieldCache::lock ( )
virtual

Lock the cache.

§ unlock()

virtual void Wombat::MamaFieldCache::unlock ( )
virtual

Unlock the cache.

§ find() [1/2]

virtual const MamaFieldCacheField* Wombat::MamaFieldCache::find ( mama_fid_t  fid,
const char *  name = NULL 
) const
virtual

Retrieve a field from the cache.

If the field is not found then NULL is returned.

Parameters
fidField id of the field to look up.
nameField name of the field to look up.
Returns
The field in the cache (if present)

§ find() [2/2]

virtual MamaFieldCacheField* Wombat::MamaFieldCache::find ( mama_fid_t  fid,
const char *  name = NULL 
)
virtual

Retrieve a field from the cache.

If the field is not found then NULL is returned.

Parameters
fidField id of the field to look up.
nameField name of the field to look up.
Returns
The field in the cache (if present)

§ setModified()

virtual void Wombat::MamaFieldCache::setModified ( MamaFieldCacheField field)
virtual

Set the specified field as modified even if the value has not changed.

Parameters
fieldThe field to set the modified flag to.

§ apply() [1/3]

virtual void Wombat::MamaFieldCache::apply ( const MamaFieldCacheField field)
virtual

Update the cache content with the field given.

If the field is already present, it will be updated, otherwise it will be added to the cache.

Parameters
fieldThe field to use for updating the cache.

§ apply() [2/3]

virtual void Wombat::MamaFieldCache::apply ( const MamaMsg msg,
const MamaDictionary dict = NULL 
)
virtual

Update the cache content with the data contained in the message.

Parameters
msgReference to a MamaMsg containing the fields to update in the cache.
dictReference to a MamaDictionary representing a data dictionary.

§ apply() [3/3]

virtual void Wombat::MamaFieldCache::apply ( const MamaFieldCacheRecord record)
virtual

Update the cache content with the data contained in the record.

Parameters
recordReference to a MamaFieldCacheRecord containing the fields to update in the cache.

§ getFullMessage()

virtual void Wombat::MamaFieldCache::getFullMessage ( MamaMsg msg)
virtual

Populate a MamaMsg with all the fields present in the cache.

Parameters
msgMamaMsg which will be populated with the fields from the cache.

§ getDeltaMessage()

virtual void Wombat::MamaFieldCache::getDeltaMessage ( MamaMsg msg)
virtual

Populate a MamaMsg with all the fields currently modified in the cache.

Note that this method also resets the modification state of the modified fields. If trackModifications flag is set to false, then this method is the same as getFullMessage.

Parameters
msgMamaMsg which will be populated with the modified fields from the cache.

§ clearModifiedFields()

virtual void Wombat::MamaFieldCache::clearModifiedFields ( )
virtual

Clear the list of all the modified fields and reset the modified flags for all the modified fields in the cache.

§ begin() [1/2]

virtual const_iterator Wombat::MamaFieldCache::begin ( ) const
virtual

Return a constant iterator to the first field in the cache and allows to iterate over the fields in the cache.

Returns
An iterator to the first element in the cache.

§ begin() [2/2]

virtual iterator Wombat::MamaFieldCache::begin ( )
virtual

Return an iterator to the first field in the cache and allows to iterate over the fields in the cache.

Returns
An iterator to the first element in the cache.

§ end() [1/2]

virtual const_iterator Wombat::MamaFieldCache::end ( ) const
virtual

Return a const iterator to an invalid element and allows to check if an iterator has arrived to the end (no more elements to iterate).

The content of this iterator must not be accessed.

Returns
An iterator to the first element in the cache.

§ end() [2/2]

virtual iterator Wombat::MamaFieldCache::end ( )
virtual

Return an iterator to an invalid element and allows to check if an iterator has arrived to the end (no more elements to iterate).

The content of this iterator must not be accessed.

Returns
An iterator to the first element in the cache.