00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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 class XQILLA_API AutoDocumentCacheReset
00092 {
00093 public:
00094 AutoDocumentCacheReset(DynamicContext* context)
00095 : oldDC(const_cast<DocumentCache*>(context->getDocumentCache())),
00096 context_ (context)
00097 {
00098 }
00099
00100 ~AutoDocumentCacheReset()
00101 {
00102 context_->setDocumentCache(oldDC);
00103 }
00104
00105 DocumentCache *oldDC;
00106
00107 protected:
00108 DynamicContext* context_;
00109 };
00110
00111 #endif