Orxonox  0.0.5 Codename: Arcturus
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
orxonox::OutputManager Class Reference

OutputManager acts as the center of the output system and is implemented as a singleton. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/util/output/OutputManager.h>

Inheritance diagram for orxonox::OutputManager:
orxonox::AdditionalContextListener

Classes

struct  Testing
 

Public Member Functions

 OutputManager ()
 Constructor, initializes all values. More...
 
virtual ~OutputManager ()
 Destructor. More...
 
bool acceptsOutput (OutputLevel level, const OutputContextContainer &context) const
 Returns true if at least one of the output listeners will accept output with the given level and context. More...
 
OutputLevel getCombinedAdditionalContextsLevelMask () const
 
OutputContextMask getCombinedAdditionalContextsMask () const
 
OutputLevel getCombinedLevelMask () const
 
ConsoleWritergetConsoleWriter ()
 
std::string getDefaultPrefix (OutputLevel level, const OutputContextContainer &context) const
 Returns a string containing the name of the level and the context (if any) which can be prepended to an output message if it is written to the console or the log file. More...
 
const std::string & getLevelName (OutputLevel level) const
 Returns a human readable string for each output level. More...
 
const std::vector< OutputListener * > & getListeners () const
 
LogWritergetLogWriter ()
 
MemoryWritergetMemoryWriter ()
 
virtual void pushMessage (OutputLevel level, const OutputContextContainer &context, const std::string &message)
 Sends an output message to all output listeners. More...
 
const OutputContextContainerregisterContext (const std::string &name, const std::string &subname="")
 Registers a context (or sub-context) and returns the container which identifies the context. More...
 
virtual void registerListener (OutputListener *listener)
 Adds an output listener to the list of listeners. More...
 
virtual void unregisterListener (OutputListener *listener)
 Removes an output listener from the list of listeners. More...
 
virtual void updatedAdditionalContextsLevelMask (const OutputListener *listener) override
 
virtual void updatedAdditionalContextsMask (const OutputListener *listener) override
 
virtual void updatedLevelMask (const OutputListener *listener) override
 
- Public Member Functions inherited from orxonox::AdditionalContextListener
virtual ~AdditionalContextListener ()
 

Static Public Member Functions

static OutputManagergetInstance ()
 Returns the only existing instance of the OutputManager singleton. More...
 
static OutputManagergetInstanceAndCreateListeners ()
 Returns the only existing instance of the OutputManager singleton and ensures that the most important output listeners exist. More...
 

Private Member Functions

 OutputManager (const OutputManager &)=delete
 
OutputManageroperator= (const OutputManager &)=delete
 
void updateCombinedAdditionalContextsLevelMask ()
 Updates the combined additional contexts level mask. More...
 
void updateCombinedAdditionalContextsMask ()
 Updates the combined additional contexts mask. More...
 
void updateCombinedLevelMask ()
 Updates the combined level mask. More...
 
void updateMasks ()
 Updates all three combined level- and context-masks. More...
 

Private Attributes

OutputLevel combinedAdditionalContextsLevelMask_
 The combined mask of accepted additional contexts levels of all listeners. More...
 
OutputContextMask combinedAdditionalContextsMask_
 The combined mask of accepted additional contexts of all listeners. More...
 
OutputLevel combinedLevelMask_
 The combined mask of accepted levels of all listeners. More...
 
ConsoleWriterconsoleWriterInstance_
 The main instance of ConsoleWriter, managed by OutputManager. More...
 
std::map< std::string, OutputContextContainercontextContainers_
 Contains all contexts including sub-contexts and their containers. More...
 
std::map< std::string, OutputContextMaskcontextMasks_
 Contains all main-contexts and their masks. More...
 
bool isInitialized_
 Becomes true once the following instances were created. More...
 
std::vector< OutputListener * > listeners_
 List of all registered output listeners. More...
 
LogWriterlogWriterInstance_
 The main instance of LogWriter, managed by OutputManager. More...
 
MemoryWritermemoryWriterInstance_
 The main instance of MemoryWriter, managed by OutputManager. More...
 
OutputContextSubID subcontextCounter_
 Counts the number of sub-contexts (and generates their IDs) More...
 

Detailed Description

OutputManager acts as the center of the output system and is implemented as a singleton.

All instances of OutputStream (and hence also the orxout() function) send their buffered output to OutputManager. OutputManager then distributes this output to all registered instances of OutputListener.

For each listener OutputManager checks if it wants to receive output with the given level and context. OutputManager itself also maintains masks that define the accepted levels and concept. They are a combination of the masks of all output listeners. See the description of OutputListener for a more conclusive description of these masks.

Additionally OutputManager is used to register output contexts.

Constructor & Destructor Documentation

orxonox::OutputManager::OutputManager ( )

Constructor, initializes all values.

orxonox::OutputManager::~OutputManager ( )
virtual

Destructor.

orxonox::OutputManager::OutputManager ( const OutputManager )
privatedelete

Member Function Documentation

bool orxonox::OutputManager::acceptsOutput ( OutputLevel  level,
const OutputContextContainer context 
) const
inline

