#include <vpr/Util/AttributeMapBase.h>
Inheritance diagram for vpr::AttributeMapBase:

Public Member Functions | |
| template<typename TYPE> | |
| void | setAttrib (const std::string &name, TYPE val) |
| Sets an attribute to the given value. | |
| template<typename TYPE> | |
| TYPE | getAttrib (const std::string &name) |
| Gets an attribute value. | |
| bool | attribExists (const std::string &name) |
| Does the named attribute exist? | |
Useful for having custom setter/getter type settings that are only used in certain contexts.
This is based upon boost::any type.
Definition at line 63 of file AttributeMapBase.h.
| void vpr::AttributeMapBase::setAttrib | ( | const std::string & | name, | |
| TYPE | val | |||
| ) | [inline] |
Sets an attribute to the given value.
| name | The name of the attribute to set. | |
| val | The value to be set. |
Definition at line 73 of file AttributeMapBase.h.
| TYPE vpr::AttributeMapBase::getAttrib | ( | const std::string & | name | ) | [inline] |
Gets an attribute value.
If not previously set, then return the value of a default constructed instance of the given type.
Definition at line 85 of file AttributeMapBase.h.
References attribExists().
00086 { 00087 TYPE ret_val; // Construct default return value 00088 if(attribExists(name)) 00089 { 00090 boost::any any_val = mAttribMap[name]; 00091 try 00092 { 00093 ret_val = boost::any_cast<TYPE>(any_val); 00094 } 00095 catch(const boost::bad_any_cast&) 00096 { 00097 ret_val = TYPE(); // Default value 00098 } 00099 } 00100 return ret_val; 00101 }
| bool vpr::AttributeMapBase::attribExists | ( | const std::string & | name | ) | [inline] |
Does the named attribute exist?
true if it exists. Definition at line 107 of file AttributeMapBase.h.
Referenced by getAttrib().
00108 { 00109 attrib_map_t::iterator found = mAttribMap.find(name); 00110 return (found != mAttribMap.end()); 00111 }
1.5.1