IlsDynObject
 
IlsDynObject
Category 
Dynamic modeling class
Inheritance Path 
IlsObject
IlsDynObject
Description 
This class is the default implementation of dynamic objects. Dynamic objects are instance of dynamic classes declared to the runtime model interpreter. The class IlsDynObject provides a structure for the dynamic relations and attributes that have been declared for the dynamic type. This class must be the base class of all static types for which a dynamic subtype has been declared. A dynamic object is not meant to be used before it has been initialized by the member function initObject.
See section “Inheritance from IlsDynobject” in Chapter Dynamic Modeling Services of the Rogue Wave Server User’s Manual for more information on how to declare dynamic types that inherit from static types.
Library 
<dynmvsvr>
Header File
#include <ilserver/dynobj.h>
Synopsis 
class IlsDynObject : public IlsObject
{
public:
IlsDynObject();
Initialization
void initObject(const IlsString& typeNm,
const IlsString& id=IlsString::Null);
virtual void initObject(const IlsObjectType&,
const IlsString& id=IlsString::Null);
virtual void afterInit();
IlsBoolean isInitialized() const;
Object Type
const IlsObjectType* getObjectType() const;
const IlsString& getObjectTypeName() const;
Instantiation
static IlsDynObject* NewInstance
(const IlsString& typeNm,
const IlsString& id=IlsString::Null);
static IlsDynObject* Narrow(const IlsString& typeNm,
IlsViewed& obj);
static IlsDynObject* GetInstance(const IlsString& typeNm,
const IlsString& id);
static IlsBoolean UseDictionary(const IlsString& typeNm);
IlsBoolean isInDictionary() const;
Identifiers
virtual void setKeyIdentifier(const IlsString& id);
virtual IlsString getKeyIdentifier() const;
Attributes
IlsBoolean setAttributeValue(const IlsString& attrNm,
const IlsMvValue& v);
IlsMvValue getAttributeValue(const IlsString& attrNm) const;
IlsDynAttribute* getDynAttribute
(const IlsString& attrNm) const;
static IlsBoolean SetStaticAttributeValue
(const IlsString& typeNm,
const IlsString& attrNm,
const IlsMvValue&);
static IlsMvValue GetStaticAttributeValue
(const IlsString& typeNm,
const IlsString& attrNm);
Relations
IlsViewedRel* getRelation(const IlsRelationDef* rel);
IlsBoolean setRelTarget(const IlsString& relNm,
IlsViewed* obj);
IlsViewed* getRelTarget(const IlsString& relNm);
IlsBoolean insertIntoRel(const IlsString& relNm,
IlsViewed* obj);
IlsBoolean extractFromRel(const IlsString& relNm,
IlsViewed* obj);
virtual IlsViewed* getElementFromRel(const IlsRelationDef* rel,
const IlsString& id);
IlsViewed* getElementFromRel(const IlsString& relNm,
int index) const;
virtual IlsViewed* getElementFromRel
(const IlsRelationDef* rel,
int index) const
virtual IlsBoolean isElementInRel(const IlsRelationDef* rel,
IlsViewed& target);
IlsDynRelation* getDynRelation(const IlsString& relNm) const;
Dynamic Views
virtual IlsBoolean beginEdition(IlsMvView&,IlsRpUpdateType);
virtual IlsBoolean endEdition(IlsMvView&,
IlsRpUpdateType,
IlsBoolean isRollback);
Others
virtual IlsMvValue callFunction(const IlsString& funcName,
IlsMvValue* args,
int nbParam,
IlsBoolean chkErr=IlsTrue);
virtual void cut(ILS_CUT_DIRECTIVE d=ILS_ALL);
 
protected
void removeFromDictionary();
void beforeRename(const IlsString& oldId,
const IlsString& newId);
void afterRename(const IlsString& oldId,
const IlsString& newId);
};
Constructor 
IlsDynObject();
This constructeur builds a new dynamic object. However, it does not initialized it. To initialize the new dynamic object, you must call the member function initObject on it.
Member Functions 
Initialization
void initObject(const IlsString& typeNm,
const IlsString& id=IlsString::Null);
This member function initializes a dynamic object whose type is typeNm. See the virtual function initObject documented hereafter.
[virtual] void initObject(const IlsObjectType&,
const IlsString& id=IlsString::Null);
This virtual member function must be called just after an object of type IlsDynObject (or of a subclass) has been created. This function has the following effects:
1. It initializes the internal state of the dynamic object.
2. It initializes the identifier attribute if such an attribute has been declared and if the argument id is not null.
3. Finally, it calls the virtual member function afterInit, documented below.
[virtual] void afterInit();
This virtual member function is called just after the dynamic object has been initialized. By default, this function calls the Rogue Wave Script callback afterInit if it exists.
IlsBoolean isInitialized() const;
This member function returns IlsTrue if the dynamic object has been initialized. A dynamic object must be initialized by a call to the function initObject before it can be manipulated.
Object Type
const IlsObjectType* getObjectType() const;
This member function returns the type associated with the dynamic object.
const IlsString& getObjectTypeName() const;
This member function returns the name of the type for the dynamic object.
Instantiation
[static] IlsDynObject* NewInstance(const IlsString& typeNm,
const IlsString& id=IlsString::Null);
This static member function instantiates a dynamic object of the dynamic type typeNm. If the dynamic object is an identified object (in other words, if an identifier attribute has been declared for this type), the identifier is assigned by the id argument.
If the dynamic type inherits from a static type, the type of the instantiated object will be the first static type found in the inheritance path. If there is no static type in the inheritance path, the member function IlsDynObjectFactory::newInstance is called to create a new dynamic object.
This function initializes the dynamic object by calling the function initObject after instantiation.
[static] IlsDynObject* Narrow(const IlsString& typeNm, IlsViewed& obj);
This static member function performs a safe cast from an IlsViewed object to an instance of IlsDynObject if the object is a dynamic object and its dynamic type is typeNm or a subtype.
[static] IlsDynObject* GetInstance(const IlsString& typeNm,const IlsString& id);
This static member function retrieves an instance of the dynamic object that has been registered with the name id into the dictionary associated with the dynamic type. If the useDictionary property has been specified for the dynamic type, this type holds a dictionary and stores each instance in it. If the type does not hold any dictionary, the function looks up in a superclass for the instance.
[static] IlsBoolean UseDictionary(const IlsString& typeNm);
This static member function returns IlsTrue if the corresponding dynamic type holds a dictionary.
IlsBoolean isInDictionary() const;
This member function returns IlsTrue if the object is stored in a dictionary. See also the protected member function removeFromDictionary.
Identifiers
[virtual] void setKeyIdentifier(const IlsString& id);
This virtual member function assigns the value of the identifier attribute that has been declared to the server model interpreter. This function registers the object to the dynamic dictionary, if any, and calls the beforeRename and afterRename functions.
[virtual] IlsString getKeyIdentifier() const;
This virtual member function returns the value of the identifier attribute, if this identifier has been declared for the corresponding attribute type. Otherwise, it returns the null string. This function is invoked when an object is stored in a dynamic set relation.
Note: Set relations can store only identified objects.
Attributes
IlsBoolean setAttributeValue(const IlsString& attrNm,
const IlsMvValue& v);
This member function assigns the value v to the attribute identified by the attrNm parameter. This function returns IlsFalse if the attribute does not belong to the associated type or if the value cannot be assigned.
IlsMvValue getAttributeValue(const IlsString& attrNm) const;
This member function retrieves the value of the attribute attrNm for this dynamic object. The returned value is void if the value cannot be retrieved.
IlsDynAttribute* getDynAttribute(const IlsString& attrNm) const;
This member function returns the dynamic attribute attrNm or 0 if this attribute does not exist.
[static] IlsBoolean SetStaticAttributeValue(const IlsString& typeNm,
const IlsString& attrNm,
const IlsMvValue&);
This static member function sets the value of the static attribute attrNm for the dynamic type typeNm. Note that changing a static attribute does not trigger any notification. This function returns IlsTrue if the attribute value has been assigned.
[static] IlsMvValue GetStaticAttributeValue(const IlsString& typeNm,
const IlsString& attrNm);
This static member function retrieves the value of the static attribute attrNm for the dynamic type typeNm.
Relations
IlsViewedRel* getRelation(const IlsRelationDef* rel);
This member function returns the implementation of the dynamic relation rel.
IlsBoolean setRelTarget(const IlsString& relNm,
IlsViewed* obj);
This member function assigns the target of the dynamic unary relation relNm. It returns IlsFalse if the target cannot be set.
IlsViewed* getRelTarget(const IlsString& relNm);
This member function returns the target of the dynamic unary relation relNm.
IlsBoolean insertIntoRel(const IlsString& relNm,
IlsViewed* obj);
This member function inserts a new target in the dynamic n-ary relation relNm. The function returns IlsFalse if the target cannot be added.
IlsBoolean extractFromRel(const IlsString& relNm,
IlsViewed* obj);
This member function extracts (and removes) the target obj from the dynamic n-ary relation relNm. The function returns IlsFalse if the target cannot be extracted.
[virtual] IlsViewed* getElementFromRel(const IlsRelationDef* rel,
const IlsString& id);
This virtual member function retrieves the first object identified by the argument id from the relation identified by the rel argument.
*If the relation is dynamic, this method calls the member function IlsDynRelation::getElement to retrieve the identified element.
*If the relation is static, this method calls the member function IlsViewedRel::getIdentifiedElement.
You can override this method to retrieve relation elements in your own subclass of IlsDynObject.
IlsViewed* getElementFromRel(const IlsString& relNm, int index) const;
This member function returns the element located at position index in relation relNm. This function returns null if index is greater than the length of the relation.
[virtual] IlsViewed* getElementFromRel(const IlsRelationDef* rel,
int index) const;
This virtual member function returns the element located at position index in the relation identified by rel. This function returns null if index is greater than the length of the relation.
[virtual] IlsBoolean isElementInRel(const IlsRelationDef* rel,
IlsViewed& target);
This virtual member function returns IlsTrue if the target is in the relation. Its behavior depends on whether the relation is dynamic or static.
*If the relation is dynamic, this method calls the member function IlsDynRelation::hasTarget.
*If the relation is static, this method calls the member function IlsViewedRel::hasElement.
IlsDynRelation* getDynRelation(const IlsString& relNm) const;
This member function returns the dynamic relation relNm or 0 if this relation does not exist.
Dynamic Views
[virtual] IlsBoolean beginEdition(IlsMvView&,IlsRpUpdateType);
[virtual] IlsBoolean endEdition(IlsMvView&,
IlsRpUpdateType,
IlsBoolean isRollback);
These virtual member functions are overriden from the parent class IlsObject. They invoke the corresponding Rogue Wave Views Script methods if they exist.
Others
[virtual] IlsMvValue callFunction(const IlsString& funcName,
IlsMvValue* args,
int nbParam,
IlsBoolean chkErr=IlsTrue);
This virtual member function invokes the function funcName with its arguments. When the chkErr argument is set to IlsTrue, an error message is generated if the Script implementation of this function is not found. Rogue Wave Server will search for a Script function named <object type name>_<funcName>.
[virtual] void cut(ILS_CUT_DIRECTIVE d=ILS_ALL);
This virtual member function calls the Rogue Wave Views Script callback onCut if exist and calls the base-class method if onCut returns IlsTrue.
Protected Member Functions 
void removeFromDictionary();
This protected member function removes a dynamic object from its dynamic dictionary, if such a dictionary exists.
void beforeRename(const IlsString& oldId, const IlsString& newId);
This protected member function must be called from a subtype before the object identifier is renamed. See section “Identified Objects” in Chapter Dynamic Modeling Services, in the Rogue Wave Server User’s Manual.
void afterRename(const IlsString& oldId, const IlsString& newId);
This protected member function must be called from a subtype after the object identifier has been renamed.
See Also 
IlsDynAttribute, IlsDynModelInterpreter, IlsDynObjectFactory, IlsDynRelation

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.