00001 #include "OperationCallerInterface.hpp" 00002 #include "../internal/GlobalEngine.hpp" 00003 00004 using namespace RTT; 00005 using namespace base; 00006 using namespace internal; 00007 00008 OperationCallerInterface::OperationCallerInterface() 00009 : myengine(0), caller(0), ownerEngine(0), met(OwnThread) 00010 {} 00011 00012 OperationCallerInterface::OperationCallerInterface(OperationCallerInterface const& orig) 00013 : myengine(orig.myengine), caller(orig.caller), ownerEngine(orig.ownerEngine), met(orig.met) 00014 {} 00015 00016 OperationCallerInterface::~OperationCallerInterface() 00017 { 00018 } 00019 00020 void OperationCallerInterface::setOwner(ExecutionEngine* ee) { 00021 ownerEngine = ee; 00022 } 00023 00024 void OperationCallerInterface::setExecutor(ExecutionEngine* ee) { 00025 if (met == OwnThread) 00026 myengine = ee; 00027 else 00028 myengine = GlobalEngine::Instance(); 00029 } 00030 00031 void OperationCallerInterface::setCaller(ExecutionEngine* ee) { 00032 if (ee) 00033 caller = ee; 00034 else 00035 caller = GlobalEngine::Instance(); 00036 } 00037 00038 bool OperationCallerInterface::setThread(ExecutionThread et, ExecutionEngine* executor) { 00039 if ( !myengine && !caller && !ownerEngine ) 00040 return false; // detect uninitialized object. This is actually a hack for RemoteOperationCaller. 00041 met = et; 00042 setExecutor(executor); 00043 return true; 00044 } 00045 00046 // report an error if an exception was thrown while calling exec() 00047 void OperationCallerInterface::reportError() { 00048 // This localOperation was added to a TaskContext or to a Service owned by a TaskContext 00049 if (this->ownerEngine != 0) 00050 this->ownerEngine->setExceptionTask(); 00051 // This operation is called through OperationCaller directly 00052 else if (this->met == OwnThread) 00053 this->myengine->setExceptionTask(); 00054 } 00055