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

OMF::ModelObject Class Reference

#include

Inheritance diagram for OMF::ModelObject:

OMF::Object Model::ModelElement Model::MultiplicityType UML::Element UML::ElementImport UML::ElementResidence UML::Expression UML::Multiplicity UML::MultiplicityRange UML::TemplateArgument UML::TemplateParameter List of all members.

Detailed Description

The ModelObject class is the base class of any class destined to be instantiated as part of the model. It also provides a common grouping for such objects. This class also contains an interface for reference counting. We use reference counting as a simple garbage collection technique to help avoid dangling references.

The ModelObject class acts as a replacement for the standard MOF reflective capabilities. This is because we aren't actually bootstrapping the implementation, but building it from the ground up. Had we chosen otherwise, we could use a true MOF class as the base for all modeling objects.


Public Member Functions

virtual  ~ModelObject ()
virtual unsigned  hashCode () const
virtual const std::string &  typeCode () const
const std::string  id () const
void  setId (const std::string &id)
void  incRef ()
void  decRef ()
void  purge ()
ModelObject parent ()
void  setParent (ModelObject *parent)
Model *  model ()
void  setModel (Model *model)
const std::vector< Property * > &  propertyList () const
const std::map< std::string,
Property * > & 
allProperties () const
bool  hasProperty (const std::string &name) const
Property *  getProperty (const std::string &name) const
Object get (const std::string &name)
void  set (const std::string &name, Object *value)
void  add (const std::string &name, Object *value)
void  remove (const std::string &name, Object *value)
void  clear (const std::string &name)
void  extend (Extension *ext)
template void  extendWith (const std::string &name, Type &value)
template void  extendWith (const std::string &name)
bool  hasExtension (const std::string &name)
Extension *  extension (const std::string &name)
void  removeExtension (const std::string &name)
Class *  proxy ()
Package *  decl ()
ModelObject metaObject ()

Protected Member Functions

  ModelObject ()
  ModelObject (const std::string &mc, Class *proxy, Package *decl)
Property &  defProperty (const std::string &name)

Constructor & Destructor Documentation

OMF::ModelObject::ModelObject  )  [explicit, protected]
 

Never, ever used.

OMF::ModelObject::ModelObject const std::string &  mc,
Class *  proxy,
Package *  decl
[protected]
 

Default constuctor. Requires a fully qualified metaclass name, a proxy and a package.

virtual OMF::ModelObject::~ModelObject  )  [virtual]
 


Member Function Documentation

void OMF::ModelObject::add const std::string &  name,
Object value
 

Add the value of a named property.

const std::map<:string property>& OMF::ModelObject::allProperties  )  const
 

Return all properties.

void OMF::ModelObject::clear const std::string &  name  ) 
 

Clear the value of a named property.

Package* OMF::ModelObject::decl  ) 
 

Returns package that declares this class of this object.

void OMF::ModelObject::decRef  ) 
 

Property& OMF::ModelObject::defProperty const std::string &  name  )  [protected]
 

Provided so derived classes can add properties. This returns the newly allocated property object so it can be altered in a chained method x().y().z().

void OMF::ModelObject::extend Extension *  ext  ) 
 

Extend the object with a new property. This entails the external construction of the extension that will be used by the model object. This is more useful for specialized extensions.

template
void OMF::ModelObject::extendWith const std::string &  name  ) 
 

This method is like the above, but the caller does not need a default value for the extension.

template
void OMF::ModelObject::extendWith const std::string &  name,
Type &  value
 

This method is much like the first but internalizes the construction of the extension element. It uses the basic extension class and wraps the given value.

Extension* OMF::ModelObject::extension const std::string &  name  ) 
 

Get the named extension property.

Object* OMF::ModelObject::get const std::string &  name  ) 
 

Get a named property of the object.

Property* OMF::ModelObject::getProperty const std::string &  name  )  const
 

This method is used to return the property object for the requested name. This can be useful if the client needs to test some of the capabilities of the property prior to manipulating it.

bool OMF::ModelObject::hasExtension const std::string &  name  ) 
 

Does the object support a named extension?

virtual unsigned OMF::ModelObject::hashCode  )  const [virtual]
 

Hash codes for model objects are the integer representation of the this pointer. The pointer value is actually the identity of the object, so it seems like a good solution for hashing.

Implements OMF::Object.

bool OMF::ModelObject::hasProperty const std::string &  name  )  const
 

This method is used to query whether or not a property is actually defined for this object. Note that we can't just test using get because the property may exist, but be a null pointer.

const std::string OMF::ModelObject::id  )  const
 

Return the id of this object. Can be empty.

void OMF::ModelObject::incRef  ) 
 

ModelObject* OMF::Object::metaObject  )  [inherited]
 

Return the meta-object of this instance. The meta-object is an instance of the metaclass of this object. For example, the metaclass of UML::Attribute is Model::Class. The metaobject for an instance of UML::Attribute is an instance of Model::Class.

This method may force a load of an entire metamodel in order to return the correct object.

Model* OMF::ModelObject::model  ) 
 

Return the model that owns this object.Note that this method can return null... in the case where this happens, we're really dealing with fragments of models. However, inserting the fragment into a model will resolve the ownership of the element.

ModelObject* OMF::ModelObject::parent  ) 
 

Return the owner of this object or - the parent in the containment tree (after which the method is named).

Reimplemented in UML::Generalization.

const std::vector& OMF::ModelObject::propertyList  )  const
 

Return a list of properties (ordered by definition). This method shouldn't really be used. It's kind of a hack that's been added to support XMI 1.2 field referencing for structure types.

Class* OMF::ModelObject::proxy  ) 
 

Get the class proxy for this model object.

void OMF::ModelObject::purge  ) 
 

The purge method is a work-around for cases where the object must be deleted immediately (such as composite aggregation). This method deletes this object. Do not refer to it after calling this method.

void OMF::ModelObject::remove const std::string &  name,
Object value
 

Remove a value from a named property.

void OMF::ModelObject::removeExtension const std::string &  name  ) 
 

Remove the named extension.

void OMF::ModelObject::set const std::string &  name,
Object value
 

Set the value of a named property.

void OMF::ModelObject::setId const std::string &  id  ) 
 

Never, ever call this method. It is used internally by this class and the Model class to set the ids for objects that are used during serialization.

void OMF::ModelObject::setModel Model *  model  ) 
 

This method should only ever be called from within the model class and only when a new top-level object is assigned to the model.

void OMF::ModelObject::setParent ModelObject parent  ) 
 

Set the parent in the containment tree. Note that this method should only ever be called by a reference mutator. It should not be the job of the client to manage containment relations. This method will recursively set the model for all owned elements of this object to the model of the owning object. It will also reallocate ids (if the parent has a model).

virtual const std::string& OMF::ModelObject::typeCode  )  const [virtual]
 

The typecode of a model object is the name of the model object's class.

Implements OMF::Object.


The documentation for this class was generated from the following file:
Generated on Fri Sep 10 13:07:38 2004 for OpenModelingFramework by 1.3.8