ALBA
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
albaAgent Class Reference

#include <albaAgent.h>

Inheritance diagram for albaAgent:
Inheritance graph
[legend]
Collaboration diagram for albaAgent:
Collaboration graph
[legend]

Public Member Functions

 albaAbstractTypeMacro (albaAgent, albaReferenceCounted)
 
 ALBA_ID_DEC (AGENT_INITIALIZE)
 
void AddObserver (albaObserver *listener, albaID channel=MCH_UP)
 
void RemoveObserver (albaObserver *listener)
 
void RemoveAllObservers ()
 
virtual void OnEvent (albaEventBase *event)
 
bool HasObservers (albaID channel)
 
void GetObservers (albaID channel, std::vector< albaObserver * > &olist)
 
int Initialize ()
 
void Shutdown ()
 
int IsInitialized ()
 
virtual void SetName (const char *name)
 
const char * GetName ()
 
- Public Member Functions inherited from albaReferenceCounted
 albaReferenceCounted ()
 
virtual ~albaReferenceCounted ()
 
 albaAbstractTypeMacro (albaReferenceCounted, albaObject)
 
virtual void Delete ()
 
void Register (void *obj)
 
virtual void UnRegister (void *obj)
 
int GetReferenceCount ()
 
void SetReferenceCount (int)
 
- Public Member Functions inherited from albaObject
 albaObject ()
 
virtual ~albaObject ()
 
virtual void Delete ()
 
virtual const char * GetTypeName () const
 
virtual bool IsA (const char *type_name) const
 
virtual bool IsA (const albaTypeID &type_id) const
 
virtual albaObjectNewObjectInstance () const =0
 
virtual const albaTypeIDGetTypeId () const
 
virtual void Print (std::ostream &os, const int indent=0) const
 
 albaObject (const albaObject &c)
 
- Public Member Functions inherited from albaObserver
 albaObserver ()
 
virtual ~albaObserver ()
 
virtual void OnEvent (albaEventBase *e)=0
 
- Public Member Functions inherited from albaEventBroadcaster
 albaEventBroadcaster (void *owner=NULL)
 
virtual ~albaEventBroadcaster ()
 
 albaEventBroadcaster (const albaEventBroadcaster &c)
 
void AddObserver (albaObserver *obj)
 
void AddObserver (albaObserver &obj)
 
albaObserverCallbackAddObserverCallback (void(*f)(void *sender, albaID eid, void *clientdata, void *calldata))
 
bool RemoveObserver (albaObserver *obj)
 
void RemoveAllObservers ()
 
bool IsObserver (albaObserver *obj)
 
bool HasObservers ()
 
void GetObservers (std::vector< albaObserver * > &olist)
 
void InvokeEvent (albaEventBase &e)
 
void InvokeEvent (albaEventBase *e)
 
void InvokeEvent (void *sender, albaID id=ID_NO_EVENT, void *data=NULL)
 
void SetChannel (albaID ch)
 
albaID GetChannel ()
 
virtual void SetListener (albaObserver *o)
 
- Public Member Functions inherited from albaEventSender
 albaEventSender ()
 
virtual void SetListener (albaObserver *o)
 
virtual albaObserverGetListener ()
 
virtual bool HasListener ()
 
virtual void InvokeEvent (albaEventBase &e)
 
virtual void InvokeEvent (albaEventBase *e)
 
virtual void InvokeEvent (void *sender, albaID id=ID_NO_EVENT, void *data=NULL)
 

Protected Member Functions

 albaAgent ()
 
virtual ~albaAgent ()
 
virtual int InternalInitialize ()
 
virtual void InternalShutdown ()
 
void InvokeEvent (albaEventBase &event, albaID channel=-1)
 
void InvokeEvent (albaEventBase *event, albaID channel=-1)
 
void InvokeEvent (void *sender, int id, albaID channel=MCH_UP, void *data=NULL)
 

Protected Attributes

albaString m_Name
 
bool m_Initialized
 
std::vector< albaEventBroadcaster * > m_Channels
 
- Protected Attributes inherited from albaReferenceCounted
int m_ReferenceCount
 
- Protected Attributes inherited from albaObject
bool m_HeapFlag
 
- Protected Attributes inherited from albaEventBroadcaster
albaObserversList m_Observers
 
albaID m_Channel
 
- Protected Attributes inherited from albaEventSender
albaObserverm_Listener
 

Additional Inherited Members

- Static Public Member Functions inherited from albaObject
static const char * GetStaticTypeName ()
 
static bool IsStaticType (const char *type_name)
 
static bool IsStaticType (const albaTypeID &type_id)
 
static const albaTypeIDGetStaticTypeId ()
 
static albaObjectSafeDownCast (albaObject *o)
 
- Protected Types inherited from albaEventBroadcaster
typedef std::list< albaObserver * > albaObserversList
 

Detailed Description

An agent is a computational object with a default I/O interface.

An agent is a computational object with a conventional events I/O interface, processing its input events, taking some action and producing output events toward other agents. An agent is a albaObserver, thus an object able to listen to ALBA events coming from other objects and extends the idea of channels keeping an internal dynamic array of channels: this was an agent can be attached as observer of events on any channel of other events, allowing the creation of a network of agents. This class support also bridging of events coming from VTK: a albaAgent can be set as observer of VTK events which are tunneled inside ALBA events.

See also
albaEventBase albaAgent albaAgentEventQueue albaAgentThreaded

Definition at line 49 of file albaAgent.h.

Constructor & Destructor Documentation

◆ albaAgent()

albaAgent::albaAgent ( )
protected

◆ ~albaAgent()

virtual albaAgent::~albaAgent ( )
protectedvirtual

Member Function Documentation

◆ albaAbstractTypeMacro()

albaAgent::albaAbstractTypeMacro ( albaAgent  ,
albaReferenceCounted   
)

◆ AddObserver()

void albaAgent::AddObserver ( albaObserver listener,
albaID  channel = MCH_UP 
)

Attach/Detach this object as event source for the specified listener.

If the specified channel is the MCH_UP, the SetListener(listener) is called. For all other channel more then one listener can be specified, and a broad cast using the VTK Subject/Observer is performed. UnPlugListener works for all channels at the same time. NULL listeners are ignored.

◆ RemoveObserver()

void albaAgent::RemoveObserver ( albaObserver listener)

◆ RemoveAllObservers()

void albaAgent::RemoveAllObservers ( )

◆ OnEvent()

virtual void albaAgent::OnEvent ( albaEventBase event)
virtual

◆ HasObservers()

bool albaAgent::HasObservers ( albaID  channel)

return true if there's an observer on the specified channel.

(noarg == MCH_UP)

◆ GetObservers()

void albaAgent::GetObservers ( albaID  channel,
std::vector< albaObserver * > &  olist 
)

return a list of the observers on a channel

◆ Initialize()

int albaAgent::Initialize ( )

Initialize this agent.

Subclasses can redefine InternalInitialize() to customize the initialization.

◆ Shutdown()

void albaAgent::Shutdown ( )

Shutdown the agent, Subclasses can redefine InternalShutdown() to customize actions for shutting down.

◆ IsInitialized()

int albaAgent::IsInitialized ( )
inline

Return true if this agent has been initialized.

Definition at line 95 of file albaAgent.h.

Referenced by albaAgentThreaded::Update().

◆ SetName()

virtual void albaAgent::SetName ( const char *  name)
inlinevirtual

The Agent name is used to identify the Agent in a unique way.

Reimplemented in albaDevice.

Definition at line 99 of file albaAgent.h.

◆ GetName()

const char * albaAgent::GetName ( )
inline

Definition at line 100 of file albaAgent.h.

◆ InternalInitialize()

virtual int albaAgent::InternalInitialize ( )
inlineprotectedvirtual

This function is overridden by subclasses to perform custom initialization.

Reimplemented in albaAgentThreaded, albaAvatar, albaAvatar3D, albaDevice, albaDeviceButtonsPadTracker, albaDeviceButtonsPadTrackerP5Glove, albaDeviceManager, albaDeviceSet, and albaDeviceTrackerWIIMote.

Definition at line 108 of file albaAgent.h.

◆ InternalShutdown()

virtual void albaAgent::InternalShutdown ( )
inlineprotectedvirtual

to be redefined by subclasses to define the shutdown actions

Reimplemented in albaAgentThreaded, albaAvatar, albaAvatar3D, albaDeviceButtonsPadTracker, albaDeviceButtonsPadTrackerP5Glove, albaDeviceManager, albaDeviceSet, and albaDeviceTrackerWIIMote.

Definition at line 111 of file albaAgent.h.

◆ InvokeEvent() [1/3]

void albaAgent::InvokeEvent ( albaEventBase event,
albaID  channel = -1 
)
protected

This function make an event to be passed to observers of this class for the specified channel.

In case of MCH_UP the message is passed to the object pointed by the "m_Listener" member variable, otherwise the event is broadcasted by means of the Subject/Observer on the specified channel.

◆ InvokeEvent() [2/3]

void albaAgent::InvokeEvent ( albaEventBase event,
albaID  channel = -1 
)
protected

◆ InvokeEvent() [3/3]

void albaAgent::InvokeEvent ( void *  sender,
int  id,
albaID  channel = MCH_UP,
void *  data = NULL 
)
protected

Member Data Documentation

◆ m_Name

albaString albaAgent::m_Name
protected

Definition at line 128 of file albaAgent.h.

◆ m_Initialized

bool albaAgent::m_Initialized
protected

Definition at line 129 of file albaAgent.h.

◆ m_Channels

std::vector<albaEventBroadcaster *> albaAgent::m_Channels
protected

Definition at line 131 of file albaAgent.h.


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