Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
orxonox::OutputListener Class Referenceabstract

OutputListener is an interface which is used to receive output of a certain level and context from OutputManager. More...

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

Inheritance diagram for orxonox::OutputListener:
orxonox::MemoryWriter orxonox::SubcontextOutputListener orxonox::BaseWriter orxonox::ConsoleWriter orxonox::LogWriter orxonox::Shell

Public Member Functions

 OutputListener (bool bRegister=true)
 Constructor, initializes the values and registers the instance at OutputManager if requested. More...
 
virtual ~OutputListener ()
 Destructor, unregisters the instance from OutputManager. More...
 
virtual bool acceptsOutput (OutputLevel level, const OutputContextContainer &context) const
 Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks. More...
 
OutputLevel getAdditionalContextsLevelMask () const
 Returns the additional contexts level mask. More...
 
OutputContextMask getAdditionalContextsMask () const
 Returns the additional contexts mask. More...
 
OutputLevel getLevelMask () const
 Returns the level mask. More...
 
void registerListener (AdditionalContextListener *listener)
 Adds a listener to the list. More...
 
void setAdditionalContextsLevelMask (OutputLevel mask)
 Defines the level mask of additional contexts. More...
 
void setAdditionalContextsLevelMax (OutputLevel max)
 Defines the level mask of additional contexts in a way which accepts all output up to the level max. More...
 
void setAdditionalContextsLevelRange (OutputLevel min, OutputLevel max)
 Defines the level mask of additional contexts in a way which accepts all output between the levels min and max. More...
 
virtual void setAdditionalContextsMask (OutputContextMask mask)
 Defines the mask of additional contexts. More...
 
void setLevelMask (OutputLevel mask)
 Defines the level mask. More...
 
void setLevelMax (OutputLevel max)
 Defines the level mask in a way which accepts all output up to the level max. More...
 
void setLevelRange (OutputLevel min, OutputLevel max)
 Defines the level mask in a way which accepts all output between the levels min and max. More...
 
virtual void unfilteredOutput (OutputLevel level, const OutputContextContainer &context, const std::vector< std::string > &lines)
 Called by OutputManager for each line of output, checks if this listener actually accepts this output before it calls the output() function. More...
 
void unregisterListener (AdditionalContextListener *listener)
 Removes a listener from the list. More...
 

Protected Member Functions

const std::vector< AdditionalContextListener * > & getListeners () const
 
virtual void output (OutputLevel level, const OutputContextContainer &context, const std::vector< std::string > &lines)=0
 Pure virtual function, needs to be implemented in order to receive output. More...
 

Private Attributes

OutputLevel additionalContextsLevelMask_
 Mask of accepted output levels of the additional contexts. More...
 
OutputContextMask additionalContextsMask_
 Mask of accepted additional contexts. More...
 
OutputLevel levelMask_
 Mask of accepted output levels, independent of contexts. More...
 
std::vector< AdditionalContextListener * > listeners_
 List of all registered additional context listeners. More...
 

Detailed Description

OutputListener is an interface which is used to receive output of a certain level and context from OutputManager.

An instance of OutputListener registers itself at OutputManager and declares the desired output levels and contexts.

OutputManager will then send output to it by calling the output() function.

OutputListener has 3 masks to define the desired output. These masks can be used in two different ways (or as a combination of both):

This can be illustrated as follows:

  1. Only level mask:
    • level-mask = error | warning;
            |   Contexts:   |
            | A | B | C | D |
    --------|---|---|---|---|
    debug   | - | - | - | - |
    --------|---|---|---|---|
    error   | x | x | x | x |
    --------|---|---|---|---|       [x] Receives output
    warning | x | x | x | x |       [-] Does not receive output
    --------|---|---|---|---|
    status  | - | - | - | - |
    --------|---|---|---|---|
    verbose | - | - | - | - |
    --------|---|---|---|---|
    
  2. Only additional contexts:
    • additional-contexts-mask = B | D;
    • additional-contexts-level-mask = debug | verbose;
            |   Contexts:   |
            | A | B | C | D |
    --------|---|---|---|---|
    debug   | - | x | - | x |
    --------|---|---|---|---|
    error   | - | - | - | - |
    --------|---|---|---|---|       [x] Receives output
    warning | - | - | - | - |       [-] Does not receive output
    --------|---|---|---|---|
    status  | - | - | - | - |
    --------|---|---|---|---|
    verbose | - | x | - | x |
    --------|---|---|---|---|
    
  3. Both level mask plus additional contexts:
    • level-mask = error | warning;
    • additional-contexts-mask = B | D;
    • additional-contexts-level-mask = debug | verbose;
            |   Contexts:   |
            | A | B | C | D |
    --------|---|---|---|---|
    debug   | - | x | - | x |
    --------|---|---|---|---|
    error   | x | x | x | x |
    --------|---|---|---|---|       [x] Receives output
    warning | x | x | x | x |       [-] Does not receive output
    --------|---|---|---|---|
    status  | - | - | - | - |
    --------|---|---|---|---|
    verbose | - | x | - | x |
    --------|---|---|---|---|
    

