DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
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 AssociateObject< Host >:
Inheritance graph
[legend]
Collaboration diagram for AssociateObject< Host >:
Collaboration graph
[legend]

Public Member Functions

 AssociateObject (const Host &host)
 Constructor.
 
 ~AssociateObject ()
 Destructor.
 
ObjectType getObjectType () const final
 Object type for DUECA's sanity.
 

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.
 

Detailed Description

template<class Host>
class 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>
{
ChannelReadToken token;
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

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 >
AssociateObject< Host >::AssociateObject ( const Host & host)
inline

Constructor.

Parameters
hostHost class for name and ID.

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