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/OutputDefinitions.h

    r8831 r8833  
    3434
    3535#define REGISTER_OUTPUT_CONTEXT(name) \
    36     OutputContext name() { static OutputContext context = registerContext(#name); return context; }
     36    const OutputContextContainer& name() { static const OutputContextContainer& context = registerContext(#name); return context; }
     37
     38#define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
     39    const OutputContextContainer& subname() { static const OutputContextContainer& context = registerContext(#name, #subname); return context; }
    3740
    3841namespace orxonox
     
    6366    using namespace level;
    6467
    65     typedef uint64_t OutputContext;
    66     typedef OutputContext (OutputContextFunction)();
     68    typedef uint64_t OutputContextMask;
     69    typedef uint16_t OutputContextSubID;
    6770
    68     extern _UtilExport OutputContext registerContext(const std::string& name);
     71    struct OutputContextContainer
     72    {
     73        OutputContextMask mask;
     74        OutputContextSubID sub_id;
     75        std::string name;
     76    };
     77
     78    typedef const OutputContextContainer& (OutputContextFunction)();
     79
     80    extern _UtilExport const OutputContextContainer& registerContext(const std::string& name, const std::string& subname = "");
    6981
    7082    namespace context
    7183    {
    72         static const OutputContext all       = 0xFFFFFFFFFFFFFFFF;
    73         static const OutputContext none      = 0x0000000000000000;
     84        static const OutputContextMask all       = 0xFFFFFFFFFFFFFFFF;
     85        static const OutputContextMask none      = 0x0000000000000000;
     86
     87        static const OutputContextSubID no_subcontext = 0;
    7488
    7589        namespace
     
    103117            REGISTER_OUTPUT_CONTEXT(triggers);
    104118            REGISTER_OUTPUT_CONTEXT(docking);
     119
     120            namespace misc
     121            {
     122                REGISTER_OUTPUT_SUBCONTEXT(misc, testcontext1);
     123                REGISTER_OUTPUT_SUBCONTEXT(misc, testcontext2);
     124                REGISTER_OUTPUT_SUBCONTEXT(misc, testcontext3);
     125                REGISTER_OUTPUT_SUBCONTEXT(misc, testcontext4);
     126            }
     127
     128            REGISTER_OUTPUT_CONTEXT(c30);
     129            REGISTER_OUTPUT_CONTEXT(c31);
     130            REGISTER_OUTPUT_CONTEXT(c32);
     131            REGISTER_OUTPUT_CONTEXT(c33);
     132            REGISTER_OUTPUT_CONTEXT(c34);
     133            REGISTER_OUTPUT_CONTEXT(c35);
     134            REGISTER_OUTPUT_CONTEXT(c36);
     135            REGISTER_OUTPUT_CONTEXT(c37);
     136            REGISTER_OUTPUT_CONTEXT(c38);
     137            REGISTER_OUTPUT_CONTEXT(c39);
     138            REGISTER_OUTPUT_CONTEXT(c40);
     139            REGISTER_OUTPUT_CONTEXT(c41);
     140            REGISTER_OUTPUT_CONTEXT(c42);
     141            REGISTER_OUTPUT_CONTEXT(c43);
     142            REGISTER_OUTPUT_CONTEXT(c44);
     143            REGISTER_OUTPUT_CONTEXT(c45);
     144            REGISTER_OUTPUT_CONTEXT(c46);
     145            REGISTER_OUTPUT_CONTEXT(c47);
     146            REGISTER_OUTPUT_CONTEXT(c48);
     147            REGISTER_OUTPUT_CONTEXT(c49);
     148            REGISTER_OUTPUT_CONTEXT(c50);
     149            REGISTER_OUTPUT_CONTEXT(c51);
     150            REGISTER_OUTPUT_CONTEXT(c52);
     151            REGISTER_OUTPUT_CONTEXT(c53);
     152            REGISTER_OUTPUT_CONTEXT(c54);
     153            REGISTER_OUTPUT_CONTEXT(c55);
     154            REGISTER_OUTPUT_CONTEXT(c56);
     155            REGISTER_OUTPUT_CONTEXT(c57);
     156            REGISTER_OUTPUT_CONTEXT(c58);
     157            REGISTER_OUTPUT_CONTEXT(c59);
     158            REGISTER_OUTPUT_CONTEXT(c60);
     159            REGISTER_OUTPUT_CONTEXT(c61);
     160            REGISTER_OUTPUT_CONTEXT(c62);
     161            REGISTER_OUTPUT_CONTEXT(c63);
     162            REGISTER_OUTPUT_CONTEXT(c64);
     163            REGISTER_OUTPUT_CONTEXT(c65);
     164            REGISTER_OUTPUT_CONTEXT(c66);
    105165        }
    106166    }
Note: See TracChangeset for help on using the changeset viewer.