OGRE 14.3
Object-Oriented Graphics Rendering Engine
Loading...
Searching...
No Matches

Associate values of arbitrary type with names. More...

Classes

class  Ogre::Property< T >
 Property instance with passthrough calls to a given object. More...
 
class  Ogre::PropertyBase
 Base interface for an instance of a property. More...
 
class  Ogre::PropertyDef
 Definition of a property of an object. More...
 
class  Ogre::PropertySet
 Defines a complete set of properties for a single object instance. More...
 
struct  Ogre::PropertyValue
 A simple structure designed just as a holder of property values between the instances of objects they might target. More...
 

Typedefs

typedef GeneralAllocatedObject Ogre::PropertyAlloc
 
typedef std::map< String, PropertyDefOgre::PropertyDefMap
 Map from property name to shared definition.
 
typedef std::map< String, PropertyValueOgre::PropertyValueMap
 Defines a transferable map of properties using wrapped value types (Ogre::Any)
 

Enumerations

enum  Ogre::PropertyType {
  Ogre::PROP_SHORT = 0 , Ogre::PROP_UNSIGNED_SHORT = 1 , Ogre::PROP_INT = 2 , Ogre::PROP_UNSIGNED_INT = 3 ,
  Ogre::PROP_LONG = 4 , Ogre::PROP_UNSIGNED_LONG = 5 , Ogre::PROP_REAL = 6 , Ogre::PROP_STRING = 7 ,
  Ogre::PROP_VECTOR2 = 8 , Ogre::PROP_VECTOR3 = 9 , Ogre::PROP_VECTOR4 = 10 , Ogre::PROP_COLOUR = 11 ,
  Ogre::PROP_BOOL = 12 , Ogre::PROP_QUATERNION = 13 , Ogre::PROP_MATRIX3 = 14 , Ogre::PROP_MATRIX4 = 15 ,
  Ogre::PROP_UNKNOWN = 999
}
 The type of a property. More...
 

Detailed Description

Associate values of arbitrary type with names.

OGRE's property system allows you to associate values of arbitrary type with names, and have those values exposed via a self-describing interface. Unlike Ogre::StringInterface, the values are passed as their native types without needing conversion to or from strings; they are simply wrapped in an Ogre::Any and casts are performed to access them.

Property values are actually not stored in this system; instead the property definitions reference getter & setter methods which provide the 'backing' for the property. This means you can directly expose features of your classes as properties without any duplication.

There are two aspects to exposing a property on your class. One is exposing the definition of the property (PropertyDef), which should be shared between all instances and probably stored in a static PropertyDefMap somewhere. The second is the instance 'wiring' which ensures that a call to set a property calls a method on this particular instance of the class; this is formed by a number of Property instances, contained in a PropertySet. Each Property has an explicit binding to getter and setter instance methods.

So, here's an example of setting up properties on an instance:

// Make sure the property definition is created
// propertyDefs is a variable of type PropertyDefMap, shared between instances
PropertyDefMap::iterator defi = propertyDefs.find("name");
if (defi == propertyDefs.end())
{
defi = propertyDefs.emplace("name",
PropertyDef("name",
"The name of the object.", PROP_STRING)).first;
}
// This has established the property definition, and its description.
// Now, we need to 'wire' a property instance for this object instance
// We assume the class is called 'Foo' and the instance is pointed to by a variable called 'inst'
// 'props' is a PropertySet, specific to the instance
props.addProperty(
OGRE_NEW Property<String>(&(defi->second),
std::bind(&Foo::getName, inst),
std::bind(&Foo::setName, inst, _1)));
@ PROP_STRING
Definition OgreProperty.h:113

Typedef Documentation

◆ PropertyAlloc

typedef GeneralAllocatedObject Ogre::PropertyAlloc

◆ PropertyDefMap

Map from property name to shared definition.

◆ PropertyValueMap

Defines a transferable map of properties using wrapped value types (Ogre::Any)

Enumeration Type Documentation

◆ PropertyType

The type of a property.

Enumerator
PROP_SHORT 
PROP_UNSIGNED_SHORT 
PROP_INT 
PROP_UNSIGNED_INT 
PROP_LONG 
PROP_UNSIGNED_LONG 
PROP_REAL 
PROP_STRING 
PROP_VECTOR2 
PROP_VECTOR3 
PROP_VECTOR4 
PROP_COLOUR 
PROP_BOOL 
PROP_QUATERNION 
PROP_MATRIX3 
PROP_MATRIX4 
PROP_UNKNOWN