Subclassing C++ View Types
By default, an instance of a dynamic view type is implemented by an object of type IlsMvView. However, you can specify another type. For instance, if you want to
specify that MyView is the C++ type that must implement any instance of the class DepartmentTable, write the following code lines.
Example
view DepartmentTable is MyView
(int lowCost=0,
int highCost=100000):
...
The class MyView must derive from the class IlsMvView, either directly or transitively.
It must declare a specific constructor and use the macro ILS_MVVIEW_DECL in its declaration:
class MyView : public IlsMvView {
public:
MyView(IlsMvComponentItf&,
IlsViewed*,
const IlsMvViewType&,
IlsMvValue*,
int);
...
ILS_MVVIEW_DECL(FilteredView)
};
The source file that implements MyView must include the following macros:
ILS_MVVIEW_BEGIN(MyView,IlsMvView)
...
ILS_MVVIEW_END(MyView)
Between the macros ILS_MVVIEW_BEGIN and ILS_MVVIEW_END, you can define runtime attributes, relations or functions, as for any server runtime type.
A simple implementation of the constructor is:
MyView::MyView(IlsMvComponentItf& i,
IlsViewed* o,
const IlsMvViewType& t,
IlsMvValue* v,
int d)
: IlsMvView(i,o,t,v,d)
{
}
A frequent reason for subtyping the class IlsMvView is to give access to a specific user type. The type IlsMvView is declared as a runtime type with a read-only relation user.
The target of this relation is an object of type IlsMvUser, associated with each component connection on the server side (see the description for the class IlsMvComponentItf in the Rogue Wave® Server Reference Manual). IlsMvUser is a server runtime type.
You may want to subclass IlsMvUser so as to define your application-specific user type by adding runtime attributes, relations and/or functions to those declared on IlsMvUser. This is necessary, for instance, to modify the contents of a representation or the editing rights on a representation with respect to application-specific user data.
In our example, the runtime relation user is redefined for the type MyView, hiding it from the class IlsMvView.
ILS_MVVIEW_BEGIN(MyView,IlsMvView)
ILS_R_RELATION_1(MyView,MyUser,user,getUserRelation,getUserTarget)
ILS_MVVIEW_END(MyView)
Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.