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

Model.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_MODEL_HPP 00026 #define OMF_MODEL_HPP 00027 00028 // std includes 00029 #include <string> 00030 #include <list> 00031 #include <set> 00032 #include <map> 00033 00034 namespace OMF 00035 { 00036 // forward declarations 00037 class Package; 00038 class ModelObject; 00039 00045 class Model 00046 { 00047 public: 00053 enum Mode { 00054 ReadOnly, 00055 ReadWrite 00056 }; 00057 00058 Model(); 00059 ~Model(); 00060 00062 const std::string &fileName() const 00063 { return _filename; } 00064 00066 void setFileName(const std::string &fname) 00067 { _filename = fname; } 00068 00070 const std::string &path() const 00071 { return _path; } 00072 00074 void setPath(const std::string &path) 00075 { _path = path; } 00076 00078 Mode mode() const 00079 { return _mode; } 00080 00082 void setMode(Mode mode) 00083 { _mode = mode; } 00084 00085 00087 bool read(const char *filename); 00088 00090 bool write(const char *filename); 00091 00093 const std::list<ModelObject *> &elements() const 00094 { return _elements; } 00095 00101 void addElement(ModelObject *elem); 00102 00108 void removeElement(ModelObject *elem); 00109 00114 void identifyElement(ModelObject *elem); 00115 00121 ModelObject *findElement(const std::string &id); 00122 00127 void enableIdentification(bool id) 00128 { _identify = id; } 00129 00135 std::string generateId(); 00136 00140 void nextId() 00141 { _idAllocator++; } 00142 00147 unsigned currentId() const 00148 { return _idAllocator; } 00149 00150 00152 const std::set<Package *> metamodels() const 00153 { return _metamodels; } 00154 00156 void addMetamodel(Package *pkg) 00157 { _metamodels.insert(pkg); } 00158 00159 private: 00160 typedef std::map<std::string, ModelObject *> IdMap; 00161 00162 bool _identify; 00163 unsigned _idAllocator; 00164 std::string _filename; 00165 std::string _path; 00166 Mode _mode; 00167 std::list<ModelObject *> _elements; 00168 std::set<Package *> _metamodels; 00169 IdMap _idMap; 00170 00171 }; 00172 } 00173 00174 #endif

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