Aimsun Next Scripting: GKCommand Class Reference
Aimsun Next Scripting  22
Public Member Functions | Public Attributes | List of all members
GKCommand Class Referenceabstract
Inheritance diagram for GKCommand:
DetectorLocationNewCmd DistributionExperimentNewCmd DistributionScenarioNewCmd FourStepsExperimentNewCmd FourStepsScenarioNewCmd GKDetectionPatternNewCmd GKDistributionCentroidTypeNewCmd GKDistributionDataSetNewCmd GKDynamicAdjustmentExperimentNewCmd GKDynamicAdjustmentExperimentResultNewCmd GKDynamicAdjustmentReplicationNewCmd GKGenerationAttractionCentroidTypeNewCmd GKGenerationAttractionDataSetAttributeNewCmd GKGenerationAttractionDataSetNewCmd GKGenerationAttractionExperimentNewCmd GKGenerationAttractionScenarioNewCmd GKGenerationAttractionVectorNewCmd GKParkingCentroidTypeNewCmd GKPedestrianAreaNewCmd GKPedestrianCentroidConfigurationNewCmd GKPedestrianDecisionNodeNewCmd GKPedestrianEntranceCentroidNewCmd GKPedestrianExitCentroidNewCmd GKPedestrianLevelChangeObjectNewCmd GKPedestrianODMatrixNewCmd GKPedestrianODRouteNewCmd GKPedestrianObstacleNewCmd GKPedestrianPolygonObstacleNewCmd GKPedestrianServicePointNewCmd GKPedestrianTypeNewCmd GKPrintLayoutNewCmd GKTimePeriodNewCmd GKTrafficProfileNewCmd GRotationCmd GTranslationCmd MacroAdjustmentExperimentNewCmd MacroAdjustmentScenarioNewCmd MacroDepartureAdjustmentExperimentNewCmd MacroDepartureAdjustmentScenarioNewCmd MacroExperimentNewCmd MacroPTAdjustmentExperimentNewCmd MacroPTAdjustmentScenarioNewCmd MacroPTExperimentNewCmd MacroPTScenarioNewCmd MacroPTZoneNewCmd MacroPTZonePlanNewCmd MacroScenarioNewCmd ModalSplitExperimentNewCmd ModalSplitScenarioNewCmd

Public Member Functions

 if (base)
 
Py_END_ALLOW_THREADS End GKCommand ()
 
void setName (const QString &)
 
const QString & getName () const
 
void setModel (GKModel *)
 
GKModelgetModel () const
 
virtual GKCommandReportinit (GKModel *)
 
virtual bool isEqual (GKCommand *) const
 
virtual void merge (GKCommand *)
 
virtual void doit ()=0
 
virtual void undoit ()=0
 
void setUndoable (bool)
 
bool isUndoable () const
 
bool isDone () const
 
virtual void setDone (bool)
 
virtual void commandToBeDone ()
 
virtual void commandDone ()
 
virtual void commandToBeUndone ()
 
virtual void commandUndone ()
 
virtual GKObjectcreatedObject () const
 
virtual bool createdObjectRequiresEdition () const
 
virtual QVector< int > getTargets () const
 

Public Attributes

ConvertToSubClassCode Py_BEGIN_ALLOW_THREADS GKCommandbase = (GKCommand*)sipCpp
 
 sipType = 0
 

Detailed Description

A command is an operation that the user can undo (and then redo). Any change in any object in Aimsun due to user manipulation must be done in a command (with the exception of edition done in the editors. See GEditor for more information on this topic).

The developer, when writes a command, will:

The developer can also implement the GKCommand::init method to verify if the operation can be executed or not.

Optionally the developer can implement also the GKCommand::isEqual and GKCommand::merge methods. See GKCommander for more information.

In Aimsun there are three types of commands:

Delete commands are handle by a specialized class, not derived from GKCommand but from GKObjectDelCmd.

Deleting an object with the C++ delete operator

When an object is created using a command it has to be deleted (using the delete operator) if the command is deleted and the command was undone. The commander deletes a command either when no longer the undo operation is possible or when the model is closed.

An example follows:

GKSectionReportNewCmd::~GKSectionReportNewCmd()
{
// If the command is not done (was created but the user selects UNDO) then
// the object must be deleted.
if( isDone() == false ){
delete obj;
}
}
bool isDone() const
See also
GKObjectDelCmd, GKCommander, GKModel, GEditor

Constructor & Destructor Documentation

◆ GKCommand()

Py_END_ALLOW_THREADS End GKCommand::GKCommand ( )

Member Function Documentation

◆ commandDone()

virtual void GKCommand::commandDone ( )
virtual

Called after do command.

◆ commandToBeDone()

virtual void GKCommand::commandToBeDone ( )
virtual

Called before do command.

◆ commandToBeUndone()

virtual void GKCommand::commandToBeUndone ( )
virtual

Called before undo command.

◆ commandUndone()

virtual void GKCommand::commandUndone ( )
virtual

Called after undo command.

