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

XmiReader_2_0.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_XMIREADER20_HPP 00026 #define OMF_XMIREADER20_HPP 00027 00028 // std includes 00029 #include <string> 00030 #include <list> 00031 #include <map> 00032 00033 // libxml includes 00034 #include <libxml/tree.h> 00035 00036 namespace OMF 00037 { 00038 // forward declarations 00039 class ModelObject; 00040 class Property; 00041 class Association; 00042 00048 class XmiReader_2_0 00049 { 00050 public: 00051 XmiReader_2_0(); 00052 ~XmiReader_2_0(); 00053 00054 // A good starting point 00055 void document(Model *model, xmlDocPtr doc); 00056 00057 protected: 00058 bool isXmi(xmlNsPtr ns); 00059 bool isVersionAttr(xmlAttrPtr attr); 00060 bool isIdAttr(xmlAttrPtr attr); 00061 bool isLabelAttr(xmlAttrPtr attr); 00062 bool isUuidAttr(xmlAttrPtr attr); 00063 bool isTypeAttr(xmlAttrPtr attr); 00064 bool isIdrefAttr(xmlAttrPtr attr); 00065 bool isHrefAttr(xmlAttrPtr attr); 00066 00067 void createObject(); 00068 void resolveDeferred(); 00069 00070 // [3.3.1] Overall Document Structure 00071 void xmi(); 00072 void startAttribs(); 00073 void xmiVersion(); 00074 void namespaces(); 00075 00076 // [3.3.2] Overall Content Structure 00077 void contentElements(); 00078 00079 // [3.3.3] Object Structure 00080 void objectAsElement(); 00081 void objectTagName(); 00082 void objectAttribs(); 00083 void identityAttribs(); 00084 void typeAttrib(); 00085 void featureAttribs(); 00086 void dataValueAttrib(); 00087 void refValueAttrib(); 00088 00089 // [3.3.4] References 00090 void linkAttribs(); 00091 00092 // [3.3.5] Object Contents 00093 void objectContents(); 00094 void contentElement(); 00095 void dataValue(); 00096 void primitiveValue(); 00097 void structureValue(); 00098 00099 // [3.3.6] Extensions??? 00100 void extension(); 00101 00102 // 6:classAttributes 00103 void classAttributes(); 00104 00105 // 7:otherLinks 00106 void otherLinks(); 00107 00108 private: 00114 struct Context 00115 { 00116 Context() : 00117 node(0), 00118 attr(0), 00119 previous(0), 00120 object(0), 00121 prop(), 00122 context(), 00123 end(false) 00124 {} 00125 00126 xmlNodePtr node; // the node being parsed 00127 xmlNodePtr child; // the current child position 00128 xmlAttrPtr attr; // the current attr position 00129 00130 Context *previous; // the previous context 00131 ModelObject *object; // the object being parsed (can be null) 00132 Property *prop; // some relavent property of this object 00133 Property *context; // the property in which this object is defined 00134 00135 bool end; // marks the end state for a sequence 00136 00137 std::string uri; // the uri of the element 00138 std::string metaclass; // the element class name 00139 std::string feature; // the name of the feature 00140 std::string xmiId; // the xmi id 00141 std::string xmiUuid; // the xmi uuid 00142 std::string xmiLabel; // the xmi label 00143 std::string xmiType; // the xmi type 00144 std::string xmiIdref; // a local xmi id reference 00145 std::string href; // a non-local xml reference 00146 }; 00147 00154 struct Deferred 00155 { 00156 Deferred() : 00157 id(), 00158 prop(0), 00159 object(0) 00160 {} 00161 00162 std::string id; 00163 Property *prop; 00164 ModelObject *object; 00165 }; 00166 00167 typedef std::map<std::string, xmlNsPtr> PrefixMap; 00168 typedef std::list<Deferred *> DeferredList; 00169 00170 xmlDocPtr _doc; // document object 00171 xmlNodePtr _xmi; // root node 00172 PrefixMap _prefix; // cached namespaces 00173 DeferredList _deferred; // deferred reference list 00174 Context *_current; // the current context 00175 Model *_model; // the model being populated 00176 }; 00177 } 00178 00179 #endif

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