StateMachineTask::~StateMachineTask()
 {
     // When the this TaskObject is deleted, make sure the program does not reference us.
     ParsedStateMachinePtr prog = statemachine.lock();
     if ( prog ) {
         prog->setTaskObject(0);
     }
 }
 StateMachineService::StateMachineService(ParsedStateMachinePtr statem, TaskContext* tc)
     : Service( statem->getName() ),
       _this( new ValueDataSource<StateMachinePtr>( statem ) ),
       statemachine(statem),
       mtc(tc)
 {
     this->createOperationFactory();
     this->setOwner( tc );
 }
 StateMachineTask::StateMachineTask(ParsedStateMachinePtr statem, ExecutionEngine* ee)
     : TaskObject( statem->getName() ),
       _this( new ValueDataSource<StateMachineWPtr>( statem ) ),
       statemachine(statem),
       mengine(ee)
 {
     this->createCommandFactory();
     this->createMethodFactory();
     this->setEngine( ee );
 }