Returns true if at least one of the output listeners will accept output with the given level and context.

For the sake of performance, output messages with levels or contexts that are not accepted should be ignored or, even better, not generated at all.

OutputLevel orxonox::OutputManager::getCombinedAdditionalContextsLevelMask ( ) const
inline
OutputContextMask orxonox::OutputManager::getCombinedAdditionalContextsMask ( ) const
inline
OutputLevel orxonox::OutputManager::getCombinedLevelMask ( ) const
inline
ConsoleWriter* orxonox::OutputManager::getConsoleWriter ( )
inline
std::string orxonox::OutputManager::getDefaultPrefix ( OutputLevel  level,
const OutputContextContainer context 
) const

Returns a string containing the name of the level and the context (if any) which can be prepended to an output message if it is written to the console or the log file.

OutputManager & orxonox::OutputManager::getInstance ( )
static

Returns the only existing instance of the OutputManager singleton.

OutputManager & orxonox::OutputManager::getInstanceAndCreateListeners ( )
static

Returns the only existing instance of the OutputManager singleton and ensures that the most important output listeners exist.

You should use this function if you send output to OutputManager and want to be sure that the most important output listeners exist. Don't use it elsewhere inside the output system to avoid circular calls.

const std::string & orxonox::OutputManager::getLevelName ( OutputLevel  level) const

Returns a human readable string for each output level.

const std::vector<OutputListener*>& orxonox::OutputManager::getListeners ( ) const
inline
LogWriter* orxonox::OutputManager::getLogWriter ( )
inline
MemoryWriter* orxonox::OutputManager::getMemoryWriter ( )
inline
OutputManager& orxonox::OutputManager::operator= ( const OutputManager )
privatedelete
void orxonox::OutputManager::pushMessage ( OutputLevel  level,
const OutputContextContainer context,
const std::string &  message 
)
virtual

Sends an output message to all output listeners.

Parameters
levelThe level of the message
contextThe context of the message
messageThe output message (may contain '\n')

This function splits the message into lines (if it contains '\n') and sends it to the output listeners. They may ignore the message if it doesn't match their level- and context-masks.

const OutputContextContainer & orxonox::OutputManager::registerContext ( const std::string &  name,
const std::string &  subname = "" 
)

Registers a context (or sub-context) and returns the container which identifies the context.

Parameters
nameThe name of the context
subnameThe name of the sub-context (or "" if it is not a sub-context)

If the context doesn't exist, it gets created. Otherwise the existing instance is returned.

void orxonox::OutputManager::registerListener ( OutputListener listener)
virtual

Adds an output listener to the list of listeners.

void orxonox::OutputManager::unregisterListener ( OutputListener listener)
virtual

Removes an output listener from the list of listeners.

void orxonox::OutputManager::updateCombinedAdditionalContextsLevelMask ( )
private

Updates the combined additional contexts level mask.

The masks of all listeners are ORed to form the combined mask.

void orxonox::OutputManager::updateCombinedAdditionalContextsMask ( )
private

Updates the combined additional contexts mask.

The masks of all listeners are ORed to form the combined mask.

void orxonox::OutputManager::updateCombinedLevelMask ( )
private

Updates the combined level mask.

The masks of all listeners are ORed to form the combined mask.

virtual void orxonox::OutputManager::updatedAdditionalContextsLevelMask ( const OutputListener listener)
inlineoverridevirtual
virtual void orxonox::OutputManager::updatedAdditionalContextsMask ( const OutputListener listener)
inlineoverridevirtual
virtual void orxonox::OutputManager::updatedLevelMask ( const OutputListener listener)
inlineoverridevirtual
void orxonox::OutputManager::updateMasks ( )
private

Updates all three combined level- and context-masks.

Member Data Documentation

OutputLevel orxonox::OutputManager::combinedAdditionalContextsLevelMask_
private

The combined mask of accepted additional contexts levels of all listeners.

OutputContextMask orxonox::OutputManager::combinedAdditionalContextsMask_
private

The combined mask of accepted additional contexts of all listeners.

OutputLevel orxonox::OutputManager::combinedLevelMask_
private

The combined mask of accepted levels of all listeners.

ConsoleWriter* orxonox::OutputManager::consoleWriterInstance_
private

The main instance of ConsoleWriter, managed by OutputManager.

std::map<std::string, OutputContextContainer> orxonox::OutputManager::contextContainers_
private

Contains all contexts including sub-contexts and their containers.

std::map<std::string, OutputContextMask> orxonox::OutputManager::contextMasks_
private

Contains all main-contexts and their masks.

bool orxonox::OutputManager::isInitialized_
private

Becomes true once the following instances were created.

std::vector<OutputListener*> orxonox::OutputManager::listeners_
private

List of all registered output listeners.

LogWriter* orxonox::OutputManager::logWriterInstance_
private

The main instance of LogWriter, managed by OutputManager.

MemoryWriter* orxonox::OutputManager::memoryWriterInstance_
private

The main instance of MemoryWriter, managed by OutputManager.

OutputContextSubID orxonox::OutputManager::subcontextCounter_
private

Counts the number of sub-contexts (and generates their IDs)


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