Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 30, 2011, 7:51:08 PM (13 years ago)
Author:
landauf
Message:

Code related to config values for output is now implemented in BaseWriter.
There's a config value for the normal output level, a vector with additional contexts, and a config value for the level of these additional contexts.
ioconsole and standard console use the same values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/output/src/libraries/util/output/BaseWriter.cc

    r8795 r8799  
    3333namespace orxonox
    3434{
    35     BaseWriter::BaseWriter()
     35    BaseWriter::BaseWriter(const std::string& name)
    3636    {
     37        this->name_ = name;
     38
     39        this->configurableMaxLevel_ = level::none;
     40        this->configurableContextsMaxLevel_ = level::verbose;
    3741    }
    3842
     
    4347    void BaseWriter::output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines)
    4448    {
    45         const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context);
    46         std::string blanks(prefix.length(), ' ');
     49        if (level <= this->configurableMaxLevel_ || (level <= this->configurableContextsMaxLevel_ && this->isAdditionalContext(context)))
     50        {
     51            const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context);
     52            std::string blanks(prefix.length(), ' ');
    4753
    48         for (size_t i = 0; i < lines.size(); ++i)
    49             this->printLine((i == 0 ? prefix : blanks) + lines[i], level);
     54            for (size_t i = 0; i < lines.size(); ++i)
     55                this->printLine((i == 0 ? prefix : blanks) + lines[i], level);
     56        }
     57    }
     58
     59    void BaseWriter::setLevelMax(OutputLevel max)
     60    {
     61        this->configurableMaxLevel_ = max;
     62        this->changedConfigurableLevels();
     63    }
     64
     65    void BaseWriter::changedConfigurableLevels()
     66    {
     67        OutputLevel max_level = std::max(this->configurableMaxLevel_, this->configurableContextsMaxLevel_);
     68        OutputListener::setLevelMax(max_level);
     69    }
     70
     71    void BaseWriter::changedConfigurableContexts()
     72    {
     73        this->configurableContextsSet_.clear();
     74        for (size_t i = 0; i < this->configurableContexts_.size(); ++i)
     75            this->configurableContextsSet_.insert(this->configurableContexts_[i]);
     76    }
     77
     78    bool BaseWriter::isAdditionalContext(OutputContext context) const
     79    {
     80        const std::string& name = OutputManager::getInstance().getContextName(context);
     81        std::set<std::string>::const_iterator it = this->configurableContextsSet_.find(name);
     82        return (it != this->configurableContextsSet_.end());
    5083    }
    5184}
Note: See TracChangeset for help on using the changeset viewer.