ContextHelpers.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2006
00003  *     DecisionSoft Limited. All rights reserved.
00004  * Copyright (c) 2004-2006
00005  *     Progress Software Corporation. All rights reserved.
00006  * Copyright (c) 2004-2006
00007  *     Oracle. All rights reserved.
00008  *
00009  * See the file LICENSE for redistribution information.
00010  *
00011  * $Id: ContextHelpers.hpp,v 1.2 2006/11/01 16:37:11 jpcs Exp $
00012  */
00013 
00014 #if !defined(AFXQ_CONTEXTHELPERS_H__D6A320F5_21F1_421D_9E46_E4373B375E1A__INCLUDED_)
00015 #define AFXQ_CONTEXTHELPERS_H__D6A320F5_21F1_421D_9E46_E4373B375E1A__INCLUDED_
00016 
00017 #include <xqilla/framework/XQillaExport.hpp>
00018 #include <xqilla/context/DynamicContext.hpp>
00019 
00020 class XQILLA_API AutoNodeSetOrderingReset
00021 {
00022 public:
00023   AutoNodeSetOrderingReset(StaticContext* context, StaticContext::NodeSetOrdering ordering = StaticContext::ORDERING_UNORDERED)
00024   {
00025     context_ = context;
00026     ordering_ = context->getNodeSetOrdering();
00027     context->setNodeSetOrdering(ordering);
00028   }
00029 
00030   ~AutoNodeSetOrderingReset()
00031   {
00032     context_->setNodeSetOrdering(ordering_);
00033   }
00034 
00035 protected:
00036   StaticContext* context_;
00037   StaticContext::NodeSetOrdering ordering_;  
00038 };
00039 
00040 class XQILLA_API AutoContextItemTypeReset
00041 {
00042 public:
00043   AutoContextItemTypeReset(StaticContext* context, const StaticType &sType)
00044   {
00045     context_ = context;
00046     sType_ = context->getContextItemType();
00047     context->setContextItemType(sType);
00048   }
00049 
00050   ~AutoContextItemTypeReset()
00051   {
00052     context_->setContextItemType(sType_);
00053   }
00054 
00055 protected:
00056   StaticContext* context_;
00057   StaticType sType_;
00058 };
00059 
00060 class XQILLA_API AutoContextInfoReset
00061 {
00062 public:
00063   AutoContextInfoReset(DynamicContext* context)
00064     : oldContextItem(context->getContextItem()),
00065       oldContextPosition(context->getContextPosition()),
00066       oldContextSize(context->getContextSize()),
00067       context_(context)
00068   {
00069   }
00070 
00071   ~AutoContextInfoReset()
00072   {
00073     resetContextInfo();
00074   }
00075 
00076   void resetContextInfo()
00077   {
00078     context_->setContextItem(oldContextItem);
00079     context_->setContextPosition(oldContextPosition);
00080     context_->setContextSize(oldContextSize);
00081   }
00082 
00083   Item::Ptr oldContextItem;
00084   unsigned int oldContextPosition;
00085   unsigned int oldContextSize;
00086 
00087 private:
00088   DynamicContext* context_;
00089 };
00090 
00091 #endif

Generated on Fri Jan 19 15:30:52 2007 for XQilla Simple API by  doxygen 1.4.6