Loading...
Searching...
No Matches
BALL::PropertyManager Class Reference

`#include <BALL/CONCEPT/property.h>`

Inheritance diagram for BALL::PropertyManager:

## Public Member Functions

Constructors and Destructors
BALL_INLINE | PropertyManager ()
| Default constructor.
BALL_INLINE | PropertyManager (const PropertyManager &property_manager)
| Copy constructor.
virtual | ~PropertyManager ()
| Destructor.
virtual void | clear ()
| Clears all properties.
virtual void | destroy ()
| Clears all properties.
Assignment
void | set (const PropertyManager &property_manager)
const PropertyManager & | operator= (const PropertyManager &property_manager)
void | get (PropertyManager &property_manager) const
void | swap (PropertyManager &property_manager)
Accessors
BitVector & | getBitVector ()
const BitVector & | getBitVector () const
Converters
| operator BitVector & ()
Handling unnamed bit properties
void | setProperty (Property property)
void | clearProperty (Property property)
void | toggleProperty (Property property)
Size | countProperties () const
Handling named properties
PropertyManager contains an vector of NamedProperty objects. Each of the NamedProeprty objects has to have a unique name. The setProperty methods ensure the uniqueness of this name. If a setProperty method is called for an existing name, the existing object is destructed prior to the insertion of the new object.
const NamedProperty & | getNamedProperty (Position index) const
NamedProperty & | getNamedProperty (Position index)
void | setProperty (const NamedProperty &property)
void | setProperty (const std::string &name)
void | setProperty (const std::string &name, bool value)
void | setProperty (const std::string &name, int value)
void | setProperty (const std::string &name, unsigned int value)
void | setProperty (const std::string &name, float value)
void | setProperty (const std::string &name, double value)
void | setProperty (const std::string &name, const std::string &value)
void | setProperty (const std::string &name, const PersistentObject &value)
const NamedProperty & | getProperty (const std::string &name) const
NamedPropertyIterator | beginNamedProperty ()
NamedPropertyIterator | endNamedProperty ()
void | clearProperty (const std::string &name)
Size | countNamedProperties () const
Predicates
bool | hasProperty (Property property) const
| Query for an unnamed property.
bool | hasProperty (const std::string &name) const
| Query for a named property.
bool | operator== (const PropertyManager &pm) const
bool | operator!= (const PropertyManager &pm) const
| Inequality operator.
Storable Interface
void | write (PersistenceManager &pm) const
| Persistent stream writing.
bool | read (PersistenceManager &pm)
| Persistent stream reading.

## Debugging and Diagnostics

bool | isValid () const
void | dump (std::ostream &s=std::cout, Size depth=0) const

## Detailed Description

Property Manager class. This class manages properties of a class. A property can be seen as easy way to extend the class BALL_EXPORT' attributes without changing its interface. There are different types of properties defined depending on the kind of data stored. The simplest kind of property is just stored as a boolean information: Either an object has a certain property, or it does not. These properties are obviously coded as a BitVector. However the meaning of the different bits has to be defined and the uniqueness of this meaning has to be guaranteed. In order to avoid this, all kernel classes derived from PropertyManager contain a public enum that defines a value NUMBER_OF_PROPERTIES. All user defined properties should refer to this constant (e.g. by defining MY_PROPERTY = Molecule::NUMBER_OF_PROPERTIES + 1).

  The second way of storing properties is much more flexible, but less efficient. It uses the class NamedProperty that also allows to store additional information along with the property. In this case, each property is accessed via a unique name.

  Interface: Storable

Definition at line 343 of file property.h.

## Constructor & Destructor Documentation

## PropertyManager() [1/2]

BALL_INLINE BALL::PropertyManager::PropertyManager | ( |  | ) |

Default constructor.

## PropertyManager() [2/2]

BALL_INLINE BALL::PropertyManager::PropertyManager | ( | const PropertyManager & | property_manager | ) |

Copy constructor.

## ~PropertyManager()

virtual BALL::PropertyManager::~PropertyManager | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## beginNamedProperty()

NamedPropertyIterator BALL::PropertyManager::beginNamedProperty | ( |  | ) |

Return an iterator to the first NamedProperty stored in this container.

## clear()

virtual void BALL::PropertyManager::clear | ( |  | ) |

virtual

Clears all properties.

