#include <property_server.h>
Public Types | |
typedef ContextType | context_type |
The "sharing context" used by this type. | |
typedef ObjIDType | object_id_type |
The type used to key objects to their properties. | |
typedef KeyType | key_type |
The key type used for properties. | |
typedef std::map< key_type, std::string > | property_map_type |
The underlying data store for properties. | |
Static Public Member Functions | |
template<typename ValueType> | |
static void | set (const object_id_type objid, const key_type &key, const ValueType &val) |
Sets the property key to val for objid. | |
template<typename ValueType> | |
static ValueType | get (const object_id_type objid, const key_type &key, const ValueType &defaultval) |
Returns the property key for objid. | |
static void | unset (const object_id_type objid, const key_type &key) |
Removes the given property from the given object. | |
static void | clear (const object_id_type objid) |
Removes the property map for objid, freeing up any resources it consumed. | |
static void | clear_all () |
Removes all properties for all objects. | |
static property_map_type * | get_map (const object_id_type objid) |
Returns a pointer to the given object's property map, or 0 if no properties have been set for the object (or if clear(objid) has been called). |
It supports, as values, any data types which are i/ostreamable using their >>istream
or ostream<<
operators.
License: Do As You Damned Well Please Author: stephan@s11n.net
Definition at line 23 of file property_server.h.
|
Returns the property key for objid. If there is an error converting the value to ValueType, or if the property does not exist, defaultval is returned. This can be used to implement custom error handling by passing a known-invalid value as defaultval and interpretting it as an error value. If there is *no* known-invalid combinations then you can check twice with two different defaulvals. If defaultval is returned both times then there is definately an error, because valid data would only be interpretted one way and you've checked against two different defaultvals. Definition at line 63 of file property_server.h. |
|
Returns a pointer to the given object's property map, or 0 if no properties have been set for the object (or if clear(objid) has been called). The caller does not own the returned pointer and (ideally) should not modify the map directly (prefer get() and set()). It is provided here primarily for serialization purposes: so the map can be saved and loaded using arbitrary serialization techniques. Definition at line 117 of file property_server.h. |