78 static std::string NAME =
typeid(T).name();
88 inline T *
allocArray(
const std::string &
id,
unsigned int n){
90 ERROR_LOG(
"unable to create an array of size 0 for id " <<
id <<
"!");
94 ERROR_LOG(
"id " <<
id <<
"is already defined");
100 da.
type = get_type_name<T>();
102 return reinterpret_cast<T*>(da.
data);
111 inline T &
allocValue(
const std::string &
id,
const T &val=T()){
112 static T _NULL = T();
114 ERROR_LOG(
"id " <<
id <<
"is already defined");
118 da.
data =
new T(val);
120 da.
type = get_type_name<T>();
123 return *(reinterpret_cast<T*>(da.
data));
131 ERROR_LOG(
"id "<<
id <<
" not found \n");
135 if(da.
type != get_type_name<T>()){
136 ERROR_LOG(
"unable to cast "<<
id <<
" to a given type "<< get_type_name<T>() <<
"\n");
141 m_oDataMapPtr->erase(m_oDataMapPtr->find(
id));
150 inline T*
getArray(
const std::string &
id,
int *lenDst=0){
152 ERROR_LOG(
"id "<<
id <<
" not found \n");
158 if(da.
type != get_type_name<T>()){
159 ERROR_LOG(
"unable to cast "<<
id <<
" to a given type "<< get_type_name<T>() <<
"\n");
163 ERROR_LOG(
"unable to access entry " <<
id <<
" as array, because it is a value!");
166 if(lenDst) *lenDst = da.
len;
167 return reinterpret_cast<T*>(da.
data);
176 inline T &
getValue(
const std::string &
id,
bool checkType=
true){
179 ERROR_LOG(
"id "<<
id <<
" not found \n");
186 if(checkType && (da.
type != get_type_name<T>())){
187 ERROR_LOG(
"unable to cast "<<
id <<
" to a given type "<< get_type_name<T>() <<
"\n");
192 ERROR_LOG(
"unable to access entry " <<
id <<
" as value, because it is an array!");
195 return *reinterpret_cast<T*>(da.
data);
199 inline const T &
getValue(
const std::string &
id,
bool checkType=
true)
const{
200 return const_cast<MultiTypeMap*>(
this)->getValue<T>(id,checkType);
209 const std::string &getType(
const std::string &
id)
const;
216 return check_type_internal(
id,get_type_name<T>());
223 bool isArray(
const std::string &
id)
const;
228 bool contains(
const std::string &
id)
const;
232 inline void lock()
const { m_oMutexPtr->lock(); }
235 inline void unlock()
const { m_oMutexPtr->unlock(); }
238 bool check_type_internal(
const std::string &
id,
const std::string &typestr)
const;
249 if(da->
len)
delete [] reinterpret_cast<T*>(da->
data);
250 else delete reinterpret_cast<T*>(da->
data);
262 void listContents()
const;
271 Entry(
const std::string &key,
const std::string &type,
int len):
272 key(key),type(type),len(len){}
279 std::vector<Entry> getEntryList()
const;
284 typedef std::map<std::string,DataArray>
DataMap;
Entry()
Definition: MultiTypeMap.h:270
undocument this line if you encounter any issues!
Definition: Any.h:37
std::string key
Definition: MultiTypeMap.h:273
Abstract and associative Data Container for Data of different types.
Definition: MultiTypeMap.h:67
SmartDataMapPtr m_oDataMapPtr
Smart-Pointer to the underlying data (allows shallow copies)
Definition: MultiTypeMap.h:293
void release(const std::string &id)
release the data element that is associated with the given id
Definition: MultiTypeMap.h:129
#define ICLUtils_API
this macros are important for creating dll's
Definition: CompatMacros.h:171
void lock() const
Definition: MultiTypeMap.h:232
Entry(const std::string &key, const std::string &type, int len)
Definition: MultiTypeMap.h:271
void(* release_func)(DataArray *)
Definition: MultiTypeMap.h:257
std::string type
Definition: MultiTypeMap.h:274
DataArray(void *data=0, int len=0)
Create an empty DataArray object.
Definition: MultiTypeMap.h:253
T * getArray(const std::string &id, int *lenDst=0)
get a T* that is associated with the given id
Definition: MultiTypeMap.h:150
bool checkType(const std::string &id) const
checks if the type-id associated with the template parameter T is compatible to the entry for id
Definition: MultiTypeMap.h:215
ICLQt_API ImgROI data(ImgQ &r)
creates full ROI ROI-struct
static const std::string & get_type_name()
internally used wrapper function for RTTI
Definition: MultiTypeMap.h:77
const T & getValue(const std::string &id, bool checkType=true) const
Definition: MultiTypeMap.h:199
internally used data handling structure
Definition: MultiTypeMap.h:241
std::string type
Definition: MultiTypeMap.h:256
T & getValue(const std::string &id, bool checkType=true)
get a T reference that is associated with the given id
Definition: MultiTypeMap.h:176
#define ERROR_LOG(x)
Definition: Macros.h:111
entry struct used in getEntryList function
Definition: MultiTypeMap.h:269
std::map< std::string, DataArray > DataMap
internal definition
Definition: MultiTypeMap.h:284
#define ICLASSERT_RETURN(X)
Definition: Macros.h:141
static void release_data_array(DataArray *da)
delete function, given to the data Array after construction to delete its own data
Definition: MultiTypeMap.h:247
SmartPtr< Mutex > SmartMutexPtr
internal definition
Definition: MultiTypeMap.h:290
void * data
Definition: MultiTypeMap.h:254
int len
Definition: MultiTypeMap.h:275
int len
Definition: MultiTypeMap.h:255
T * allocArray(const std::string &id, unsigned int n)
Allocates a new memory block (new T[n]) for the given id string.
Definition: MultiTypeMap.h:88
SmartMutexPtr m_oMutexPtr
mutex to handle syncronous calls
Definition: MultiTypeMap.h:296
SmartPtr< DataMap > SmartDataMapPtr
internal definition
Definition: MultiTypeMap.h:287
void unlock() const
internally unlocks the data store
Definition: MultiTypeMap.h:235
T & allocValue(const std::string &id, const T &val=T())
Allocates a new memory elements (new T(val)) for the given id string.
Definition: MultiTypeMap.h:111