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_MODELOBJECT_HPP
00026
#define OMF_MODELOBJECT_HPP
00027
00028
00029
#include <string>
00030
#include <map>
00031
00032
00033
#include <OMF/Object.hpp>
00034
#include <OMF/Types.hpp>
00035
#include <OMF/Exception.hpp>
00036
#include <OMF/Property.hpp>
00037
#include <OMF/Method.hpp>
00038
#include <OMF/Extension.hpp>
00039
#include <OMF/Class.hpp>
00040
#include <OMF/Package.hpp>
00041
00042
namespace OMF
00043 {
00044
00045
class Model;
00046
00061 class ModelObject :
public Object
00062 {
00063
protected:
00065 explicit ModelObject()
00066 {}
00067
00072
ModelObject(
const std::string &mc,
Class *proxy,
Package *decl);
00073
00074
public:
00075
virtual ~ModelObject();
00076
00083
virtual unsigned hashCode() const;
00084
00089 virtual const std::string &typeCode() const;
00090
00092 const std::string
id()
const
00093
{
return _id; }
00094
00100 void setId(
const std::string &
id)
00101 { _id =
id; }
00102
00103
void incRef();
00104
void decRef();
00105
00112
void purge();
00113
00118 ModelObject *
parent()
00119 {
return _parent; }
00120
00129
void setParent(
ModelObject *parent);
00130
00137 Model *
model()
00138 {
return _model; }
00139
00145
void setModel(
Model *model);
00146
00153 const std::vector<Property *> &
propertyList()
const
00154
{
return _propList; }
00155
00157 const std::map<std::string, Property *> &
allProperties()
const
00158
{
return _propMap; }
00159
00166
bool hasProperty(
const std::string &name)
const;
00167
00174
Property *
getProperty(
const std::string &name)
const;
00175
00177
Object *
get(
const std::string &name);
00178
00180
void set(
const std::string &name,
Object *value);
00181
00183
void add(
const std::string &name,
Object *value);
00184
00186
void remove(
const std::string &name,
Object *value);
00187
00189
void clear(
const std::string &name);
00190
00191
00198
void extend(
Extension *ext);
00199
00205
template <
class Type>
00206 void extendWith(
const std::string &name, Type &value)
00207 {
00208
extend(
new BasicExtension<Type>(name, value));
00209 }
00210
00215
template <
class Type>
00216 void extendWith(
const std::string &name)
00217 {
00218
extend(
new BasicExtension<Type>(name));
00219 }
00220
00222
bool hasExtension(
const std::string &name);
00223
00225
Extension *
extension(
const std::string &name);
00226
00228
void removeExtension(
const std::string &name);
00229
00230
00232 Class *
proxy()
00233 {
return _proxy; }
00234
00236 Package *
decl()
00237 {
return _decl; }
00238
00239
protected:
00245
Property &
defProperty(
const std::string &name);
00246
00247
private:
00248
typedef std::vector<Property *> PropertyVector;
00249
typedef std::map<std::string, Property *> PropertyMap;
00250
typedef std::map<std::string, Method *> MethodMap;
00251
typedef std::map<std::string, Extension *> ExtensionMap;
00252
00253
unsigned _refCount;
00254 std::string _id;
00255 PropertyVector _propList;
00256 PropertyMap _propMap;
00257 MethodMap _methMap;
00258 ExtensionMap _extMap;
00259
Model *_model;
00260
Class *_proxy;
00261
Package *_decl;
00262
ModelObject *_parent;
00263 };
00264 }
00265
00266
#endif