9 #ifndef CMHPropertiesValuesList_H 10 #define CMHPropertiesValuesList_H 59 CMHPropertiesValuesList( const CMHPropertiesValuesList& o );
63 CMHPropertiesValuesList & operator =( const CMHPropertiesValuesList& o );
67 virtual ~CMHPropertiesValuesList();
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 );
99 CSerializablePtr getAnyHypothesis(
const char *propertyName)
const;
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);
117 void removeAll(
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)
180 std::vector<std::string> getPropertyNames()
const;
186 iterator
begin() {
return m_properties.begin(); }
187 const_iterator
begin()
const {
return m_properties.begin(); }
188 iterator
end() {
return m_properties.end(); }
189 const_iterator
end()
const {
return m_properties.end(); }
191 size_t size()
const {
return m_properties.size(); }
An arbitrary list of "annotations", or named attributes, each being an instance of any CSerializable ...
TPropertyValueIDTriplet()
std::vector< TPropertyValueIDTriplet >::const_iterator const_iterator
#define MRPT_END_WITH_CLEAN_UP(stuff)
The virtual base class which provides a unified interface for all persistent objects in MRPT...
#define THROW_EXCEPTION(msg)
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, from an elemental data type.
const Scalar * const_iterator
R * getAs(SMART_PTR &o)
Utility to get a cast'ed pointer from a smart pointer.
const_iterator end() const
Internal triplet for each property in utils::CMHPropertiesValuesList.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
bool BASE_IMPEXP strCmpI(const std::string &s1, const std::string &s2)
Return true if the two strings are equal (case insensitive)
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...
A memory buffer (implements CStream) which can be itself serialized.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
CMHPropertiesValuesListPtr SmartPtr
std::vector< TPropertyValueIDTriplet >::iterator iterator
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name)
A structure that holds runtime class type information.
const_iterator begin() const
#define THROW_EXCEPTION_CUSTOM_MSG1(msg, param1)