Dynamic View Services > Defining Runtime Access to the Server Model > Declaring Model Classes > Extended Macros
 
Extended Macros
For Classes with Identifiers
Rogue Wave® Server provides a specific set of macros for the runtime declaration of server classes that have a specific runtime identifier attribute.
When used for an entity class, these macros allow you to define your own accessors and modifiers for the identifier, as shown in the following code sample from the file company.h:
class Project: public IlsEntity{
IlsBoolean setIdentifier(IlsString id);
...
ILS_OBJECT_DECL(Project)
};
In the code sample below, ident is declared as the identifier attribute for Project in the file company.C:
#include <company.h>
 
ILS_OBJECT_WITH_ID_BEGIN(Project,ident)
ILS_RW_ATTRIBUTE_STRING(Project,ident,getIdentifier,setIdentifier,
isIdentifierModified)
...
ILS_OBJECT_END(Project)
The macro ILS_RW_ATTRIBUTE_STRING declares the runtime attribute ident, registers this attribute with the server model interpreter by means of the functions IlsEntity::getIdentifier and IlsEntity::isIdentifierModified, and of the user-defined accessor setIdentifier.
You can also use the macro ILS_OBJECT_WITH_ID_BEGIN to declare an object class derived from IlsObject. Do so when you want to associate a constructor with an identifier argument instead of the default constructor. See “Collectors”. for information on how this constructor is called by Rogue Wave Server.
For Class Hierarchy
When a server object class directly inherits from another server class, the derived class should be declared using a specific BEGIN macro that specifies the parent type. In the code sample below, for instance, the class Manager, which derives from the class Employee, is declared to the server model interpreter as follows:
*In the header file company.h:
class Manager: public Employee {
...
ILS_OBJECT_DECL(Manager)
};
*In the source file company.cpp:
ILS_OBJECT1_BEGIN(Manager,Employee)
...
ILS_OBJECT_END(Manager)
The parent type should be declared as a runtime type, like the class Employee. This macro causes each runtime attribute, relation or function of the runtime type Employee to be inherited by the runtime type Manager, except if it is hidden by a Manager attribute, relation or function with the same name. The macro also declares a narrowing function for Manager. The following code illustrates the use of the Employee and Manager narrowing functions on a Manager object:
Manager& m=...;
   IlsViewed& v=m;
     Employee* ep=Employee::Narrow(v);
     Manager* mp=Manager::Narrow(v);
      assert(ep==&m);
      assert(mp==&m);
See the Rogue Wave Server Reference Manual for information on other macros that allow:
*multiple inheritance, such as ILS_OBJECT2_BEGIN;
*inheritance of entities, such as ILS_ENTITY1_BEGIN;
*or object classes with an associated identifier attribute, such as ILS_OBJECT1_WITH_ID_BEGIN.

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