mrfioc2  2.3.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
mrf::ObjectInst< C, Base > Class Template Reference

User implementation hook. More...

#include <object.h>

Inheritance diagram for mrf::ObjectInst< C, Base >:
Inheritance graph
[legend]
Collaboration diagram for mrf::ObjectInst< C, Base >:
Collaboration graph
[legend]

Public Member Functions

virtual propertyBasegetPropertyBase (const char *pname, const std::type_info &ptype)
 
virtual void visitProperties (bool(*cb)(propertyBase *, void *), void *arg)
 

Static Public Member Functions

static int initObject ()
 

Protected Member Functions

 ObjectInst (const std::string &n)
 
template<typename A >
 ObjectInst (const std::string &n, A &a)
 
virtual ~ObjectInst ()
 

Detailed Description

template<class C, typename Base = Object>
class mrf::ObjectInst< C, Base >

User implementation hook.

Used to implement properties in a user class.

class mycls : public ObjectInst<mycls> {
...
int getint() const;
void setint(int);
};

Each user class must define an Object table. This should be done once, usually with its method definitions.

...
void mycls::setint(int) {...}
...
OBJECT_BEGIN(mycls)
OBJECT_PROP("propname", &mycls::getint, &mycls::setint)
...
OBJECT_END(mycls)

Definition at line 459 of file object.h.

Constructor & Destructor Documentation

◆ ObjectInst() [1/2]

template<class C, typename Base = Object>
mrf::ObjectInst< C, Base >::ObjectInst ( const std::string &  n)
inlineexplicitprotected

Definition at line 466 of file object.h.

466 : Base(n) {}

◆ ObjectInst() [2/2]

template<class C, typename Base = Object>
template<typename A >
mrf::ObjectInst< C, Base >::ObjectInst ( const std::string &  n,
A &  a 
)
inlineprotected

Definition at line 468 of file object.h.

468 : Base(n, a) {}

◆ ~ObjectInst()

template<class C, typename Base = Object>
virtual mrf::ObjectInst< C, Base >::~ObjectInst ( )
inlineprotectedvirtual

Member Function Documentation

◆ getPropertyBase()

template<class C, typename Base = Object>
virtual propertyBase* mrf::ObjectInst< C, Base >::getPropertyBase ( const char *  pname,
const std::type_info &  ptype 
)
inlinevirtual

Reimplemented in mrf::ObjectInst< MRMPreScaler, PreScaler >, mrf::ObjectInst< MRMPulser, Pulser >, mrf::ObjectInst< MRMOutput, Output >, and mrf::ObjectInst< EVRMRM, EVR >.

Definition at line 472 of file object.h.

473  {
474  std::string emsg;
475  if(!m_props)
476  throw std::runtime_error(emsg);
477  typename m_props_t::const_iterator it=m_props->lower_bound(pname),
478  end=m_props->upper_bound(pname);
479  for(;it!=end;++it) {
480  if(it->second->type()==ptype)
481  return it->second->bind(static_cast<C*>(this));
482  }
483  // continue checking for Base class properties
484  return Base::getPropertyBase(pname, ptype);
485  }

◆ initObject()

template<class C, typename Base = Object>
static int mrf::ObjectInst< C, Base >::initObject ( )
static

◆ visitProperties()

template<class C, typename Base = Object>
virtual void mrf::ObjectInst< C, Base >::visitProperties ( bool(*)(propertyBase *, void *)  cb,
void *  arg 
)
inlinevirtual

Reimplemented in mrf::ObjectInst< MRMPreScaler, PreScaler >, mrf::ObjectInst< MRMPulser, Pulser >, mrf::ObjectInst< MRMOutput, Output >, and mrf::ObjectInst< EVRMRM, EVR >.

Definition at line 487 of file object.h.

488  {
489  std::string emsg;
490  if(!m_props)
491  throw std::runtime_error(emsg);
492 
493  mrf::auto_ptr<propertyBase> cur;
494  for(typename m_props_t::const_iterator it=m_props->begin();
495  it!=m_props->end(); ++it)
496  {
497  cur.reset(it->second->bind(static_cast<C*>(this)));
498  if(!cur.get())
499  continue;
500  if(!(*cb)(cur.get(), arg))
501  break;
502  }
503  Base::visitProperties(cb, arg);
504  }

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