Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 11, 2011, 11:20:39 PM (13 years ago)
Author:
landauf
Message:

A context is now defined by a struct instead of only a mask.

Introduced sub-contexts. Sub-contexts of the same main-context share the same mask, but have a different ID.
Main-contexts are filtered using a bitmask which happens for every line of output and is very fast.
Sub-contexts are filtered using a set which is slow but happens only if a specific sub-context is enabled in the config file which is usually not the case.

The concept of filtering normal output + additional contexts was moved from BaseWriter directly to OutputListener and OutputManager which makes the whole system faster.
BaseWriter now calls registerContext() for each configured output context, which basically allows the usage of more than 64 contexts as long as these contexts are not used before loading the config file. Though by design it's not recommended.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/output/src/libraries/util/output/OutputManager.h

    r8799 r8833  
    3333
    3434#include <vector>
    35 #include <boost/bimap.hpp>
     35#include <map>
    3636
    3737#include "OutputDefinitions.h"
     
    4545            static OutputManager& getInstanceAndCreateListeners();
    4646
    47             void pushMessage(OutputLevel level, OutputContext context, const std::string& message);
     47            void pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message);
    4848
    4949            void registerListener(OutputListener* listener);
     
    5252            void updateMasks();
    5353            void updateCombinedLevelMask();
    54             void updateCombinedContextMask();
     54            void updateCombinedAdditionalContextsLevelMask();
     55            void updateCombinedAdditionalContextsMask();
    5556
    56             inline OutputLevel getCombinedLevelMask() const
    57                 { return this->combinedLevelMask_; }
    58             inline OutputContext getCombinedContextMask() const
    59                 { return this->combinedContextMask_; }
     57            inline bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const
     58            {
     59                return (this->combinedLevelMask_ & level) ||
     60                       ((this->combinedAdditionalContextsLevelMask_ & level) && (this->combinedAdditionalContextsMask_ & context.mask));
     61            }
    6062
    61             inline bool acceptsOutput(OutputLevel level, OutputContext context) const
    62                 { return ((this->combinedLevelMask_ & level) && (this->combinedContextMask_ & context)); }
    63 
    64             OutputContext registerContext(const std::string& name);
     63            const OutputContextContainer& registerContext(const std::string& name, const std::string& subname = "");
    6564
    6665            const std::string& getLevelName(OutputLevel level) const;
    67             const std::string& getContextName(OutputContext context) const;
    68             OutputContext getContextValue(const std::string& name) const;
    69 
    70             std::string getComposedContextName(OutputContext context) const;
    71             std::string getDefaultPrefix(OutputLevel level, OutputContext context) const;
     66            std::string getDefaultPrefix(OutputLevel level, const OutputContextContainer& context) const;
    7267
    7368        private:
     
    7873            std::vector<OutputListener*> listeners_;
    7974
    80             OutputLevel   combinedLevelMask_;
    81             OutputContext combinedContextMask_;
     75            OutputLevel       combinedLevelMask_;
     76            OutputLevel       combinedAdditionalContextsLevelMask_;
     77            OutputContextMask combinedAdditionalContextsMask_;
    8278
    83             boost::bimap<OutputContext, std::string> contexts_;
     79            std::map<std::string, OutputContextMask> contextMasks_;
     80            std::map<std::string, OutputContextContainer> contextContainers_;
     81            OutputContextSubID subcontextCounter_;
    8482    };
    8583}
Note: See TracChangeset for help on using the changeset viewer.