}
-ContextObj::ContextObj(Context* pContext) :
- d_pContextObjRestore(NULL) {
-
- Assert(pContext != NULL, "NULL context pointer");
-
- d_pScope = pContext->getBottomScope();
- d_pScope->addToChain(this);
-}
-
-
-ContextObj::~ContextObj() throw(AssertionException) {
+void ContextObj::destroy() throw(AssertionException) {
for(;;) {
if(next() != NULL) {
next()->prev() = prev();
}
+ContextObj::ContextObj(Context* pContext) :
+ d_pContextObjRestore(NULL) {
+
+ Assert(pContext != NULL, "NULL context pointer");
+
+ d_pScope = pContext->getBottomScope();
+ d_pScope->addToChain(this);
+}
+
+
ContextNotifyObj::ContextNotifyObj(Context* pContext, bool preNotify) {
if(preNotify) {
pContext->addNotifyObjPre(this);
* ContextMemoryManager (see item 2 above).
* 4. In the subclass implementation, any time the state is about to be
* changed, first call makeCurrent().
+ * 5. In the subclass implementation, the destructor should call destroy().
+ * Unfortunately, the destroy() functionality cannot be in the ContextObj
+ * destructor since it needs to call the subclass-specific restore() method
+ * in order to properly clean up saved copies.
*/
class ContextObj {
/**
}
}
+ /**
+ * Should be called from sub-class destructor: calls restore until restored
+ * to initial version. Also removes object from all Scope lists. Note that
+ * this doesn't actually free the memory allocated by the ContextMemoryManager
+ * for this object. This isn't done until the corresponding Scope is popped.
+ */
+ void destroy() throw(AssertionException);
+
/**
* operator new using ContextMemoryManager (common case used by
* subclasses during save() ). No delete is required for memory
ContextObj(Context* context);
/**
- * Destructor: Calls restore until restored to initial version.
- * Also removes object from all Scope lists. Note that this doesn't
- * actually free the memory allocated by the ContextMemoryManager
- * for this object. This isn't done until the corresponding Scope
- * is popped.
+ * Destructor does nothing: subclass must explicitly call destroy() instead.
*/
- virtual ~ContextObj() throw(AssertionException);
+ virtual ~ContextObj() {}
/**
* If you want to allocate a ContextObj object on the heap, use this