DUECA/DUSIME
Public Member Functions | Static Public Attributes | List of all members
dueca::AssociateObject< Host > Class Template Reference

Proxy identity for helper classes associated with an object derived from dueca::NamedObject. More...

#include <AssociateObject.hxx>

Inheritance diagram for dueca::AssociateObject< Host >:
Inheritance graph
[legend]
Collaboration diagram for dueca::AssociateObject< Host >:
Collaboration graph
[legend]

Public Member Functions

 AssociateObject (const Host &host)
 Constructor. More...
 
 ~AssociateObject ()
 Destructor.
 
ObjectType getObjectType () const final
 Object type for DUECA's sanity. More...
 
- Public Member Functions inherited from dueca::NamedObject
const std::string getEntity () const
 Returns the "entity" part of the name.
 
const std::string getClass () const
 Returns the "class" part of the name.
 
const std::string getPart () const
 Returns the sub-entity or "part" part of the name.
 
const NameSetgetNameSet () const
 This returns the complete name set.
 
const GlobalIdgetId () const
 This returns the id. More...
 
virtual ObjectType getObjectType () const =0
 This has to be re-implemented in a derived class, used to get an idea of what the derived class does. More...
 

Static Public Attributes

static const char *const classname
 Class name constant, should be equal to the host object's classname, used for reporting errors and warnings.
 

Additional Inherited Members

- Protected Member Functions inherited from dueca::NamedObject
 NamedObject (const GlobalId &id)
 Reserve for AssociateObject. More...
 
 NamedObject (const NameSet &ns)
 Normal constructor, protected, because it has no use to create a NamedObject by itself.
 
virtual ~NamedObject ()
 Destructor.
 

Detailed Description

template<class Host>
class dueca::AssociateObject< Host >

Proxy identity for helper classes associated with an object derived from dueca::NamedObject.

In DUECA, objects that can use DUECA services (accessing channels, creating and using activities) need to have a name and a GlobalId, commonly by deriving from NamedObject. In addition, the convenience macros for checking channels and the like normally use the dueca::getclassname<>() templated function to access the "classname" member defined in modules.

This template class enables helper classes/objects that don't have their own GlobalId to assume the GlobalId and name of their "owner", and sets the proper class name.

Use this to delegate capabilities in a manner like (note, incomplete code!):

MyModule: public Module
{
// defining a helper reading a channel
struct MyHelper: public AssociateObject<MyModule>
{
MyHelper(const MyModule& m);
};
// e.g. a list of helpers
typedef std::list<MyHelper> helperlist_t;
};
Proxy identity for helper classes associated with an object derived from dueca::NamedObject.
Definition: AssociateObject.hxx:67
Access token used to read data from a UnifiedChannel.
Definition: ChannelReadToken.hxx:204
Base class for user-created self contained objects in DUECA.
Definition: Module.hxx:80

In your c++ file, ensure that the helpers have the proper "classname":

template<>
MyModule::classname;

The MyHelper struct will now be able to open channels, create activities, etc. Its name and id are equal to that of the host class.

Constructor & Destructor Documentation

◆ AssociateObject()

template<class Host >
dueca::AssociateObject< Host >::AssociateObject ( const Host &  host)
inline

Constructor.

Parameters
hostHost class for name and ID.

Member Function Documentation

◆ getObjectType()

template<class Host >
ObjectType dueca::AssociateObject< Host >::getObjectType ( ) const
inlinefinalvirtual

Object type for DUECA's sanity.

Implements dueca::NamedObject.


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