◆ createdObject()

virtual GKObject * GKCommand::createdObject ( ) const
virtual

Created object for New Commands (once the command has been added to the GKCommander via the addCommand function).

Reimplemented in GKDetectionPatternNewCmd, DistributionExperimentNewCmd, DistributionScenarioNewCmd, FourStepsExperimentNewCmd, FourStepsScenarioNewCmd, GKPedestrianAreaNewCmd, GKPedestrianCentroidConfigurationNewCmd, GKPedestrianDecisionNodeNewCmd, GKPedestrianEntranceCentroidNewCmd, GKPedestrianExitCentroidNewCmd, GKPedestrianLevelChangeObjectNewCmd, GKPedestrianODMatrixNewCmd, GKPedestrianODRouteNewCmd, GKPedestrianServicePointNewCmd, GKPedestrianTypeNewCmd, GKDynamicAdjustmentExperimentNewCmd, GKDynamicAdjustmentExperimentResultNewCmd, GKDynamicAdjustmentReplicationNewCmd, GKDistributionCentroidTypeNewCmd, GKDistributionDataSetNewCmd, GKGenerationAttractionCentroidTypeNewCmd, GKGenerationAttractionDataSetAttributeNewCmd, GKGenerationAttractionDataSetNewCmd, GKGenerationAttractionExperimentNewCmd, GKGenerationAttractionScenarioNewCmd, GKGenerationAttractionVectorNewCmd, GKParkingCentroidTypeNewCmd, GKTimePeriodNewCmd, MacroAdjustmentExperimentNewCmd, MacroAdjustmentScenarioNewCmd, MacroDepartureAdjustmentExperimentNewCmd, MacroDepartureAdjustmentScenarioNewCmd, MacroExperimentNewCmd, MacroScenarioNewCmd, MacroPTExperimentNewCmd, MacroPTScenarioNewCmd, MacroPTZoneNewCmd, MacroPTZonePlanNewCmd, DetectorLocationNewCmd, ModalSplitExperimentNewCmd, ModalSplitScenarioNewCmd, GKPrintLayoutNewCmd, MacroPTAdjustmentExperimentNewCmd, MacroPTAdjustmentScenarioNewCmd, and GKTrafficProfileNewCmd.

◆ createdObjectRequiresEdition()

virtual bool GKCommand::createdObjectRequiresEdition ( ) const
virtual

A object created by a new command requires edition to be customized? True only for objects that cannot be created in a valid state.

◆ doit()

virtual void GKCommand::doit ( )
pure virtual

Do not use this function. Available just for compatibility issues.

Implemented in GRotationCmd, GTranslationCmd, GKDetectionPatternNewCmd, GKDetectionPatternTemplateNewCmd, OCITDetectionPatternNewCmd, OCITDetectionPatternTemplateNewCmd, DistributionExperimentNewCmd, DistributionScenarioNewCmd, FourStepsExperimentNewCmd, FourStepsScenarioNewCmd, GKPedestrianAreaNewCmd, GKPedestrianCentroidConfigurationNewCmd, GKPedestrianDecisionNodeNewCmd, GKPedestrianEntranceCentroidNewCmd, GKPedestrianExitCentroidNewCmd, GKPedestrianLevelChangeObjectNewCmd, GKPedestrianObstacleNewCmd, GKPedestrianODMatrixNewCmd, GKPedestrianODRouteNewCmd, GKPedestrianPolygonObstacleNewCmd, GKPedestrianServicePointNewCmd, GKPedestrianTypeNewCmd, GKDynamicAdjustmentExperimentNewCmd, GKDistributionCentroidTypeNewCmd, GKDistributionDataSetNewCmd, GKGenerationAttractionCentroidTypeNewCmd, GKGenerationAttractionDataSetAttributeNewCmd, GKGenerationAttractionDataSetNewCmd, GKGenerationAttractionExperimentNewCmd, GKGenerationAttractionScenarioNewCmd, GKGenerationAttractionVectorNewCmd, GKParkingCentroidTypeNewCmd, GKTimePeriodNewCmd, MacroAdjustmentExperimentNewCmd, MacroAdjustmentScenarioNewCmd, MacroDepartureAdjustmentExperimentNewCmd, MacroDepartureAdjustmentScenarioNewCmd, MacroExperimentNewCmd, MacroScenarioNewCmd, MacroPTExperimentNewCmd, MacroPTScenarioNewCmd, MacroPTZoneNewCmd, MacroPTZonePlanNewCmd, DetectorLocationNewCmd, ModalSplitExperimentNewCmd, ModalSplitScenarioNewCmd, GKPrintLayoutNewCmd, MacroPTAdjustmentExperimentNewCmd, MacroPTAdjustmentScenarioNewCmd, and GKTrafficProfileNewCmd.

◆ getModel()

GKModel * GKCommand::getModel ( ) const

Returns the model.

◆ getName()

const QString & GKCommand::getName ( ) const

Returns the command name.

◆ getTargets()

