00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#ifndef OMF_MODEL_HPP
00026
#define OMF_MODEL_HPP
00027
00028
00029
#include <string>
00030
#include <list>
00031
#include <set>
00032
#include <map>
00033
00034
namespace OMF
00035 {
00036
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