00001 /***************************************************************************** 00002 * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch) 00003 ***************************************************************************** 00004 * Project : Zeus Base Library 00005 * Module : XLoaderObject 00006 * Package : Zeus.ZeusBase.System 00007 * Author : Benjamin Hadorn 00008 * Date : 27.12.2011 00009 * System : Zeus-Framework 00010 ***************************************************************************** 00011 * Licence: * 00012 * This library is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU Lesser General Public License as * 00014 * published by the Free Software Foundation; either version * 00015 * 2.1 of the License, or (at your option) any later version. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU Lesser General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Lesser General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 * Changes: 00029 * 27.12.2011 bha: created zeus 2.0 00030 *****************************************************************************/ 00031 00032 #ifndef XLoaderObjectH 00033 #define XLoaderObjectH 00034 00035 #include <zeusbase/System/Interfaces/IXLoaderObject.hpp> 00036 #include <zeusbase/System/XObject.h> 00037 #include <zeusbase/System/XObjectFactory.h> 00038 00039 BEGIN_NAMESPACE_Zeus 00040 00041 /***************************************************************************/ 00048 /***************************************************************************/ 00049 zeusbase_class TXLoaderObject : public TXObject, public IXLoaderObject 00050 { 00051 public: 00052 TXLoaderObject(IXMLNode& rNode); 00053 virtual ~TXLoaderObject(); 00054 00055 //Methods of IXLoaderObject 00056 virtual Retval MQUALIFIER load(); 00057 virtual Retval MQUALIFIER unload(); 00058 virtual bool MQUALIFIER isLoaded(); 00059 virtual Retval MQUALIFIER getExtXMLRefNode(IXMLNode*& rpExtRefNode) const; 00060 virtual Retval MQUALIFIER setExtXMLRef(NAMESPACE_Zeus::IXMLDocument& doc, IXMLNode& main_ref); 00061 virtual void MQUALIFIER getXMLFileName(IString& pFileName) const; 00062 virtual Retval MQUALIFIER reload(const IString* pFileNameToCopy = NULL); 00063 00064 //Methods of TXObject 00065 virtual Retval MQUALIFIER addChild(IXObject& child); 00066 virtual bool MQUALIFIER canCreateChildren()const; 00067 virtual bool MQUALIFIER freeze(); 00068 virtual bool MQUALIFIER unfreeze(); 00069 virtual Retval MQUALIFIER insertChild(Int iIndex, IXObject& rChild); 00070 00071 //**************************************************** 00072 // CAUTION: 00073 // Following methods will automatically call the load() Method 00074 // if the this loader object is not loaded. 00075 // Implicity the following methods will perform a load() call also, 00076 // depending on their input parameters: 00077 // - getObject() 00078 // - getObjects() 00079 // - getChildrenByName() 00080 // 00081 // DO NOT ADD ANY OTHER METHODS FOR AUTOMATICALLY LOADING, SPECIALLY NOT 00082 // - getChildCount() 00083 virtual Retval MQUALIFIER getChild(Int iIndex, IXObject*& rpChild); 00084 virtual Retval MQUALIFIER getChildByName(const IString& rName, IXObject*& rpChild); 00085 // CAUTION 00086 //**************************************************** 00087 00088 //Methods of IZUnknown 00089 MEMORY_MANAGER_DECL 00090 00091 REG_SUB_BEGIN(TXLoaderObject) 00092 REG_SUB_ADD(TXLoaderObject, L"TXLoaderObject"); 00093 REG_SUB_END 00094 00095 protected: 00096 Retval saveXML(const TString& rFileName = L""); 00097 00098 private: 00100 bool m_bLoaded; 00102 IXMLDocument* m_pDocument; 00104 IXMLNode* m_pExtRefNode; 00105 00106 void releaseDocument(); 00107 void setCanCreateChildrenFlag(bool bValue); 00108 00109 }; 00110 00111 //INLINE METHODS 00112 /***************************************************************************/ 00115 /***************************************************************************/ 00116 inline void TXLoaderObject::setCanCreateChildrenFlag(bool bValue) 00117 { 00118 this->storeIntAttribute(TString(L"CreateChildren"), bValue); 00119 } 00120 00121 /***************************************************************************/ 00124 /***************************************************************************/ 00125 inline bool MQUALIFIER TXLoaderObject::isLoaded() 00126 { 00127 return m_bLoaded; 00128 } 00129 00130 END_NAMESPACE_Zeus 00131 00132 #endif