Constructor & Destructor Documentation

orxonox::OutputListener::OutputListener ( bool  bRegister = true)

Constructor, initializes the values and registers the instance at OutputManager if requested.

Parameters
bRegisterIf true, the instance is automatically registered at OutputManager. Should be false if the constructor of the derived class generates output.
orxonox::OutputListener::~OutputListener ( )
virtual

Destructor, unregisters the instance from OutputManager.

Member Function Documentation

bool orxonox::OutputListener::acceptsOutput ( OutputLevel  level,
const OutputContextContainer context 
) const
virtual

Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks.

Reimplemented in orxonox::SubcontextOutputListener.

OutputLevel orxonox::OutputListener::getAdditionalContextsLevelMask ( ) const
inline

Returns the additional contexts level mask.

OutputContextMask orxonox::OutputListener::getAdditionalContextsMask ( ) const
inline

Returns the additional contexts mask.

OutputLevel orxonox::OutputListener::getLevelMask ( ) const
inline

Returns the level mask.

const std::vector<AdditionalContextListener*>& orxonox::OutputListener::getListeners ( ) const
inlineprotected
virtual void orxonox::OutputListener::output ( OutputLevel  level,
const OutputContextContainer context,
const std::vector< std::string > &  lines 
)
protectedpure virtual

Pure virtual function, needs to be implemented in order to receive output.

Implemented in orxonox::BaseWriter, and orxonox::MemoryWriter.

void orxonox::OutputListener::registerListener ( AdditionalContextListener listener)

Adds a listener to the list.

void orxonox::OutputListener::setAdditionalContextsLevelMask ( OutputLevel  mask)

Defines the level mask of additional contexts.

void orxonox::OutputListener::setAdditionalContextsLevelMax ( OutputLevel  max)

Defines the level mask of additional contexts in a way which accepts all output up to the level max.

void orxonox::OutputListener::setAdditionalContextsLevelRange ( OutputLevel  min,
OutputLevel  max 
)

Defines the level mask of additional contexts in a way which accepts all output between the levels min and max.

void orxonox::OutputListener::setAdditionalContextsMask ( OutputContextMask  mask)
virtual

Defines the mask of additional contexts.

Reimplemented in orxonox::SubcontextOutputListener.

void orxonox::OutputListener::setLevelMask ( OutputLevel  mask)

Defines the level mask.

void orxonox::OutputListener::setLevelMax ( OutputLevel  max)

Defines the level mask in a way which accepts all output up to the level max.

void orxonox::OutputListener::setLevelRange ( OutputLevel  min,
OutputLevel  max 
)

Defines the level mask in a way which accepts all output between the levels min and max.

virtual void orxonox::OutputListener::unfilteredOutput ( OutputLevel  level,
const OutputContextContainer context,
const std::vector< std::string > &  lines 
)
inlinevirtual

Called by OutputManager for each line of output, checks if this listener actually accepts this output before it calls the output() function.

void orxonox::OutputListener::unregisterListener ( AdditionalContextListener listener)

Removes a listener from the list.

Member Data Documentation

OutputLevel orxonox::OutputListener::additionalContextsLevelMask_
private

Mask of accepted output levels of the additional contexts.

OutputContextMask orxonox::OutputListener::additionalContextsMask_
private

Mask of accepted additional contexts.

OutputLevel orxonox::OutputListener::levelMask_
private

Mask of accepted output levels, independent of contexts.

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

List of all registered additional context listeners.


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