void

Description

ObjectExtensions can be used to dynamically extend objects inheriting from AttributeProvider with data and functionality at runtime. Internally, it is a unified interface for several different GenericAttributes. There are two types of extensions: 1. non polymorphic and 2. polymorphic.

class MyExtension{
        PROVIDES_TYPE_NAME_NV(MyExtension)
        int someValue;
    public:
        MyExtension(int _someValue) : someValue(_someValue){}
        int getValue()const {   return someValue;   }
}
...
MyObject * a = new MyObject; // MyObject---|>AttributeProvider
Util::addObjectExtension<MyExtension>(42);
...
Util::requireObjectExtension<MyExtension>(a)->getValue();

Functions

   
template< typename extension_t , typename object_t , typename… args >  
extension_t * addObjectExtension(object_t * obj, args &&… params)
template< typename extension_t , typename object_t , typename… args >  
extension_t * addObjectExtension(const StringIdentifier & extName, object_t * obj, args &&… params)
template< typename extension_t >  
extension_t * getObjectExtension(const Util::AttributeProvider * obj)
template< typename extension_t >  
extension_t * getObjectExtension(const StringIdentifier & extName, const Util::AttributeProvider * obj)
template< typename extension_t >  
extension_t * requireObjectExtension(const Util::AttributeProvider * obj)
template< typename extension_t >  
extension_t * requireObjectExtension(const StringIdentifier & extName, const Util::AttributeProvider * obj)
template< typename extension_t >  
bool hasObjectExtension(const Util::AttributeProvider * obj)
template< typename extension_t >  
bool hasObjectExtension(const StringIdentifier & extName, const Util::AttributeProvider * obj)
Returns true iff theobjecthas a extension of type extension_t namedextName.

Documentation

function
addObjectExtension

public
     
template< typename extension_t , typename object_t , typename… args >    
extension_t * addObjectExtension( object_t * obj,
  args &&… params
)    

Create and add an extension of type extension_t to the givenobject.

  • Additional parameters are passed to the extension’s constructor.

  • The extension’s name is inquired by calling extension_t::getObjectExtensionName() or extension_t::getClassId()

  • The created extension is returned.

Defined in Util/ObjectExtension.h:167


function
addObjectExtension

public
     
template< typename extension_t , typename object_t , typename… args >    
extension_t * addObjectExtension( const StringIdentifier & extName,
  object_t * obj,
  args &&… params
)    

Create and add an extension of type extension_t to the givenobjectnamedextName.

See also: addObjectExtension (obj, params…)

Defined in Util/ObjectExtension.h:175


function
getObjectExtension

public
     
template< typename extension_t >    
extension_t * getObjectExtension( const Util::AttributeProvider * obj )

If the givenobjecthas a extension of type extension_t, it is returned; nullptr otherwise.

  • The extension’s name is inquired by calling extension_t::getObjectExtensionName() or extension_t::getClassId()

Defined in Util/ObjectExtension.h:182


function
getObjectExtension

public
     
template< typename extension_t >    
extension_t * getObjectExtension( const StringIdentifier & extName,
  const Util::AttributeProvider * obj
)    

If the givenobjecthas a extension of type extension_t namedextName, it is returned; nullptr otherwise.

See also: getObjectExtension(obj)

Defined in Util/ObjectExtension.h:189


function
requireObjectExtension

public
     
template< typename extension_t >    
extension_t * requireObjectExtension( const Util::AttributeProvider * obj )

If the givenobjecthas a extension of type extension_t, it is returned; otherwise, an exception is thrown.

  • The extension’s name is inquired by calling extension_t::getObjectExtensionName() or extension_t::getClassId().

Defined in Util/ObjectExtension.h:196


function
requireObjectExtension

public
     
template< typename extension_t >    
extension_t * requireObjectExtension( const StringIdentifier & extName,
  const Util::AttributeProvider * obj
)    

If the givenobjecthas a extension of type extension_t namedextName, it is returned; otherwise, an exception is thrown.

  • The extension’s name is inquired by calling extension_t::getObjectExtensionName() or extension_t::getClassId().

Defined in Util/ObjectExtension.h:203


function
hasObjectExtension

public
     
template< typename extension_t >    
bool hasObjectExtension( const Util::AttributeProvider * obj )

Returns true iff theobjecthas a extension of type extension_t.

  • The extension’s name is inquired by calling extension_t::getObjectExtensionName() or extension_t::getClassId().

Defined in Util/ObjectExtension.h:212


function
hasObjectExtension

public
     
template< typename extension_t >    
bool hasObjectExtension( const StringIdentifier & extName,
  const Util::AttributeProvider * obj
)    

Returns true iff theobjecthas a extension of type extension_t namedextName.

Defined in Util/ObjectExtension.h:217