Reimplemented in BALL::Atom, BALL::AtomContainer, BALL::Bond, BALL::NucleicAcid, BALL::Nucleotide, BALL::PDBAtom, BALL::PDBFile, BALL::Protein, BALL::Residue, BALL::SecondaryStructure, BALL::VIEW::AddBackboneModel, BALL::VIEW::AddBallAndStickModel, BALL::VIEW::AddSurfaceModel, BALL::VIEW::AtomBondModelBaseProcessor, BALL::VIEW::HBondModelProcessor, BALL::VIEW::ModelProcessor, and BALL::VIEW::Representation.

## clearProperty() [1/2]

void BALL::PropertyManager::clearProperty | ( | const std::string & | name | ) |

Remove a named property. If the named property name does exist, it is remove from the array of properties.

Parameters

  name | the name of the property to be removed

## clearProperty() [2/2]

void BALL::PropertyManager::clearProperty | ( | Property | property | ) |

Clear a property. This method clears an unnamed property of a PropertyManager object by calling BitVector::clearBit(property) for the private bit vector.

Parameters

  property | the number of the property to be cleared

## countNamedProperties()

Size BALL::PropertyManager::countNamedProperties | ( |  | ) | const

Return the number of named properties.

Returns
  Size the number of named properties stored in the ProprtyManager object

## countProperties()

Size BALL::PropertyManager::countProperties | ( |  | ) | const

Count all properties. This method returns the sum of unnamed and named properties. It counts the number of ones in the bit vector and the number of properties stored in the named property vector.

## destroy()

virtual void BALL::PropertyManager::destroy | ( |  | ) |

virtual

Clears all properties.

Reimplemented in BALL::Atom, BALL::AtomContainer, BALL::Bond, BALL::NucleicAcid, BALL::Nucleotide, BALL::PDBAtom, BALL::Protein, BALL::Residue, and BALL::SecondaryStructure.

## dump()

void BALL::PropertyManager::dump | ( | std::ostream & | s = std::cout,
|  | Size | depth = 0 ) const

Internal state dump. Dump the current internal state of {*this} to the output ostream s with dumping depth depth .

Parameters

  s | - output stream where to output the internal state of {*this}
  depth | - the dumping depth

## endNamedProperty()

NamedPropertyIterator BALL::PropertyManager::endNamedProperty | ( |  | ) |

Return an iterator past the last NamedProperty stored in this container.

## get()

void BALL::PropertyManager::get | ( | PropertyManager & | property_manager | ) | const

Assign properties to another property manager. This method copies the contents of the PropertyManager object to the given property_manager.

Parameters

  property_manager | the target object

## getBitVector() [1/2]

BitVector & BALL::PropertyManager::getBitVector | ( |  | ) |

Return a mutable reference to the bit vector. This method returns the bit vector containing the unnamed properties of the property manager.

Returns
  BitVector& a mutable reference to the (private) BitVector containing the unnamed properties

## getBitVector() [2/2]

const BitVector & BALL::PropertyManager::getBitVector | ( |  | ) | const

Return a const reference to the bit vector containing the unnamed properties. This method returns the bit vector containing the unnamed properties of the property manager.

Returns
  BitVector& a const reference to the (private) BitVector containing the unnamed properties

## getNamedProperty() [1/2]

NamedProperty & BALL::PropertyManager::getNamedProperty | ( | Position | index | ) |

Mutable access to a named property by its index.

Exceptions

  Exception::IndexOverflow |

## getNamedProperty() [2/2]

const NamedProperty & BALL::PropertyManager::getNamedProperty | ( | Position | index | ) | const

Non-mutable access to a named property by its index.

Exceptions

  Exception::IndexOverflow |

## getProperty()

const NamedProperty & BALL::PropertyManager::getProperty | ( | const std::string & | name | ) | const

Retrieve a named property. If the property manager contains a property named name this property is returned. An empty property is returned otherwise.

Parameters

  name | the name of the proeprty to be retrieved

## hasProperty() [1/2]

bool BALL::PropertyManager::hasProperty | ( | const std::string & | name | ) | const

Query for a named property.

## hasProperty() [2/2]

bool BALL::PropertyManager::hasProperty | ( | Property | property | ) | const

Query for an unnamed property.

## isValid()

bool BALL::PropertyManager::isValid | ( |  | ) | const

Test if instance is valid. Returns true if the bitvector is valid.

Returns
  bool true

## operator BitVector &()

BALL::PropertyManager::operator BitVector & | ( |  | ) |

Converter to BitVector. This operator converts a PropertyManager object to a BitVector object containing the unnamed properties.

Returns
  BitVector& a reference to the BitVector containing the unnamed properties of the property manager

## operator!=()

bool BALL::PropertyManager::operator!= | ( | const PropertyManager & | pm | ) | const

Inequality operator.

## operator=()

