Rosetta
Public Types | Public Member Functions | Private Attributes | List of all members
basic::datacache::ConstDataMap Class Reference

general-purpose store for any kind of object with the particular copy semantics of copying by value. This is effectively a map of string pairs to (constant) pointers. The first string represents the category of the object, and the second being a name for that particular object. The guarantee with the ConstDataMap is that if an object is put into the map, it may be read from, but it will not be changed underneath you. Data stored in the ConstDataMap can safely be shared between threads. More...

#include <ConstDataMap.hh>

Inheritance diagram for basic::datacache::ConstDataMap:
Inheritance graph
[legend]

Public Types

typedef std::map< std::string, utility::VirtualBaseCOPNamedConstObjectMap
 
typedef std::map< std::string, NamedConstObjectMapCategorizedConstObjectMap
 
typedef CategorizedConstObjectMap::iterator iterator
 
typedef CategorizedConstObjectMap::const_iterator const_iterator
 

Public Member Functions

 ConstDataMap ()
 
 ConstDataMap (ConstDataMap const &src)
 
 ~ConstDataMap () override
 
ConstDataMapoperator= (ConstDataMap const &rhs)
 Performs a shallow copy of all of the pointers stored in rhs into this. More...
 
bool operator== (ConstDataMap const &rhs) const
 Performs pointer comparison to determine if these two maps point at the same data. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void add (std::string const &type, std::string const &name, utility::VirtualBaseCOP const op)
 
bool has (std::string const &category) const
 are there any objects in the outer map with the given category? More...
 
bool has (std::string const &category, std::string const &name) const
 Is there an object with the given category and the given name? More...
 
template<class Ty >
Ty const & get (std::string const &type, std::string const &name) const
 
template<class Ty >
utility::pointer::shared_ptr< Ty const > get_ptr (std::string const &type, std::string const &name) const
 
NamedConstObjectMapoperator[] (std::string const &type)
 
platform::Size size () const
 returns the number of objects contained in the map More...
 
- Public Member Functions inherited from utility::VirtualBase
 VirtualBase ()=default
 Default constructor. More...
 
virtual ~VirtualBase ()=default
 The virtual destructor is one of the main reasons for the VirtualBase class. More...
 
 VirtualBase (VirtualBase const &)=default
 
 VirtualBase (VirtualBase &&)=default
 
VirtualBaseoperator= (VirtualBase const &)=default
 
VirtualBaseoperator= (VirtualBase &&)=default
 

Private Attributes

CategorizedConstObjectMap data_map_
 

Detailed Description

general-purpose store for any kind of object with the particular copy semantics of copying by value. This is effectively a map of string pairs to (constant) pointers. The first string represents the category of the object, and the second being a name for that particular object. The guarantee with the ConstDataMap is that if an object is put into the map, it may be read from, but it will not be changed underneath you. Data stored in the ConstDataMap can safely be shared between threads.

Member Typedef Documentation

◆ CategorizedConstObjectMap

◆ const_iterator

typedef CategorizedConstObjectMap::const_iterator basic::datacache::ConstDataMap::const_iterator

◆ iterator

typedef CategorizedConstObjectMap::iterator basic::datacache::ConstDataMap::iterator

◆ NamedConstObjectMap

Constructor & Destructor Documentation

◆ ConstDataMap() [1/2]

basic::datacache::ConstDataMap::ConstDataMap ( )
default

◆ ConstDataMap() [2/2]

basic::datacache::ConstDataMap::ConstDataMap ( ConstDataMap const &  src)
default

◆ ~ConstDataMap()

basic::datacache::ConstDataMap::~ConstDataMap ( )
overridedefault

Member Function Documentation

◆ add()

void basic::datacache::ConstDataMap::add ( std::string const &  type,
std::string const &  name,
utility::VirtualBaseCOP const  op 
)

◆ begin() [1/2]

ConstDataMap::iterator basic::datacache::ConstDataMap::begin ( )

References data_map_.

◆ begin() [2/2]

ConstDataMap::const_iterator basic::datacache::ConstDataMap::begin ( ) const

References data_map_.

◆ end() [1/2]

ConstDataMap::iterator basic::datacache::ConstDataMap::end ( )

References data_map_.

◆ end() [2/2]

ConstDataMap::const_iterator basic::datacache::ConstDataMap::end ( ) const

References data_map_.

◆ get()

template<class Ty >
Ty const & basic::datacache::ConstDataMap::get ( std::string const &  type,
std::string const &  name 
) const

a template utility function to grab any type of object from the Data_map. Downcasts the VirtualBase object in map to the template data type using dynamic_cast to ensure type-correctness

Exceptions
Throwsa utility::excn::EXCN_Msg_Exception in the event that the requested object cannot be found in the ConstDataMap.

References CREATE_EXCEPTION, data_map_, and has().

Referenced by main().

◆ get_ptr()

template<class Ty >
utility::pointer::shared_ptr< Ty const > basic::datacache::ConstDataMap::get_ptr ( std::string const &  type,
std::string const &  name 
) const

a template utility function to grab any type of object from the ConstDataMap. Downcasts the owning pointer in map to the template data type using dynamic_pointer_cast to ensure type-correctness

Exceptions
Throwsa utility::excn::EXCN_Msg_Exception in the event that the requested object cannot be found in the ConstDataMap.

References CREATE_EXCEPTION, data_map_, and has().

◆ has() [1/2]

bool basic::datacache::ConstDataMap::has ( std::string const &  category) const

are there any objects in the outer map with the given category?

References data_map_.

Referenced by get(), and get_ptr().

◆ has() [2/2]

bool basic::datacache::ConstDataMap::has ( std::string const &  category,
std::string const &  name 
) const

Is there an object with the given category and the given name?

References data_map_.

◆ operator=()

ConstDataMap & basic::datacache::ConstDataMap::operator= ( ConstDataMap const &  rhs)

Performs a shallow copy of all of the pointers stored in rhs into this.

merge-sort style iteration over the elements of both data-maps. This implementation may not be necessary as the STL library may already implement map's assignment operator this way.

References data_map_.

◆ operator==()

bool basic::datacache::ConstDataMap::operator== ( ConstDataMap const &  rhs) const

Performs pointer comparison to determine if these two maps point at the same data.

merge-sort style iteration over the elements of both data-maps.

References data_map_.

◆ operator[]()

ConstDataMap::NamedConstObjectMap & basic::datacache::ConstDataMap::operator[] ( std::string const &  type)

References data_map_.

◆ size()

platform::Size basic::datacache::ConstDataMap::size ( ) const

returns the number of objects contained in the map

References count, and data_map_.

Member Data Documentation

◆ data_map_

CategorizedConstObjectMap basic::datacache::ConstDataMap::data_map_
private

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