b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2000::ObjectType Class Reference

#include "b2object.H"

Inheritance diagram for b2000::ObjectType:

Public Member Functions

const std::string get_name () const
 
bool normalize_name (std::string &identifier) const
 
virtual Objectnew_object ()
 
virtual Objectnew_object (Allocator &allocator)
 
virtual bool is_type (const Object *o)
 
virtual bool is_subtype (const Object *o)
 
virtual ObjectTypeget_subtype (const std::string &name_, Module &module_=b2000_module)
 

Detailed Description

ObjectType instances are factory objects: They are used to create instances of sub-classes of Object. Implementors should not use ObjectType directly but instead use either ObjectTypeIncomplete or ObjectTypeComplete.

Member Function Documentation

◆ get_name()

const std::string b2000::ObjectType::get_name ( ) const
inline
Returns
The name under which the object type is registered.

◆ get_subtype()

virtual ObjectType * b2000::ObjectType::get_subtype ( const std::string &  name_,
Module &  module_ = b2000_module 
)
inlinevirtual

Get a subtype of this object type.

Parameters
name_The name under which the subtype was registered.
module_The module to search.
Returns
A pointer to the subtype instance. It can be used to construct instances of the sub-class by means of the new_object() method.

If the subtype is not found in the module, an attempt to load the sub-module module_.name() + "." + name is made. If the sub-module cannot be loaded, KeyError is thrown.

Reimplemented in b2000::ObjectTypeIncomplete< OBJECT, BASE_OBJECT_TYPE >, and b2000::ObjectTypeComplete< OBJECT, BASE_OBJECT_TYPE >.

◆ is_subtype()

virtual bool b2000::ObjectType::is_subtype ( const Object o)
inlinevirtual
Returns
Whether the type of an instance is a subtype of this object type.

Reimplemented in b2000::ObjectTypeIncomplete< OBJECT, BASE_OBJECT_TYPE >, and b2000::ObjectTypeComplete< OBJECT, BASE_OBJECT_TYPE >.

◆ is_type()

virtual bool b2000::ObjectType::is_type ( const Object o)
inlinevirtual
Returns
Whether an instance is of this object type.

Reimplemented in b2000::ObjectTypeIncomplete< OBJECT, BASE_OBJECT_TYPE >, and b2000::ObjectTypeComplete< OBJECT, BASE_OBJECT_TYPE >.

◆ new_object() [1/2]

virtual Object * b2000::ObjectType::new_object ( )
inlinevirtual

Create an instance of the Object sub-class that is associated with this object type.

Returns
The new instance.

Reimplemented in b2000::ObjectTypeIncomplete< OBJECT, BASE_OBJECT_TYPE >, and b2000::ObjectTypeComplete< OBJECT, BASE_OBJECT_TYPE >.

◆ new_object() [2/2]

virtual Object * b2000::ObjectType::new_object ( Allocator allocator)
inlinevirtual

Create an instance of the Object sub-class that is associated with this object type.

Parameters
allocatorA memory allocator object.
Returns
The new instance.

Reimplemented in b2000::ObjectTypeIncomplete< OBJECT, BASE_OBJECT_TYPE >, and b2000::ObjectTypeComplete< OBJECT, BASE_OBJECT_TYPE >.

◆ normalize_name()

bool b2000::ObjectType::normalize_name ( std::string &  identifier) const
inline

Normalize the given identifier, if it matches the original name or any alias of the object, without suffix. The argument is not changed, if there is no match. The function returns whether the identifier matches the object name or not.


The documentation for this class was generated from the following file: