Difference between revisions of "Development/Cpp/Helper/OPropertyContainerHelper"

From Apache OpenOffice Wiki
< Development‎ | Cpp‎ | Helper
Jump to: navigation, search
m (Interface)
Line 1: Line 1:
{{CppHelper/Heading|PropertyContainerHelper|is a helper class for managing property values, and implementing most of the property set related interfaces|<code>comphelper/propertycontainerhelper.hxx</code>}}
+
{{CppHelper/Heading|PropertyContainerHelper|is a helper class for managing properties, each associated with a location of the property value, and implementing the property set related interfaces|<code>comphelper/propertycontainerhelper.hxx</code>}}
  
 
=== Description ===
 
=== Description ===

Revision as of 09:24, 29 November 2007

Class Name Purpose Location
PropertyContainerHelper is a helper class for managing properties, each associated with a location of the property value, and implementing the property set related interfaces comphelper/propertycontainerhelper.hxx


Description

A PropertyContainerHelper manages a set of properties and property values.

A property is described by all the attributes required by a css.beans.Property: Name, Handle, Type, and Attributes. A PropertyContainerHelper allows you to specify an arbitrary number of properties, and keeps track of them, later being able to hand out a structure describing them.

What makes the class powerful is that together with a property description the class also manages the location where the actual property value is stored. When you register a property, you also register the location (or let the PropertyContainerHelper find one) of the property value. From then on, every read access to the property will return the value stored in the location, and every write access will change the value in this location.

This is especially useful together with member variables: If your class implements the property set related interfaces, and you also want a quick, typed access to the actual property values, you can declare a class member, and register this member as location of a property's value. Then, read and write access to the member is equivalent to read and write access to the property value, using PropertyContainerHelper's methods.

Interface

For a complete interface description, you're referred to the file, please browse propertycontainer.hxx's source code online, or check out the file (it's located in comphelper/inc/comphelper).

Here, only some of the interface methods are mentioned:

  • registerProperty: The main method for registering a property, together with a (typed) value location.
  • registerMayBeVoidProperty: registers a property which can be void, thus represented by an css.uno.Any.
  • registerPropertyNoMember: registers a property without actual location. The PropertyContainerHelper will allocate space for this property's value in an internal repository.
  • convertFastPropertyValue, setFastPropertyValue, getFastPropertyValue: central entry point for setting and getting property values. Those methods have the same signature and semantics as the respective methods at the OPropertySetHelper class from module cppuhelper.
  • describeProperties: fills a sequence of Propertys with the description of the actual properties of the instance. Useful to implement the XPropertySetInfo interface.

Example

TODO: There's more to come here ...

Personal tools