AlCommand
 
 
 

Encapsulates the user defined interface to command history.

Synopsis

#include <AlCommand.h>
class AlCommand : public AlObject
AlCommand();
virtual	~AlCommand();
virtual statusCode	deleteObject();
virtual AlObjectType	type() const;
statusCode	create( const char *name );
statusCode	install();
statusCode	uninstall();
statusCode	modified();
int	execute( boolean freeIfInvalid = TRUE );
int	undo( boolean freeIfInvalid = TRUE );
AlSurfaceType	surfaceType() const;
statusCode	setSurfaceType( AlSurfaceType );
AlUserCommand*	userCommand();
int	status() const;
static statusCode	setDebug( boolean on );
static statusCode	add( AlUserCommandAlloc *, const char *name );
static statusCode	remove( const char *name );

Description

This file contains the definitions required to define an user command history command.

The command layer in Alias is a software layer that is between the user interface and the main application. A command is an object that represents actions such as: fillet, square, or patch.

The user interface code builds commands that are sent through the layer to be executed. The user interface does not create geometry itself, it creates commands that do it.

Commands can be saved somewhere and re-executed whenever the system feels it is necessary. As long as the data the command depends upon is valid, the command remains valid.

The most practical application of re-executing a command is the generation of data from a piece of source geometry. When the original geometry changes, the new model can be ’automatically’ created by re-executing the command history on the new data.

Command functions: These are outlined in the AlUserCommand class.

A ‘constructor’ DAG node is considered to be a DAG node which creates the result. An example of a constructor is one of the original curves in a fillet operation.

A ‘target’ DAG node is considered to be the result of a command operation. An example is the fillet created by the fillet command.

The ’AlCommand’ class is used to maintain a list of the current plug-in defined command history commands. New commands are installed using the ’AlCommand::add’ method. This associates a string with a function that allocates a new copy of a command. The first parameter of the add command is a AlUserCommandAlloc. An AlUserCommandAlloc is a pointer to a function returning an AlUserCommand class as defined below.

typedef AlUserCommand *AlUserCommandAlloc(); 

AlCommand::remove is used to remove a command type from the database.

AlCommand::create is used to create an new copy of the command. After a command has been created, its data fields can be accessed using the ’AlCommand->userCommand’ method.

A command has two components, the UI driver and the underlying geometry manipulation code. The UI creates a new command using AlCommand::create. The private data is accessed using the AlCommand -> userCommand method (which is typecast to the plug-in’s derived command). From this, the command data structure’s fields can be filled in. The UI uses the execute method to call the userCommand’s execute command. This does the actual command. Finally the result is added to the Alias system using the ’install’ method.

The Alias messaging system will call the various functions in the command to maintain the dependencies and re-execute the command if necessary.

statusCode AlCommand::setDebug( boolean on )

Description

Turns command history debugging on (TRUE) or off (FALSE). Alias will write information into the errlog as the construction history plug-in runs if this boolean is set.

Arguments

< on - the new value of command history debugging

Return Codes

sSuccess - setting worked

AlCommand::AlCommand()

Description

Constructor for a command wrapper.

AlCommand::~AlCommand()

Description

Destructor for a command wrapper.

AlObjectType AlCommand::type() const

Description

Returns kCommandType.

AlCommand *AlCommand::asCommandPtr()

Description

Safe downcast to AlCommand.

AlUserCommand *AlCommand::userCommand()

Description

Returns a pointer to the user command.

int AlCommand::status() const

Description

Returns the value of the result from the last execution of the command. Returns -1 if this command is invalid.

statusCode AlCommand::create( const char *name )

Description

Allocates a new user defined command history command.

Arguments

< name - the name of the command to create

Return Codes

sSuccess - method was successful

sInvalidArgument - name was NULL

sObjectNotFound - the command name was not found (undefined)

sFailure - not enough memory or user constructor failure

statusCode AlCommand::deleteObject()

Description

Deletes the command (also calls the user command destructor)

Return Codes

sSuccess - the command was deleted

sInvalidObject - the command was invalid

AlSurfaceType AlCommand::surfaceType() const

Description

Gets the type of surface produced by the given command.

statusCode AlCommand::modified()

Description

Marks this command as being modified.

Return Codes

sInvalidObject - the command was invalid

sSuccess - the command was marked as being modified

statusCode AlCommand::setSurfaceType( AlSurfaceType type )

Description

Sets the type of surface produced by the given command.

Arguments

< type - type of surface to be produced by the given command

Return Codes

sSuccess - setting was successful

sInvalidArgument - type was neither kSurfaceSpline nor kSurfacePolyset

sInvalidObject - the command was invalid

statusCode AlCommand::install()

Description

Installs a command in the construction history list.

Return Codes

sInvalidObject - the command was invalid

sSuccess - the command was installed

sFailure - the command was already installed

statusCode AlCommand::uninstall()

Description

Remove a command from the construction history list.

Return Codes

sInvalidObject - the command was invalid

sSuccess - the command was uninstalled

sFailure - the command was not installed

int AlCommand::execute( boolean freeIfInvalid )

Description

Executes the command after it has been created. Do not directly call the execute command in the user command, but use this function instead.

Arguments

< freeIfInvalid - the command is freed if it is found to be invalid

Return Values

zero - command was successful

negative number - the command is no longer valid

positive number - the command did not succeed (the number returned is the error return value)

int AlCommand::undo( boolean freeIfInvalid )

Description

Undoes the command after it has been created. Do not directly call the undo command in the user command, but use this function instead.

Arguments

< freeIfInvalid - the command is freed if it is found to be invalid

Return Values

zero - command was successful

negative number - the command is no longer valid

positive number - the command did not succeed (the number returned is the error return value)

statusCode AlCommand::add( AlUserCommandAlloc *func, const char *name )

Description

Adds the construction history command to the list of available commands.

Arguments

func - name of the function that will allocate the new AlUserCommand

name - string name of the function

Return Codes

sFailure - another command with the same name already exists

sInvalidArgument - func is NULL or name is NULL

sInsufficientMemory - could not allocate memory for new function

sSuccess - the add was successful

statusCode AlCommand::remove( const char *name )

Description

Deletes the construction history command.

Arguments

name - string name of the function

Return Codes

sFailure - command not found

sInvalidArgument - name is NULL

sSuccess - command was removed