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

This class extends the basic OutputListener interface and adds the ability to filter sub-contexts. More...

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

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

Public Member Functions

 SubcontextOutputListener (bool bRegister=true)
 Constructor, initializes the context masks. More...
 
virtual ~SubcontextOutputListener ()
 Destructor. More...
 
virtual bool acceptsOutput (OutputLevel level, const OutputContextContainer &context) const override
 Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks, as well as the set of accepted sub-contexts. More...
 
const std::set< OutputContextSubID > & getSubcontexts () const
 
virtual void setAdditionalContextsMask (OutputContextMask mask) override
 Overwritten implementation of the function defined by OutputListener. More...
 
void setAdditionalSubcontexts (const std::set< const OutputContextContainer * > &subcontexts)
 Defines the set of accepted sub-contexts. More...
 
- Public Member Functions inherited from orxonox::OutputListener
 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...
 
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...
 
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...
 

Private Attributes

std::set< OutputContextSubIDsubcontexts_
 The set of accepted sub-contexts. More...
 
OutputContextMask subcontextsCheckMask_
 All contexts defined by this mask need to be checked whether they are accepted by the set of sub-contexts. More...
 
OutputContextMask subcontextsNoCheckMask_
 All contexts defined by this mask don't need to be checked since we accept all sub-contexts. More...
 

Additional Inherited Members

- Protected Member Functions inherited from orxonox::OutputListener
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...
 

Detailed Description

This class extends the basic OutputListener interface and adds the ability to filter sub-contexts.

Defining additional contexts with setAdditionalContextsMask() enables all sub-contexts of these additional contexts. To accept only some particular sub-contexts, setAdditionalSubcontexts() has to be used. Note that this requires a set, since a mask is not possible with sub-contexts.

The "final" context mask which will be seen by OutputManager is the combination of all regular contexts plus the masks of all sub-contexts.

Remarks
It would have been possible to implement filtering of sub-contexts directly in OutputListener and even to make OutputManager aware of sub-contexts. This would reduce the amount of unnecessarily generated output, but also increase the complexity of the checks whether some output is needed. On the other hand, filtering of sub-contexts makes the whole concept more complicated, as it adds another mask and a set. So to keep it clean and simple I figured it's best to put sub-context filtering into a seaparate class.

Constructor & Destructor Documentation

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

Constructor, initializes the context masks.

orxonox::SubcontextOutputListener::~SubcontextOutputListener ( )
virtual

Destructor.

Member Function Documentation

bool orxonox::SubcontextOutputListener::acceptsOutput ( OutputLevel  level,
const OutputContextContainer context 
) const
overridevirtual

Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks, as well as the set of accepted sub-contexts.

Reimplemented from orxonox::OutputListener.

const std::set<OutputContextSubID>& orxonox::SubcontextOutputListener::getSubcontexts ( ) const
inline
void orxonox::SubcontextOutputListener::setAdditionalContextsMask ( OutputContextMask  mask)
overridevirtual

Overwritten implementation of the function defined by OutputListener.

Contexts defined with this function are accepted independent of the sub-context. The "final" mask of additional contexts is defined by the combination of this mask and the masks of all accepted sub-contexts.

Reimplemented from orxonox::OutputListener.

void orxonox::SubcontextOutputListener::setAdditionalSubcontexts ( const std::set< const OutputContextContainer * > &  subcontexts)

Defines the set of accepted sub-contexts.

The masks of sub-contexts in this set are added to the mask of additional contexts, but output is only accepted if the exact sub-context exists in this set.

Member Data Documentation

std::set<OutputContextSubID> orxonox::SubcontextOutputListener::subcontexts_
private

The set of accepted sub-contexts.

OutputContextMask orxonox::SubcontextOutputListener::subcontextsCheckMask_
private

All contexts defined by this mask need to be checked whether they are accepted by the set of sub-contexts.

OutputContextMask orxonox::SubcontextOutputListener::subcontextsNoCheckMask_
private

All contexts defined by this mask don't need to be checked since we accept all sub-contexts.


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