HOPS
HOPS class reference
Public Member Functions | Protected Attributes | List of all members
hops::MHO_ExtensibleElement Class Reference

Class MHO_ExtensibleElement. More...

#include <MHO_ExtensibleElement.hh>

Inheritance diagram for hops::MHO_ExtensibleElement:
[legend]

Public Member Functions

 MHO_ExtensibleElement ()
 
virtual ~MHO_ExtensibleElement ()
 
void Accept (MHO_Visitor *aVisitor) override
 Visits all extensions of MHO_ExtensibleElement using given visitor. More...
 
template<class XExtensionType >
MHO_ExtendedElement< XExtensionType > * AsExtension ()
 Returns an extension of type XExtensionType if found in the list of extensions. More...
 
template<class XExtensionType >
bool HasExtension () const
 Checks if an extensible element has a specific extension type. More...
 
template<class XExtensionType >
MHO_ExtendedElement< XExtensionType > * MakeExtension ()
 Creates and adds a new extension of type XExtensionType to the list of extensions. More...
 
- Public Member Functions inherited from hops::MHO_Element
 MHO_Element ()
 
virtual ~MHO_Element ()
 

Protected Attributes

std::vector< MHO_Element * > fExtensions
 

Detailed Description

Class MHO_ExtensibleElement.

Implements an interface by which a class that inherits from MHO_ExtensibleElement can have arbitrarily extended functionality added to it without modifying the original class Pointers to the extensions are stored internally, and access proceeds through the visitor pattern. This interface should be used VERY sparingly, as dynamic_casts are expensive and the number of dynamic_casts needed for a single call to the 'Accept' method scales like N*M (where N is the number of visitors, and M the number of extensions).

Author
J. Barrett - barre.nosp@m.ttj@.nosp@m.mit.e.nosp@m.du
Date
Wed Sep 15 13:18:04 2021 -0400

Constructor & Destructor Documentation

◆ MHO_ExtensibleElement()

hops::MHO_ExtensibleElement::MHO_ExtensibleElement ( )
inline

◆ ~MHO_ExtensibleElement()

virtual hops::MHO_ExtensibleElement::~MHO_ExtensibleElement ( )
inlinevirtual

Member Function Documentation

◆ Accept()

void hops::MHO_ExtensibleElement::Accept ( MHO_Visitor aVisitor)
inlineoverridevirtual

Visits all extensions of MHO_ExtensibleElement using given visitor.

Parameters
aVisitorMHO_Visitor to traverse and operate on extensions

Implements hops::MHO_Element.

◆ AsExtension()

template<class XExtensionType >
MHO_ExtendedElement< XExtensionType > * hops::MHO_ExtensibleElement::AsExtension
inline

Returns an extension of type XExtensionType if found in the list of extensions.

Returns a dynamically casted extension of type XExtensionType if found among stored extensions.

Template Parameters
XExtensionTypeTemplate parameter XExtensionType
Returns
Pointer to MHO_ExtendedElement<XExtensionType or nullptr if not found
Pointer to MHO_ExtendedElement<XExtensionType or nullptr if not found

◆ HasExtension()

template<class XExtensionType >
bool hops::MHO_ExtensibleElement::HasExtension
inline

Checks if an extensible element has a specific extension type.

Returns
True if the element has the specified extension type, false otherwise.
True if extension exists, false otherwise.

◆ MakeExtension()

template<class XExtensionType >
MHO_ExtendedElement< XExtensionType > * hops::MHO_ExtensibleElement::MakeExtension
inline

Creates and adds a new extension of type XExtensionType to the list of extensions.

Creates and adds a new extension of type XExtensionType to the extensible element.

Template Parameters
XExtensionTypeTemplate parameter XExtensionType
Returns
Pointer to the newly created MHO_ExtendedElement<XExtensionType
Pointer to the newly created MHO_ExtendedElement<XExtensionType

Member Data Documentation

◆ fExtensions

std::vector< MHO_Element* > hops::MHO_ExtensibleElement::fExtensions
protected

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