MADARA  3.1.8
madara::knowledge::containers::Collection Class Reference

A collection of MADARA containers that can be used for aggregate operations on all containers in the collection. More...

#include <Collection.h>

Inheritance diagram for madara::knowledge::containers::Collection:
Collaboration diagram for madara::knowledge::containers::Collection:

Public Member Functions

 Collection ()
 Constructor. More...
 
 Collection (const Collection &rhs)
 Copy constructor. More...
 
virtual ~Collection ()
 Destructor. More...
 
void add (const BaseContainer &container)
 Adds a class implementing BaseContainer to the collection. More...
 
void clear (void)
 Clears the collection of all containers. More...
 
virtual BaseContainerclone (void) const
 Clones this container. More...
 
std::string get_debug_info (void)
 Returns the type of the containers along with name and any other useful information. More...
 
std::string get_name (void) const
 Returns the name of the container. More...
 
KnowledgeUpdateSettings get_settings (void)
 Gets the update settings for the container. More...
 
bool is_false (void) const
 Determines if the value of the collection is false. More...
 
bool is_true (void) const
 Determines if all values in the collection are true. More...
 
void modify (void)
 Mark all values in the container as modified. More...
 
virtual bool modify_if_false (BaseContainer &conditional)
 Modifies the container if the argument is false. More...
 
virtual bool modify_if_true (BaseContainer &conditional)
 Modifies the container if the argument is true. More...
 
void set_settings (const KnowledgeUpdateSettings &settings)
 Sets the update settings for all containers. More...
 
size_t size (void) const
 Returns the size of the collection. More...
 

Protected Member Functions

virtual std::string get_debug_info_ (void)
 Returns the type of the container along with name and any other useful information. More...
 
virtual bool is_false_ (void) const
 Polymorphic is false method which can be used to determine if at least one value in the container is false. More...
 
virtual bool is_true_ (void) const
 Polymorphic is true method which can be used to determine if all values in the container are true. More...
 
virtual void modify_ (void)
 Polymorphic modify method used by collection containers. More...
 

Protected Attributes

ThreadSafeContextcontext_
 Variable context that we are modifying. More...
 
MADARA_LOCK_TYPE mutex_
 guard for access and changes More...
 
std::string name_
 Prefix of variable. More...
 
KnowledgeUpdateSettings settings_
 Settings for modifications. More...
 
std::vector< BaseContainer * > vector_
 The underlying collection of containers. More...
 

Detailed Description

A collection of MADARA containers that can be used for aggregate operations on all containers in the collection.

Definition at line 43 of file Collection.h.

Constructor & Destructor Documentation

madara::knowledge::containers::Collection::Collection ( )

Constructor.

Definition at line 3 of file Collection.cpp.

madara::knowledge::containers::Collection::Collection ( const Collection rhs)

Copy constructor.

Parameters
rhsthe source object to copy

Definition at line 9 of file Collection.cpp.

madara::knowledge::containers::Collection::~Collection ( )
virtual

Destructor.

Definition at line 21 of file Collection.cpp.

Member Function Documentation

void madara::knowledge::containers::Collection::add ( const BaseContainer container)
inline

Adds a class implementing BaseContainer to the collection.

Parameters
containerthe container to add

Definition at line 8 of file Collection.inl.

void madara::knowledge::containers::Collection::clear ( void  )
inline

Clears the collection of all containers.

Definition at line 16 of file Collection.inl.

madara::knowledge::containers::BaseContainer * madara::knowledge::containers::Collection::clone ( void  ) const
virtual

Clones this container.

Returns
a deep copy of the container that must be managed by the user (i.e., you have to delete the return value)

Implements madara::knowledge::containers::BaseContainer.

Definition at line 65 of file Collection.cpp.

std::string madara::knowledge::containers::Collection::get_debug_info ( void  )

Returns the type of the containers along with name and any other useful information.

Returns
info in format {container}: {name}{ = value, if appropriate}

Definition at line 38 of file Collection.cpp.

std::string madara::knowledge::containers::Collection::get_debug_info_ ( void  )
protectedvirtual

Returns the type of the container along with name and any other useful information.

The provided information should be useful for developers wishing to debug container operations, especially as it pertains to pending network operations (i.e., when used in conjunction with modify)

Returns
info in format {container}: {name}{ = value, if appropriate}

Implements madara::knowledge::containers::BaseContainer.

Definition at line 59 of file Collection.cpp.

std::string madara::knowledge::containers::BaseContainer::get_name ( void  ) const
inlineinherited

Returns the name of the container.

Returns
name of the container

Definition at line 5 of file BaseContainer.inl.

madara::knowledge::KnowledgeUpdateSettings madara::knowledge::containers::BaseContainer::get_settings ( void  )
inherited

Gets the update settings for the container.

Returns
the current settings

Definition at line 37 of file BaseContainer.cpp.

bool madara::knowledge::containers::Collection::is_false ( void  ) const

Determines if the value of the collection is false.

Returns
true if at least one value is false

Definition at line 100 of file Collection.cpp.

bool madara::knowledge::containers::Collection::is_false_ ( void  ) const
protectedvirtual

Polymorphic is false method which can be used to determine if at least one value in the container is false.

Implements madara::knowledge::containers::BaseContainer.

Definition at line 113 of file Collection.cpp.

bool madara::knowledge::containers::Collection::is_true ( void  ) const

Determines if all values in the collection are true.

Returns
true if all values are true

Definition at line 71 of file Collection.cpp.

bool madara::knowledge::containers::Collection::is_true_ ( void  ) const
protectedvirtual

Polymorphic is true method which can be used to determine if all values in the container are true.

Implements madara::knowledge::containers::BaseContainer.

Definition at line 107 of file Collection.cpp.

void madara::knowledge::containers::Collection::modify ( void  )

Mark all values in the container as modified.

Definition at line 27 of file Collection.cpp.

void madara::knowledge::containers::Collection::modify_ ( void  )
protectedvirtual

Polymorphic modify method used by collection containers.

This method calls the modify method for this class. We separate the faster version (modify) from this version (modify_) to allow users the opportunity to have a fastery version that does not use polymorphic functions (generally virtual functions are half as efficient as normal function calls)

Implements madara::knowledge::containers::BaseContainer.

Definition at line 53 of file Collection.cpp.

bool madara::knowledge::containers::BaseContainer::modify_if_false ( BaseContainer conditional)
virtualinherited

Modifies the container if the argument is false.

Parameters
conditionalthe container that must be false to modify
Returns
true if the container was modified

Definition at line 64 of file BaseContainer.cpp.

bool madara::knowledge::containers::BaseContainer::modify_if_true ( BaseContainer conditional)
virtualinherited

Modifies the container if the argument is true.

Parameters
conditionalthe container that must be true to modify
Returns
true if the container was modified

Definition at line 44 of file BaseContainer.cpp.

void madara::knowledge::containers::Collection::set_settings ( const KnowledgeUpdateSettings settings)
inline

Sets the update settings for all containers.

Parameters
settingsthe new settings to use

Definition at line 29 of file Collection.inl.

size_t madara::knowledge::containers::Collection::size ( void  ) const
inline

Returns the size of the collection.

Returns
size of the collection

Definition at line 41 of file Collection.inl.

Member Data Documentation

ThreadSafeContext* madara::knowledge::containers::BaseContainer::context_
protectedinherited

Variable context that we are modifying.

Definition at line 146 of file BaseContainer.h.

MADARA_LOCK_TYPE madara::knowledge::containers::BaseContainer::mutex_
mutableprotectedinherited

guard for access and changes

Mutex for local changes

Definition at line 141 of file BaseContainer.h.

std::string madara::knowledge::containers::BaseContainer::name_
protectedinherited

Prefix of variable.

Definition at line 151 of file BaseContainer.h.

KnowledgeUpdateSettings madara::knowledge::containers::BaseContainer::settings_
protectedinherited

Settings for modifications.

Definition at line 156 of file BaseContainer.h.

std::vector<BaseContainer *> madara::knowledge::containers::Collection::vector_
protected

The underlying collection of containers.

Definition at line 156 of file Collection.h.


The documentation for this class was generated from the following files: