fawkes::LocalBlackBoard Class Reference

Local BlackBoard. More...

#include <blackboard/local.h>

Inheritance diagram for fawkes::LocalBlackBoard:

[legend]
List of all members.

Public Member Functions

 LocalBlackBoard (size_t memsize)
 Heap Memory Constructor.
 LocalBlackBoard (size_t memsize, const char *magic_token, bool master=true)
 Shared Memory Constructor.
virtual ~LocalBlackBoard ()
 Destructor.
virtual Interfaceopen_for_reading (const char *interface_type, const char *identifier)
 Open interface for reading.
virtual Interfaceopen_for_writing (const char *interface_type, const char *identifier)
 Open interface for writing.
virtual void close (Interface *interface)
 Close interface.
virtual InterfaceInfoListlist_all ()
 Get list of interfaces.
virtual bool is_alive () const throw ()
 Check if the BlackBoard is still alive.
virtual bool try_aliveness_restore () throw ()
 Try to restore the aliveness of the BlackBoard instance.
virtual std::list< Interface * > open_multiple_for_reading (const char *interface_type, const char *id_pattern="*")
 Open multiple interfaces for reading.
virtual void register_listener (BlackBoardInterfaceListener *listener, unsigned int flags)
 Register BB event listener.
virtual void unregister_listener (BlackBoardInterfaceListener *listener)
 Unregister BB interface listener.
virtual void register_observer (BlackBoardInterfaceObserver *observer, unsigned int flags)
 Register BB interface observer.
virtual void unregister_observer (BlackBoardInterfaceObserver *observer)
 Unregister BB interface observer.
virtual void start_nethandler (FawkesNetworkHub *hub)
 Start network handler.
const BlackBoardMemoryManagermemory_manager () const
 Get memory manager.

Static Public Member Functions

static void cleanup (const char *magic_token, bool use_lister=false)
 Cleanup orphaned BlackBoard segments.

Detailed Description

Local BlackBoard.

See also:
Interface

Message

Author:
Tim Niemueller

Definition at line 45 of file local.h.


Constructor & Destructor Documentation

fawkes::LocalBlackBoard::LocalBlackBoard ( size_t  memsize  ) 

Heap Memory Constructor.

Parameters:
memsize size of memory in bytes

Definition at line 75 of file local.cpp.

References fawkes::BlackBoardMessageManager::set_interface_manager().

fawkes::LocalBlackBoard::LocalBlackBoard ( size_t  memsize,
const char *  magic_token,
bool  master = true 
)

Shared Memory Constructor.

Parameters:
memsize size of memory in bytes
magic_token magic token used for shared memory segment
master true to operate in master mode, false otherwise

Definition at line 57 of file local.cpp.

References fawkes::BlackBoardMessageManager::set_interface_manager().

fawkes::LocalBlackBoard::~LocalBlackBoard (  )  [virtual]

Destructor.

Definition at line 90 of file local.cpp.

References fawkes::Thread::cancel(), and fawkes::Thread::join().


Member Function Documentation

void fawkes::LocalBlackBoard::cleanup ( const char *  magic_token,
bool  use_lister = false 
) [static]

Cleanup orphaned BlackBoard segments.

This erase orphaned shared memory segments that belonged to a BlackBoard.

Parameters:
magic_token magic token of shared memory segments
use_lister true to use a lister with console output

Definition at line 199 of file local.cpp.

References fawkes::SharedMemory::erase_orphaned().

void fawkes::LocalBlackBoard::close ( Interface interface  )  [virtual]

Close interface.

Parameters:
interface interface to close

Implements fawkes::BlackBoard.

Definition at line 138 of file local.cpp.

References fawkes::BlackBoardInterfaceManager::close().

bool fawkes::LocalBlackBoard::is_alive (  )  const throw () [virtual]

Check if the BlackBoard is still alive.

Returns:
true, if the BlackBoard is still alive and may be used, false otherwise.

Implements fawkes::BlackBoard.

Definition at line 152 of file local.cpp.

InterfaceInfoList * fawkes::LocalBlackBoard::list_all (  )  [virtual]

Get list of interfaces.

Returns:
list of interfaces

Implements fawkes::BlackBoard.

Definition at line 145 of file local.cpp.

References fawkes::BlackBoardInterfaceManager::list_all().

const BlackBoardMemoryManager * fawkes::LocalBlackBoard::memory_manager (  )  const

Get memory manager.

CAUTION: This is NOT meant to be used in your application. This returns a pointer to the used memory manager. The return type is declared const. Use this only for debugging purposes to output info about the BlackBoard memory.

Returns:
const pointer to memory manager

Definition at line 220 of file local.cpp.

Interface * fawkes::LocalBlackBoard::open_for_reading ( const char *  interface_type,
const char *  identifier 
) [virtual]

