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

From Apache OpenOffice Wiki
< Development‎ | Cpp‎ | Helper
Jump to: navigation, search
Line 21: Line 21:
 
* {{CppMethod|convertFastPropertyValue}}, {{CppMethod|setFastPropertyValue}}, {{CppMethod|getFastPropertyValue}}: central entry point for setting and getting property values. Those methods have the same signature and semantics as the respective methods at the <code>OPropertySetHelper</code> class from module <code>cppuhelper</code>.
 
* {{CppMethod|convertFastPropertyValue}}, {{CppMethod|setFastPropertyValue}}, {{CppMethod|getFastPropertyValue}}: central entry point for setting and getting property values. Those methods have the same signature and semantics as the respective methods at the <code>OPropertySetHelper</code> class from module <code>cppuhelper</code>.
 
* {{CppMethod|describeProperties}}: fills a sequence of <code>Property</code>s with the description of the actual properties of the instance. Useful to implement the <code>XPropertySetInfo</code> interface.
 
* {{CppMethod|describeProperties}}: fills a sequence of <code>Property</code>s with the description of the actual properties of the instance. Useful to implement the <code>XPropertySetInfo</code> interface.
 +
 +
Note that the class is intended to be derived from. This is part of the it's patina [[Image:smiley.gif]] (the roots of the class as {{CppClass|OPropertyContainer}} lie in the year 2000) - nowadays, you would probably make its interface public instead of protected, so you can aggregate an instance of it.
  
 
=== Example ===
 
=== Example ===

Revision as of 09:42, 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.

Note that the class is intended to be derived from. This is part of the it's patina Smiley.gif (the roots of the class as OPropertyContainer lie in the year 2000) - nowadays, you would probably make its interface public instead of protected, so you can aggregate an instance of it.

Example

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

Personal tools