mesh3d::attribute_map_collection< Key > Class Template Reference

collection of attribute maps for specific key type

#include <attribute_map_collection.h>

Public Types

typedef map_map::const_iterator const_iterator

Public Member Functions

 attribute_map_collection ()
void clear ()
size_t size () const
template<typename Value >
std::tr1::shared_ptr
< attribute_map< Key, Value > > 
create (std::string const &name)
void insert (std::string const &name, std::tr1::shared_ptr< attribute_map_base< Key > > const &map)
void remove (std::string const &name)
bool has (std::string const &name) const
std::tr1::shared_ptr
< attribute_map_base< Key > > 
find_any (std::string const &name) const
template<typename Value >
std::tr1::shared_ptr
< attribute_map< Key, Value > > 
find (std::string const &name) const
template<typename Value >
std::tr1::shared_ptr
< attribute_map< Key, Value > > 
find_or_create (std::string const &name)
const_iterator begin () const
const_iterator end () const

Detailed Description

template<typename Key>
class mesh3d::attribute_map_collection< Key >

Definition at line 39 of file attribute_map_collection.h.


Member Typedef Documentation

template<typename Key>
typedef map_map::const_iterator mesh3d::attribute_map_collection< Key >::const_iterator

Definition at line 45 of file attribute_map_collection.h.


Constructor & Destructor Documentation

template<typename Key >
mesh3d::attribute_map_collection< Key >::attribute_map_collection (  )  [inline]

Definition at line 43 of file attribute_map_collection.inl.

00044 {
00045 }


Member Function Documentation

template<typename Key >
void mesh3d::attribute_map_collection< Key >::clear (  )  [inline]

Definition at line 48 of file attribute_map_collection.inl.

00049 {
00050     m_maps.clear();
00051 }

template<typename Key >
size_t mesh3d::attribute_map_collection< Key >::size (  )  const [inline]

Definition at line 55 of file attribute_map_collection.inl.

00056 {
00057     return m_maps.size();
00058 }

template<typename Key >
template<typename Value >
std::tr1::shared_ptr< attribute_map< Key, Value > > mesh3d::attribute_map_collection< Key >::create ( std::string const &  name  )  [inline]

Definition at line 113 of file attribute_map_collection.inl.

00114 {
00115     std::tr1::shared_ptr<attribute_map<Key, Value> > p(new attribute_map<Key, Value>);
00116     insert(name, p);
00117     return p;
00118 }

template<typename Key>
void mesh3d::attribute_map_collection< Key >::insert ( std::string const &  name,
std::tr1::shared_ptr< attribute_map_base< Key > > const &  map 
) [inline]

Definition at line 61 of file attribute_map_collection.inl.

00063 {
00064     assert(m_maps.find(name) == m_maps.end());
00065 
00066     m_maps.insert(map_map::value_type(name, map));
00067 }

template<typename Key >
void mesh3d::attribute_map_collection< Key >::remove ( std::string const &  name  )  [inline]

Definition at line 70 of file attribute_map_collection.inl.

00071 {
00072     m_maps.erase(name);
00073 }

template<typename Key >
bool mesh3d::attribute_map_collection< Key >::has ( std::string const &  name  )  const [inline]

Definition at line 76 of file attribute_map_collection.inl.

00077 {
00078     return m_maps.find(name) != m_maps.end();
00079 }

template<typename Key >
std::tr1::shared_ptr< attribute_map_base< Key > > mesh3d::attribute_map_collection< Key >::find_any ( std::string const &  name  )  const [inline]

Definition at line 83 of file attribute_map_collection.inl.

00084 {
00085     const_iterator i = m_maps.find(name);
00086 
00087     if(i == m_maps.end())
00088     {
00089         throw attribute_map_not_found_exception(name);
00090     }
00091 
00092     assert(i != m_maps.end());
00093     return i->second;
00094 }

template<typename Key >
template<typename Value >
std::tr1::shared_ptr< attribute_map< Key, Value > > mesh3d::attribute_map_collection< Key >::find ( std::string const &  name  )  const [inline]

Definition at line 123 of file attribute_map_collection.inl.

00124 {
00125     std::tr1::shared_ptr<attribute_map_base<Key> > p = find_any(name);
00126 
00127     if(
00128         std::tr1::shared_ptr<attribute_map<Key, Value> > 
00129             t = std::tr1::dynamic_pointer_cast<attribute_map<Key, Value> >(p)
00130     )
00131     {
00132         return t;
00133     }
00134     else
00135     {
00136         throw incompatible_attribute_type_exception(
00137             name, 
00138             p->value_type_id().name(),
00139             typeid(Value).name()
00140         );
00141 
00142         //return std::tr1::shared_ptr<attribute_map<Key, Value> >();
00143     }
00144 }

template<typename Key >
template<typename Value >
std::tr1::shared_ptr< attribute_map< Key, Value > > mesh3d::attribute_map_collection< Key >::find_or_create ( std::string const &  name  )  [inline]

Definition at line 149 of file attribute_map_collection.inl.

00150 {
00151     map_map::iterator i = m_maps.find(name);
00152     if(i != m_maps.end())
00153     {
00154         if(
00155             std::tr1::shared_ptr<attribute_map<Key, Value> > 
00156                 t = std::tr1::dynamic_pointer_cast<attribute_map<Key, Value> >(i->second)
00157         )
00158         {
00159             return t;
00160         }
00161         else
00162         {
00163             throw incompatible_attribute_type_exception(
00164                 name, 
00165                 t->value_type_id().name(),
00166                 typeid(Value).name()
00167             );
00168 
00169             //return std::tr1::shared_ptr<attribute_map<Key, Value> >();
00170         }
00171     }
00172     else
00173     {
00174         return create<Value>(name);
00175     }
00176 }

template<typename Key >
attribute_map_collection< Key >::const_iterator mesh3d::attribute_map_collection< Key >::begin (  )  const [inline]

Definition at line 98 of file attribute_map_collection.inl.

00099 {
00100     return m_maps.begin();
00101 }

template<typename Key >
attribute_map_collection< Key >::const_iterator mesh3d::attribute_map_collection< Key >::end (  )  const [inline]

Definition at line 105 of file attribute_map_collection.inl.

00106 {
00107     return m_maps.end();
00108 }


The documentation for this class was generated from the following files:
Generated on Sun Apr 11 12:23:11 2010 for RenderStack by  doxygen 1.6.3