Open interface for reading.

This will create a new interface instance of the given type. The result can be casted to the appropriate type.

Parameters:
type type of the interface
identifier identifier of the interface
Returns:
new fully initialized interface instance of requested type
Exceptions:
OutOfMemoryException thrown if there is not enough free space for the requested interface.

Implements fawkes::BlackBoard.

Definition at line 105 of file local.cpp.

References fawkes::BlackBoardInterfaceManager::open_for_reading().

Interface * fawkes::LocalBlackBoard::open_for_writing ( const char *  interface_type,
const char *  identifier 
) [virtual]

Open interface for writing.

This will create a new interface instance of the given type. The result can be casted to the appropriate type. This will only succeed if there is not already a writer for the given interface type/id!

Parameters:
type type of the interface
identifier identifier of the interface
Returns:
new fully initialized interface instance of requested type
Exceptions:
OutOfMemoryException thrown if there is not enough free space for the requested interface.
BlackBoardWriterActiveException thrown if there is already a writing instance with the same type/id

Implements fawkes::BlackBoard.

Definition at line 116 of file local.cpp.

References fawkes::BlackBoardInterfaceManager::open_for_writing().

std::list< Interface * > fawkes::LocalBlackBoard::open_multiple_for_reading ( const char *  interface_type,
const char *  id_pattern = "*" 
) [virtual]

Open multiple interfaces for reading.

This will create interface instances for currently registered interfaces of the given type that match the given ID pattern. The result can be casted to the appropriate type.

Parameters:
type type of the interface
id_pattern pattern of interface IDs to open, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported.
Returns:
list of new fully initialized interface instances of requested type. You have to close all interfaces on your own when done with the list!

Implements fawkes::BlackBoard.

Definition at line 127 of file local.cpp.

References fawkes::BlackBoardInterfaceManager::open_multiple_for_reading().

void fawkes::LocalBlackBoard::register_listener ( BlackBoardInterfaceListener listener,
unsigned int  flags 
) [virtual]

Register BB event listener.

Parameters:
listener BlackBoard event listener to register
flags an or'ed combination of BBIL_FLAG_DATA, BBIL_FLAG_READER, BBIL_FLAG_WRITER and BBIL_FLAG_INTERFACE. Only for the given types the event listener is registered. BBIL_FLAG_ALL can be supplied to register for all events.

Implements fawkes::BlackBoard.

Definition at line 165 of file local.cpp.

References fawkes::BlackBoardNotifier::register_listener().

void fawkes::LocalBlackBoard::register_observer ( BlackBoardInterfaceObserver observer,
unsigned int  flags 
) [virtual]

Register BB interface observer.

Parameters:
observer BlackBoard interface observer to register
flags an or'ed combination of BBIO_FLAG_CREATED, BBIO_FLAG_DESTROYED

Implements fawkes::BlackBoard.

Definition at line 179 of file local.cpp.

References fawkes::BlackBoardNotifier::register_observer().

void fawkes::LocalBlackBoard::start_nethandler ( FawkesNetworkHub hub  )  [virtual]

Start network handler.

This will start the network handler thread and register it with the given hub.

Parameters:
hub hub to use and to register with

Definition at line 231 of file local.cpp.

References fawkes::Thread::start().

Referenced by FawkesMainThread::FawkesMainThread().

bool fawkes::LocalBlackBoard::try_aliveness_restore (  )  throw () [virtual]

Try to restore the aliveness of the BlackBoard instance.

Note that even though the aliveness of the BlackBoard is restored single interfaces may still be invalid. That can for instance happen if a remote connection is re-established and a writer has been created during the downtime and an own writer instance of that very interface cannot be restored.

Returns:
true if the aliveness could be restored and the BlackBoard is operational again, false otherwise.

Implements fawkes::BlackBoard.

Definition at line 159 of file local.cpp.

void fawkes::LocalBlackBoard::unregister_listener ( BlackBoardInterfaceListener listener  )  [virtual]

Unregister BB interface listener.

This will remove the given BlackBoard interface listener from any event that it was previously registered for.

Parameters:
listener BlackBoard event listener to remove

Implements fawkes::BlackBoard.

Definition at line 172 of file local.cpp.

References fawkes::BlackBoardNotifier::unregister_listener().

void fawkes::LocalBlackBoard::unregister_observer ( BlackBoardInterfaceObserver observer  )  [virtual]

Unregister BB interface observer.

This will remove the given BlackBoard event listener from any event that it was previously registered for.

Parameters:
observer BlackBoard event listener to remove

Implements fawkes::BlackBoard.

Definition at line 186 of file local.cpp.

References fawkes::BlackBoardNotifier::unregister_observer().


The documentation for this class was generated from the following files:
Generated on Tue Feb 22 13:31:37 2011 for Fawkes API by  doxygen 1.4.7