Fawkes API  Fawkes Development Version
fawkes::LocalBlackBoard Class Reference

Local BlackBoard. More...

#include <>>

Inheritance diagram for fawkes::LocalBlackBoard:

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 all currently existing interfaces.
virtual InterfaceInfoListlist (const char *type_pattern, const char *id_pattern)
 Get list of interfaces matching type and ID patterns.
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 *type_pattern, const char *id_pattern="*")
 Open multiple interfaces for reading.
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

Constructor & Destructor Documentation

fawkes::LocalBlackBoard::LocalBlackBoard ( size_t  memsize)

Heap Memory Constructor.

Parameters:
memsizesize of memory in bytes

Definition at line 74 of file local.cpp.

References fawkes::BlackBoard::__notifier.

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

Shared Memory Constructor.

Parameters:
memsizesize of memory in bytes
magic_tokenmagic token used for shared memory segment
mastertrue to operate in master mode, false otherwise

Definition at line 57 of file local.cpp.

References fawkes::BlackBoard::__notifier.

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

Destructor.

Definition at line 88 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_tokenmagic token of shared memory segments
use_listertrue to use a lister with console output

Definition at line 177 of file local.cpp.

References fawkes::SharedMemory::erase_orphaned().

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

Close interface.

Parameters:
interfaceinterface to close

Implements fawkes::BlackBoard.

Definition at line 136 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 157 of file local.cpp.

InterfaceInfoList * fawkes::LocalBlackBoard::list ( const char *  type_pattern,
const char *  id_pattern 
) [virtual]

Get list of interfaces matching type and ID patterns.

See the fnmatch() documentation for possible patterns.

Parameters:
type_patternpattern with shell like globs (* for any number of characters, ? for exactly one character) to match the interface type.
id_patternpattern with shell like globs (* for any number of characters, ? for exactly one character) to match the interface ID.
Returns:
list of interfaces

Implements fawkes::BlackBoard.

Definition at line 150 of file local.cpp.

References fawkes::BlackBoardInterfaceManager::list().

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

Get list of all currently existing interfaces.

Returns:
list of interfaces

Implements fawkes::BlackBoard.

Definition at line 143 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 198 of file local.cpp.

Interface * fawkes::LocalBlackBoard::open_for_reading ( const char *  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:
typetype of the interface
identifieridentifier of the interface
Returns:
new fully initialized interface instance of requested type
Exceptions:
OutOfMemoryExceptionthrown if there is not enough free space for the requested interface.

Implements fawkes::BlackBoard.

Definition at line 102 of file local.cpp.

References fawkes::BlackBoardInterfaceManager::open_for_reading().

Interface * fawkes::LocalBlackBoard::open_for_writing ( const char *  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:
typetype of the interface
identifieridentifier of the interface
Returns:
new fully initialized interface instance of requested type
Exceptions:
OutOfMemoryExceptionthrown if there is not enough free space for the requested interface.
BlackBoardWriterActiveExceptionthrown if there is already a writing instance with the same type/id

Implements fawkes::BlackBoard.

Definition at line 113 of file local.cpp.

References fawkes::BlackBoardInterfaceManager::open_for_writing().

std::list< Interface * > fawkes::LocalBlackBoard::open_multiple_for_reading ( const char *  type_pattern,
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_patternpattern of interface types to open, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported.
id_patternpattern 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 124 of file local.cpp.

References fawkes::BlackBoardInterfaceManager::open_multiple_for_reading().

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:
hubhub to use and to register with

Definition at line 209 of file local.cpp.

References fawkes::Thread::start().

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 164 of file local.cpp.


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