9#ifndef CMHPropertiesValuesList_H
10#define CMHPropertiesValuesList_H
75 CSerializablePtr
get(
const char *propertyName,
const int64_t & hypothesis_ID )
const;
80 typename T::SmartPtr
getAs(
const char *propertyName,
const int64_t & hypothesis_ID,
bool allowNullPointer =
true)
const
83 CSerializablePtr obj = get(propertyName,hypothesis_ID);
87 return typename T::SmartPtr();
91 ASSERT_( class_ID == obj->GetRuntimeClass() );
92 return typename T::SmartPtr( obj );
104 void set(
const char *propertyName,
const CSerializablePtr &obj,
const int64_t & hypothesis_ID);
109 void setMemoryReference(
const char *propertyName,
const CSerializablePtr& obj,
const int64_t & hypothesis_ID);
113 void remove(
const char *propertyName,
const int64_t & hypothesis_ID);
122 void setElemental(
const char *propertyName,
const T &data,
const int64_t & hypothesis_ID)
126 CMemoryChunkPtr memChunk = CMemoryChunkPtr(
new CMemoryChunk() );
127 memChunk->setAllocBlockSize(10);
136 it->value = memChunk;
143 newPair.
name = std::string(propertyName);
144 newPair.
value = memChunk;
145 newPair.
ID = hypothesis_ID;
146 m_properties.push_back(newPair);
149 printf(
"Exception while setting annotation '%s'",propertyName); \
157 bool getElemental(
const char *propertyName, T &out_data,
const int64_t & hypothesis_ID,
bool raiseExceptionIfNotFound =
false)
const
164 CMemoryChunkPtr memChunk = CMemoryChunkPtr(it->value);
166 if (memChunk->getTotalBytesCount()!=
sizeof(out_data))
THROW_EXCEPTION(
"Data sizes do not match.");
167 out_data = *
static_cast<T*
>( memChunk->getRawBufferData() );
172 if (raiseExceptionIfNotFound)
191 size_t size()
const {
return m_properties.size(); }
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name)
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
An arbitrary list of "annotations", or named attributes, each being an instance of any CSerializable ...
void remove(const char *propertyName, const int64_t &hypothesis_ID)
Remove a given property, if it exists.
CSerializablePtr getAnyHypothesis(const char *propertyName) const
Returns the value of the property (case insensitive) for the first hypothesis ID found,...
std::vector< std::string > getPropertyNames() const
Returns the name of all properties in the list.
CMHPropertiesValuesList()
Default constructor.
void clear()
Clears the list and frees all object's memory.
void setMemoryReference(const char *propertyName, const CSerializablePtr &obj, const int64_t &hypothesis_ID)
Sets/change the value of the property (case insensitive) for the given hypothesis ID,...
CMHPropertiesValuesList(const CMHPropertiesValuesList &o)
Copy constructor.
virtual ~CMHPropertiesValuesList()
Destructor.
T::SmartPtr getAs(const char *propertyName, const int64_t &hypothesis_ID, bool allowNullPointer=true) const
Returns the value of the property (case insensitive) for some given hypothesis ID checking its class ...
const_iterator end() const
void set(const char *propertyName, const CSerializablePtr &obj, const int64_t &hypothesis_ID)
Sets/change the value of the property (case insensitive) for the given hypothesis ID,...
void setElemental(const char *propertyName, const T &data, const int64_t &hypothesis_ID)
Sets/change the value of a property (case insensitive) for the given hypothesis ID,...
void removeAll(const int64_t &hypothesis_ID)
Remove all the properties for the given hypothesis.
std::vector< TPropertyValueIDTriplet > m_properties
std::vector< TPropertyValueIDTriplet >::iterator iterator
bool getElemental(const char *propertyName, T &out_data, const int64_t &hypothesis_ID, bool raiseExceptionIfNotFound=false) const
Gets the value of a property (case insensitive) for the given hypothesis ID, retrieves it as an eleme...
std::vector< TPropertyValueIDTriplet >::const_iterator const_iterator
const_iterator begin() const
CSerializablePtr get(const char *propertyName, const int64_t &hypothesis_ID) const
Returns the value of the property (case insensitive) for some given hypothesis ID,...
A memory buffer (implements CStream) which can be itself serialized.
The virtual base class which provides a unified interface for all persistent objects in MRPT.
const Scalar * const_iterator
bool BASE_IMPEXP strCmpI(const std::string &s1, const std::string &s2)
Return true if the two strings are equal (case insensitive)
#define THROW_EXCEPTION_CUSTOM_MSG1(msg, param1)
#define MRPT_END_WITH_CLEAN_UP(stuff)
#define THROW_EXCEPTION(msg)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Internal triplet for each property in utils::CMHPropertiesValuesList.
TPropertyValueIDTriplet()
A structure that holds runtime class type information.