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

ModelObject.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_MODELOBJECT_HPP 00026 #define OMF_MODELOBJECT_HPP 00027 00028 // std includes 00029 #include <string> 00030 #include <map> 00031 00032 // OMF includes 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 // forward declarations 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

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