Usage
List of: Discussion Topic
Subjects: Extending ACIS
Contents: Application Development Manual

When defining a new run-time virtual method, as with defining any function, the developer must decide on the name for the method and its arguments. The only restriction for a run-time virtual method is that it must return a logical value indicating whether the operation was supported for the supplied entity type. This implies that any values to be returned by the operation must be passed back through the argument list.

The developer then derives a class from METHOD_ARGS to contain the arguments for the method. Since the major purpose of this class is to provide some compile-time type checking, not encapsulation, it is recommended that all data members be declared public for simplicity. In addition to a constructor, which may be used to provide default parameters for the method, this class must also provide a virtual id class which returns a character string used to provide additional type safety and allow a form of method overloading. The identifier string should match the class name in order to reduce the possibility of conflict with classes generated by other developers. Also, to reduce dependencies between components, it is recommended that all methods for the argument class be defined inline in the .hxx file.

Example 8-14 defines an argument class with all inline methods:

C++ Example

#include "methargs.hxx"

class DL_item;
class SPAtransf;

class SKETCH_ARGS : public METHOD_ARGS
{
public:

DL_item *&result;

int color;

const SPAtransf *transform;


SKETCH_ARGS(DL_item *&res, int col,


const SPAtransf *trans = NULL) :


result(res), color(col), transform(trans) {}


virtual const char *id() const { return "sketch_args"; }
};

Example 8-14. methargs.hxx
PDF/APPDEV/08EXT.PDF
HTM/DATA/ACIS/APPDEV/08EXT/0046.HTM