FiReS  0.2.0
FiReS - Filter, Retrieval and Search
fires::Object Class Reference

A class to represent objects that can be used in fires. More...

#include <Object.h>

+ Collaboration diagram for fires::Object:

Public Member Functions

 Object ()
 Default constructor.
 
 Object (const Object &object)
 Copy constructor.
 
virtual ~Object ()
 Destructor.
 
void registerProperty (const std::string &label, const Property &property)
 Register a property to this object. More...
 
bool unregisterProperty (const std::string &label)
 Unregister a property of this object. More...
 
PropertygetProperty (const std::string &label)
 Get a property of this object. More...
 
const PropertygetProperty (const std::string &label) const
 Get a property of this object as const. More...
 
template<class ValueType >
ValueType getPropertyValue (const std::string &propertyLabel, const ValueType defaultValue) const
 Get a property value of this object. More...
 
template<class ValueType >
ValueType getPropertyValue (const std::string &propertyLabel) const
 Get a property value of this object. More...
 
Propertyoperator[] (const std::string &label)
 Get a property of this object. More...
 
bool setProperty (const std::string &label, const Property &property)
 Set a property of this object. More...
 
bool hasProperty (const std::string &label) const
 Queries if a property has been registered in this object. More...
 
void clearProperties (void)
 Clears the properties of this object (no memory freeing)
 
ObjectPropertiesproperties (void)
 Get all properties. More...
 
const ObjectPropertiesproperties (void) const
 Get all properties as const. More...
 
std::string & label (void)
 Get a reference to the label of the object. More...
 
const std::string & label (void) const
 Get the label of the object as const. More...
 
void serialize (std::ostream &stream, bool minimizeStream=true, const std::string &linePrefix="") const
 Serialize this object properties. More...
 
void deserialize (std::istream &stream)
 Reads and loads this object properties stream containing JSON from which data will be loaded.
 
void deserialize (const boost::property_tree::ptree &root)
 Reads and loads this object properties boost JSON root object from which data will be loaded.
 
Operators
Objectoperator= (const Object &other)
 

Protected Attributes

ObjectProperties _properties
 Set of properties of this object.
 
std::string _label
 Label of this object.
 

Detailed Description

A class to represent objects that can be used in fires.

This class provides access to object properties and properties

Definition at line 63 of file Object.h.

Member Function Documentation

Property& fires::Object::getProperty ( const std::string &  label)

Get a property of this object.

Parameters
labellabel string to retrieve the property
Returns
the property if found and throw exception otherwise
const Property& fires::Object::getProperty ( const std::string &  label) const

Get a property of this object as const.

Parameters
labellabel string to retrieve the property
Returns
the property if found and throw exception otherwise
template<class ValueType >
ValueType fires::Object::getPropertyValue ( const std::string &  propertyLabel,
const ValueType  defaultValue 
) const
inline

Get a property value of this object.

Parameters
labellabel string to retrieve the property
defaultValuereturn value if property not found
Returns
the property value if found else the defaultValue

Definition at line 134 of file Object.h.

template<class ValueType >
ValueType fires::Object::getPropertyValue ( const std::string &  propertyLabel) const
inline

Get a property value of this object.

Parameters
labellabel string to retrieve the property
Returns
the property value

Definition at line 154 of file Object.h.

bool fires::Object::hasProperty ( const std::string &  label) const

Queries if a property has been registered in this object.

Parameters
labellabel string to retrieve the property
Returns
true if found
std::string& fires::Object::label ( void  )

Get a reference to the label of the object.

Returns
reference to label
const std::string& fires::Object::label ( void  ) const

Get the label of the object as const.

Returns
label of the object as const
Property& fires::Object::operator[] ( const std::string &  label)

Get a property of this object.

Parameters
labellabel string to retrieve the property
Returns
the property if found and throw exception otherwise
ObjectProperties& fires::Object::properties ( void  )

Get all properties.

Returns
all properties
const ObjectProperties& fires::Object::properties ( void  ) const

Get all properties as const.

Returns
all properties
void fires::Object::registerProperty ( const std::string &  label,
const Property property 
)

Register a property to this object.

Parameters
labellabel string for the property
propertyproperty to be added

Referenced by fires::PropertyManager::registerProperty().

+ Here is the caller graph for this function:

void fires::Object::serialize ( std::ostream &  stream,
bool  minimizeStream = true,
const std::string &  linePrefix = "" 
) const

Serialize this object properties.

Parameters
streamto write the object
linePrefixprefix at the start of every line
bool fires::Object::setProperty ( const std::string &  label,
const Property property 
)

Set a property of this object.

Parameters
labellabel string to retrieve the property
propertyproperty to be setted
Returns
true in case property was setted, false otherwise
bool fires::Object::unregisterProperty ( const std::string &  label)

Unregister a property of this object.

Parameters
labellabel of the property to be deleted
Returns
true if the property could be deleted

The documentation for this class was generated from the following file: