Changeset 9651 for code/branches/core6/src/libraries/core/object/Context.cc
- Timestamp:
- Aug 16, 2013, 9:20:59 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/object/Context.cc
r9650 r9651 42 42 Context* Context::rootContext_s = 0; 43 43 44 Context ::Context(Context* context) : Listable(this), parentContext_(context)44 Context* getContextForInitializationOfOtherContexts() 45 45 { 46 // we have to call Listable(this) to avoid circular initialization when creating a Context because Listable calls Context::getRootContext() by 47 // default AND we have to set the context again in the constructor because of other classes inheriting from Context (Listable is a virtual base 48 // and each subclass must call its constructor individually, so either all subclasses add Listable(this) to their initialization list or we call 49 // setContext(this) here). 46 static size_t count = 0; 47 // the first time this is called, ++count returns 1 and the context is created 48 // the second time this is called, ++count returns 2 and NULL is returned because we're in the constructor of the context itself 49 // for each future call the context (now completely created) is returned 50 if (++count == 2) 51 return NULL; 52 else 53 { 54 static Context context(NULL); 55 return &context; 56 } 57 } 58 59 // Initialize Listable(*) with a special context, only used to initialize other contexts. Later in the constructor we change the context 60 Context::Context(Context* context) : Listable(getContextForInitializationOfOtherContexts()), parentContext_(context) 61 { 62 RegisterObject(Context); 63 64 // the context is its own context 50 65 this->setContext(this); 51 52 RegisterObject(Context);53 66 } 54 67
Note: See TracChangeset
for help on using the changeset viewer.