Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

XmiWriter.hpp

Go to the documentation of this file.
00001 /* 00002 * Copyright (C) 2004 Andrew Sutton 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to: 00016 * 00017 * The Free Software Foundation, Inc. 00018 * 59 Temple Place, Suite 330 00019 * Boston, MA 02111-1307 USA 00020 * 00021 * Contact: 00022 * Andrew Sutton asutton@cs.kent.edu 00023 */ 00024 00025 #ifndef OMF_XMIWRITER_HPP 00026 #define OMF_XMIWRITER_HPP 00027 00028 // std includes 00029 #include <string> 00030 #include <map> 00031 00032 // libxml includes 00033 #include <libxml/tree.h> 00034 00035 // OMF includes 00036 #include <OMF/ModelIterator.hpp> 00037 00038 namespace OMF 00039 { 00040 // forward declarations 00041 class Model; 00042 class ModelObject; 00043 class Property; 00044 00052 class XmiWriter 00053 { 00054 public: 00055 XmiWriter(); 00056 ~XmiWriter(); 00057 00065 bool write(Model *model, const char *filename); 00066 00067 private: 00068 // 1 Document Structure 00069 void document(); 00070 void xmi(); 00071 void startAttribs(); 00072 void xmiVersion(); 00073 void namespaces(); 00074 00075 // 2 Document Contents 00076 void contentElements(); 00077 00078 // 3 Object Structure 00079 void objectAsElement(); 00080 void tagName(); 00081 void objectAttribs(); 00082 void identityAttribs(); 00083 void typeAttrib(); 00084 void featureAttribs(); 00085 void dataValueAttrib(); 00086 void refValueAttrib(); 00087 00088 // 4 Reference element 00089 void referenceElement(); 00090 00091 // 5 object contents 00092 void attributeAsElement(); 00093 00094 private: 00095 struct Context 00096 { 00097 typedef std::list<Property *> PropList; 00098 00099 Context() : 00100 previous(0), 00101 object(0), 00102 ref(0), 00103 prop(0), 00104 compAtt(), 00105 compRef(), 00106 attribs(), 00107 node(0), 00108 attr(0) 00109 {} 00110 00111 Context *previous; // link to the last context 00112 ModelObject *object; // the current object 00113 ModelObject *ref; // scratchpad for the current reference 00114 Property *prop; // the current relation 00115 00116 PropList compAtt; // composite attributes (lists, structures). 00117 PropList compRef; // composite elements 00118 PropList attribs; // everything else 00119 00120 xmlNodePtr node; // the xml node 00121 xmlAttrPtr attr; // the current attr pointer 00122 }; 00123 00124 typedef std::map<std::string, xmlNsPtr> NsMap; 00125 00126 ModelIterator _it; // the iterator used for serialization 00127 xmlDocPtr _doc; // the doc being built 00128 xmlNodePtr _xmi; // the root element 00129 xmlNsPtr _xmiNs; // the XMI namespace 00130 NsMap _nsMap; // mapping for namespace lookup 00131 Model *_model; // the model 00132 Context *_current; // the current context 00133 }; 00134 00135 } 00136 00137 #endif 00138

Generated on Fri Sep 10 13:07:33 2004 for OpenModelingFramework by doxygen 1.3.8