const PropertyManager & BALL::PropertyManager::operator= | ( | const PropertyManager & | property_manager | ) |

Assignment operator. This operator calls set(property_manager) to assign a new object.

Parameters

  property_manager | the PropertyManager object to copy from

Returns
  PropertyManager *this

## operator==()

bool BALL::PropertyManager::operator== | ( | const PropertyManager & | pm | ) | const

Equality operator Two instances are equal if they have the same named and unnamed properties.

## read()

bool BALL::PropertyManager::read | ( | PersistenceManager & | pm | ) |

Persistent stream reading.

## set()

void BALL::PropertyManager::set | ( | const PropertyManager & | property_manager | ) |

Assign properties from another property manager

Parameters

  property_manager | the PropertyManager object to copy from

## setProperty() [1/10]

void BALL::PropertyManager::setProperty | ( | const NamedProperty & | property | ) |

Set a named property. This method adds a new named property to the property manager's array of named properties or substitutes an already existing named property by property. If a property with the same name as property already exists, it is destructed.

Parameters

  property | the new property to be set

## setProperty() [2/10]

void BALL::PropertyManager::setProperty | ( | const std::string & | name | ) |

Set a named property without any data. This method creates a new named property not containing any data (NamedProperty::Type == NONE). Already existing data using the same name is overwritten.

Parameters

  name | the name to be used for the new property

## setProperty() [3/10]

void BALL::PropertyManager::setProperty | ( | const std::string & | name,
|  | bool | value )

Set a named property containing boolean data. This method creates a new named property containing boolean data (NamedProperty::Type == BOOL). Already existing data using the same name is overwritten.

Parameters

  name | the name to be used for the new property
  value | the boolean value

## setProperty() [4/10]

void BALL::PropertyManager::setProperty | ( | const std::string & | name,
|  | const PersistentObject & | value )

Set a named property containing a PersistentObject. This method creates a new named property containing a string (NamedProperty::Type == OBJECT). Already existing data using the same name is overwritten.

Parameters

  name | the name to be used for the new property
  value | the data

## setProperty() [5/10]

void BALL::PropertyManager::setProperty | ( | const std::string & | name,
|  | const std::string & | value )

Set a named property containing a string. This method creates a new named property containing a string (NamedProperty::Type == STRING). Already existing data using the same name is overwritten.

Parameters

  name | the name to be used for the new property
  value | the data

## setProperty() [6/10]

void BALL::PropertyManager::setProperty | ( | const std::string & | name,
|  | double | value )

Set a named property containing a double-precision floating point number. This method creates a new named property containing a floating point number (NamedProperty::Type == DOUBLE). Already existing data using the same name is overwritten.

Parameters

  name | the name to be used for the new property
  value | the data

## setProperty() [7/10]

void BALL::PropertyManager::setProperty | ( | const std::string & | name,
|  | float | value )

Set a named property containing a floating point number. This method creates a new named property containing a floating point number (NamedProperty::Type == FLOAT). Already existing data using the same name is overwritten.

Parameters

  name | the name to be used for the new property
  value | the data

## setProperty() [8/10]

void BALL::PropertyManager::setProperty | ( | const std::string & | name,
|  | int | value )

Set a named property containing a signed integer number. This method creates a new named property containing an int (NamedProperty::Type == INT). Already existing data using the same name is overwritten.

Parameters

  name | the name to be used for the new property
  value | the data

## setProperty() [9/10]

void BALL::PropertyManager::setProperty | ( | const std::string & | name,
|  | unsigned int | value )

Set a named property containing an unsigned integer number. This method creates a new named property containing an unsigned int (NamedProperty::Type == UNSIGNED_INT). Already existing data using the same name is overwritten.

Parameters

  name | the name to be used for the new property
  value | the data

## setProperty() [10/10]

void BALL::PropertyManager::setProperty | ( | Property | property | ) |

Set a property. This method sets an unnamed property of a PropertyManager object by calling BitVector::setBit(property) for the private bit vector.

Parameters

  property | the number of the property to be set

## swap()

void BALL::PropertyManager::swap | ( | PropertyManager & | property_manager | ) |

Swap the properties with another property manager.

Parameters

  property_manager | the PropertyManager object to swap the properties with

## toggleProperty()

void BALL::PropertyManager::toggleProperty | ( | Property | property | ) |

Toggle (invert) a property. This method clears an unnamed property of a PropertyManager object by calling BitVector::toggleBit(property) for the private bit vector.

Parameters

  property | the number of the property to be toggled

## write()

void BALL::PropertyManager::write | ( | PersistenceManager & | pm | ) | const

Persistent stream writing.