00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2010 by the OpenStructure authors 00005 // Copyright (C) 2003-2010 by the IPLT authors 00006 // 00007 // This library is free software; you can redistribute it and/or modify it under 00008 // the terms of the GNU Lesser General Public License as published by the Free 00009 // Software Foundation; either version 3.0 of the License, or (at your option) 00010 // any later version. 00011 // This library is distributed in the hope that it will be useful, but WITHOUT 00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00013 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00014 // details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this library; if not, write to the Free Software Foundation, Inc., 00018 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 //------------------------------------------------------------------------------ 00020 00021 /* 00022 low level info implementation 00023 00024 Author: Ansgar Philippsen 00025 */ 00026 00027 #ifndef OST_DATA_INFO_IMPL_H 00028 #define OST_DATA_INFO_IMPL_H 00029 00030 #include <ost/message.hh> 00031 #include <utility> 00032 #include <vector> 00033 #include <iostream> 00034 00035 #include <QDomElement> 00036 #include <QDomDocument> 00037 #include <QDomAttr> 00038 #include <QDomText> 00039 00040 #include <ost/base.hh> 00041 #include <ost/geom/geom.hh> 00042 00043 #include <ost/ptr_observer.hh> 00044 00045 #include "info_impl_fw.hh" 00046 #include "item_type.hh" 00047 00048 namespace ost { namespace info { namespace detail { 00049 00050 typedef std::vector<ElePtr> EleList; 00051 /* 00052 wraps a DomElement, to be used by the high level item and group class 00053 */ 00054 class EleImpl { 00055 public: 00056 EleImpl(const QDomElement& e); 00057 00058 // tag name access 00059 String GetName() const; 00060 void SetName(const String& n); 00061 00062 // get full path 00063 String GetPath() const; 00064 00065 00066 // attribute access 00067 void SetAttribute(const String& name, const String& value); 00068 String GetAttribute(const String& name) const; 00069 bool HasAttribute(const String& name) const; 00070 void RemoveAttribute(const String& name); 00071 00072 std::vector<String> GetAttributeList() const; 00073 00074 String GetTextData() const; 00075 void SetTextData(const String& td); 00076 00080 EleList GetSubs(const String& name) const; 00081 00084 ElePtr GetSub(const String& name) const; 00085 ElePtr CreateSub(const String& name); 00086 bool HasSub(const String& name) const; 00087 00088 void RemoveSub(const String& name); 00089 00090 void RemoveSub(const ElePtr& ele); 00091 00092 QDomElement& GetElement(); 00093 const QDomElement& GetElement() const; 00094 00095 InfoImpl& GetRoot(); 00096 InfoImpl& GetRoot() const; 00097 00098 std::vector<ElePtr> GetSubList() const; 00099 00100 ElePtr GetParent() const; 00101 00102 bool operator==(const EleImpl& ref) const; 00103 00104 Type GetType() const; 00105 void SetType(Type t); 00106 00107 void SetNewType(int t); 00108 00109 void SetStringRepr(const String& v, bool settype); 00110 String GetStringRepr() const; 00111 void SetIntRepr(int repr); 00112 int GetIntRepr() const; 00113 void SetFloatRepr(float repr); 00114 float GetFloatRepr() const; 00115 void SetBoolRepr(bool repr); 00116 bool GetBoolRepr() const; 00117 void SetVecRepr(const geom::Vec3& repr); 00118 geom::Vec3 GetVecRepr() const; 00119 00120 private: 00121 QDomElement ele_; 00122 00123 Type type_; 00124 00125 String String_repr_; 00126 int int_repr_; 00127 float float_repr_; 00128 bool bool_repr_; 00129 geom::Vec3 vec_repr_; 00130 }; 00131 00132 00133 class InfoImpl { 00134 public: 00135 InfoImpl(); 00136 InfoImpl(const String& file); 00137 InfoImpl(bool dummy,const String& text); 00138 00139 RootPtr Copy() const; 00140 00141 void Import(const String& file); 00142 void Export(const String& file); 00143 00144 EleImpl Root(); 00145 00146 RootPtrList& DefList() {return def_list_;} 00147 const RootPtrList& DefList() const {return def_list_;} 00148 00149 QDomDocument& GetDocument() {return document_;} 00150 const QDomDocument& GetDocument() const {return document_;} 00151 00152 private: 00153 QDomDocument document_; 00154 00155 RootPtrList def_list_; 00156 }; 00157 00158 }}} // ns 00159 00160 #endif
1.5.8