IlsEntity
 
IlsEntity
Category 
Modeling class
Inheritance Path 
IlsRefCounted
IlsViewed
IlsEntity
Description 
The class IlsEntity is a base class for classes declaring server data members: derived data members, entry data members, and relations. Instances of a class deriving from IlsEntity can be the target of a use relation, but cannot be the target of an ownership relation. This rule will be enforced at compile time.
Library 
<server>
Header File 
#include <ilserver/model.h>
Synopsis 
class IlsEntity
{
public:
IlsEntity(IlsIdentifier identifier,
IlsActivity activity=IlsModel::GetDefaultActivity());
IlsEntity(IlsEntity& rhs);
virtual ~IlsEntity();
IlsActivity getActivity() const;
Identifiers
IlsIdentifier getIdentifier();
void rename(IlsIdentifier);
Cutting Relations
virtual void cut(ILS_CUT_DIRECTIVE=ILS_ALL);
Notification
IlsBoolean isIdentifierModified();
IlsIdentifier getOldIdentifier();
IlsBoolean remove();
IlsBoolean areUsersModified();
Locking Entities
virtual IlsBoolean lock();
virtual IlsBoolean unlock();
virtual IlsBoolean trylock();
virtual IlsBoolean isUpdateAllowed();
};
Constructors 
IlsEntity(IlsIdentifier identifier,
IlsActivity activity=IlsModel::GetDefaultActivity());
As its first argument, the constructor of an entity takes an identifier of type IlsIdentifier. This identifier behaves like an instance of IlsString and thus, like a character string. The identifier is stored in IlsEntity. Consequently, you just have to pass the identifier to the constructor of IlsEntity when deriving from this class.
The argument activity specifies whether the entity is active or not. An entry is active if its modification sets off the recomputation of derived data members. The default value is the one returned by the static member function IlsModel::GetDefaultActivity, which is ILS_INACTIVE by default.
IlsEntity(IlsEntity& rhs);
This is the copy constructor of the class. The identifier is copied as well.
Destructor 
virtual ~IlsEntity();
This is the virtual destructor of IlsEntity.
Member Functions 
IlsActivity getActivity() const;
This function returns ILS_ACTIVE if the entity has been set as active. Otherwise, it returns ILS_INACTIVE. For details, see the constructor.
Identifiers
IlsIdentifier getIdentifier();
This member function returns the identifier stored in the class IlsEntity. Thus, you do not have to store this identifier in the derived type.
void rename(IlsIdentifier);
This member function renames the identifier stored in the class IlsEntity.
This function automatically maintains consistency in the dictionary containing the entity.
This function throws the following exceptions:
*IlsUpdateForbidden if the function isUpdateAllowed returns IlsFalse.
*IlsAlreadyInDictionary if the identifier passed as its argument is already
contained in one of the dictionaries storing the entity.
Cutting Relations
[virtual] void cut(ILS_CUT_DIRECTIVE=ILS_ALL);
This virtual member function cuts all the relations of which the entity is the target. The argument supplied to this function is an enumerated type that provides the following three values:
*ILS_ALL cuts all relations;
*ILS_USE cuts use relations only. In the case of an entity, this value is equivalent
to ILS_ALL;
*ILS_OWNERSHIP cuts the ownership relation. This value does not apply to an entity.
This function throws the exception IlsUpdateForbidden if the function isUpdateAllowed, described below, returns IlsFalse.
Notification
IlsBoolean isIdentifierModified();
During a notification phase, this member function returns IlsTrue if the entity identifier has been modified since the last notification phase.
IlsIdentifier getOldIdentifier();
During a notification phase, this member function returns the old identifier of the entity. It returns a null smart pointer if the entity has not been modified since the last notification phase.
IlsBoolean remove();
This member function overrides the function IlsViewed::remove. It removes the entity from each dictionary in which it is stored. Then, it calls the cut function and notifies components that the entity is to be deleted. This function always returns IlsTrue.
IlsBoolean areUsersModified();
During a notification phase, this function returns IlsTrue if a use relation has been added or removed since the last notification phase.
Locking Entities
These functions return IlsFalse by default. They are meant to be overridden.
[virtual] IlsBoolean lock();
This virtual member function locks the entity, and returns IlsTrue once the entity is locked.
[virtual] IlsBoolean unlock();
This virtual member function unlocks the entity and returns IlsTrue once the entity is unlocked.
[virtual] IlsBoolean trylock();
This virtual member function tries to lock the entity. It returns IlsFalse if the operation fails.
[virtual] IlsBoolean isUpdateAllowed();
By default, this virtual member function returns IlsFalse when the entity is locked and IlsTrue if you have the right to modify the entity. It is called if the static member function IlsModel::SetUpdateChecked returns IlsTrue.
See Also 
Exceptions, IlsDerived, IlsEntry, IlsIdentifier, IlsModel, IlsObject, IlsOwns, IlsOwnsDynamicArray, IlsOwnsFixedArray, IlsOwnsList, IlsOwnsSet, IlsString, IlsUses, IlsUsesDynamicArray, IlsUsesFixedArray, IlsUsesList, IlsUsesSet, IlsViewed

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