virtual QVector< int > GKCommand::getTargets ( ) const
virtual

Returns a list of objects modified by this command. Optional for now.

This implementation returns the id of the created object (if any)

◆ if()

GKCommand::if ( base  )
inline

References base, GKSystem::getSystem(), and sipType.

◆ init()

virtual GKCommandReport * GKCommand::init ( GKModel )
virtual

Initializes the command and returns NULL if the command can be executed, othewise it returns information about why the command cannot be executed. This method is called by GKCommander when the command is added to it (GKCommander::add) and before it is executed.

Reimplemented in GKPedestrianCentroidConfigurationNewCmd, GKPedestrianAreaNewCmd, GKPedestrianDecisionNodeNewCmd, GKPedestrianLevelChangeObjectNewCmd, GKPedestrianObstacleNewCmd, GKPedestrianPolygonObstacleNewCmd, GKPedestrianServicePointNewCmd, GKPedestrianEntranceCentroidNewCmd, and GKPedestrianExitCentroidNewCmd.

◆ isDone()

bool GKCommand::isDone ( ) const

Return true is the command has been done (the commander has executed the GKCommand::doit method) and false if the command has been undone (the commander has executed the GKCommand::undoit method).

◆ isEqual()

virtual bool GKCommand::isEqual ( GKCommand ) const
virtual

Returns true is this command is equal to the command "other". Equal means, in this context, that both commands apply the same operation to the same object (or objects). If you implement this operation then GKCommand::merge operation must be implemented too.

Never return true on creation commands. This type of command cannot be merged.

◆ isUndoable()

bool GKCommand::isUndoable ( ) const

Returns true if the command can be undone and false otherwise.

◆ merge()

virtual void GKCommand::merge ( GKCommand )
virtual

If two command are equal the commander will join both in one. This method will merge the command "other" with the command "this". The command "other" will be discarded.

◆ setDone()

virtual void GKCommand::setDone ( bool  )
virtual

Set the done attribute. Called by the commander (GKCommander) when needed.

◆ setModel()

void GKCommand::setModel ( GKModel )

Set the model, done by the GKCommander when the command is add to it.

◆ setName()

void GKCommand::setName ( const QString &  )

Set the command name, usually done in the command constructor.

◆ setUndoable()

void GKCommand::setUndoable ( bool  )

If "value" is true this command can be undone and false otherwise .

◆ undoit()

virtual void GKCommand::undoit ( )
pure virtual

Do not use this function. Available just for compatibility issues.

Implemented in GRotationCmd, GTranslationCmd, GKDetectionPatternNewCmd, GKDetectionPatternTemplateNewCmd, OCITDetectionPatternNewCmd, OCITDetectionPatternTemplateNewCmd, DistributionExperimentNewCmd, DistributionScenarioNewCmd, FourStepsExperimentNewCmd, FourStepsScenarioNewCmd, GKPedestrianAreaNewCmd, GKPedestrianCentroidConfigurationNewCmd, GKPedestrianDecisionNodeNewCmd, GKPedestrianEntranceCentroidNewCmd, GKPedestrianExitCentroidNewCmd, GKPedestrianLevelChangeObjectNewCmd, GKPedestrianObstacleNewCmd, GKPedestrianODMatrixNewCmd, GKPedestrianODRouteNewCmd, GKPedestrianPolygonObstacleNewCmd, GKPedestrianServicePointNewCmd, GKPedestrianTypeNewCmd, GKDynamicAdjustmentExperimentNewCmd, GKDistributionCentroidTypeNewCmd, GKDistributionDataSetNewCmd, GKGenerationAttractionCentroidTypeNewCmd, GKGenerationAttractionDataSetAttributeNewCmd, GKGenerationAttractionDataSetNewCmd, GKGenerationAttractionExperimentNewCmd, GKGenerationAttractionScenarioNewCmd, GKGenerationAttractionVectorNewCmd, GKParkingCentroidTypeNewCmd, GKTimePeriodNewCmd, MacroAdjustmentExperimentNewCmd, MacroAdjustmentScenarioNewCmd, MacroDepartureAdjustmentExperimentNewCmd, MacroDepartureAdjustmentScenarioNewCmd, MacroExperimentNewCmd, MacroScenarioNewCmd, MacroPTExperimentNewCmd, MacroPTScenarioNewCmd, MacroPTZoneNewCmd, MacroPTZonePlanNewCmd, DetectorLocationNewCmd, ModalSplitExperimentNewCmd, ModalSplitScenarioNewCmd, GKPrintLayoutNewCmd, MacroPTAdjustmentExperimentNewCmd, MacroPTAdjustmentScenarioNewCmd, and GKTrafficProfileNewCmd.

Member Data Documentation

◆ base

ConvertToSubClassCode Py_BEGIN_ALLOW_THREADS GKCommand* GKCommand::base = (GKCommand*)sipCpp

Referenced by if().

◆ sipType

GKCommand::sipType = 0

Referenced by if().

© Aimsun SLU
Aimsun ®