00001
#ifndef baciBACIAction_H
00002
#define baciBACIAction_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00035
#ifndef __cplusplus
00036
#error This is a C++ include file and cannot be used from plain C
00037
#endif
00038
00039
#include "baciExport.h"
00040
#include "baciValue.h"
00041
00042
#include <deque>
00043
00044
namespace baci {
00045
00046
00047
00048
class BACIComponent;
00049
00053 enum ActionRequest {
reqNone=0,
00054
reqInvokeWorking=1,
00055
reqInvokeDone=2,
00056
reqDestroy=3 };
00057
00065 class baci_EXPORT ActionImplementator
00066 {
00067
public:
00090
virtual ActionRequest invokeAction(
int function,
00091
BACIComponent* component_p,
00092
const int &callbackID,
00093
const CBDescIn& descIn,
00094
BACIValue* value,
00095
Completion& completion,
00096
CBDescOut& descOut) = 0;
00097
00098 virtual ~ActionImplementator() {}
00099
00100 };
00101
00102
00103
00112 class baci_EXPORT BACIAction
00113 {
00114
00115
public:
00116
00120 BACIAction() : actionFunction_m(0), actionImplementator_mp(0),
00121 callbackID_m(-1), value_m(
BACIValue::NullValue), completed_m(false) {}
00122
00128 BACIAction(ActionImplementator* actionImplementator_,
00129
int actionFunction_,
00130
int callbackID_) :
00131 actionFunction_m(actionFunction_),
00132 actionImplementator_mp(actionImplementator_),
00133 callbackID_m(callbackID_),
00134 value_m(
BACIValue(
BACIValue::NullValue)),
00135 completed_m(false)
00136 {
00137 }
00138
00146 BACIAction(ActionImplementator* actionImplementator_,
00147
int actionFunction_,
00148
int callbackID_,
const BACIValue& value_):
00149 actionFunction_m(actionFunction_),
00150 actionImplementator_mp(actionImplementator_),
00151 callbackID_m(callbackID_),
00152 value_m(value_),
00153 completed_m(false)
00154 {
00155 }
00156
00160 BACIAction& operator=(
const BACIAction& action)
00161 {
00162
if (
this!=&action)
00163 {
00164 actionFunction_m=action.
actionFunction_m;
00165 actionImplementator_mp=action.
actionImplementator_mp;
00166 callbackID_m=action.
callbackID_m;
00167 value_m=action.
value_m;
00168 completed_m=action.
completed_m;
00169 completion_m=action.
completion_m;
00170 }
00171
return *
this;
00172 }
00173
00177 bool operator==(
const BACIAction& action)
const {
return callbackID_m==action.
callbackID_m; }
00178
00189 ActionRequest invoke(
BACIComponent* component_p,
00190
int callbackID_,
00191
const CBDescIn& descIn,
00192
BACIValue* value,
00193
Completion& completion,
00194
CBDescOut& descOut)
00195 {
00196
return actionImplementator_mp->invokeAction(actionFunction_m, component_p, callbackID_, descIn,
00197 value, completion, descOut);
00198 }
00199
00204 int getActionFunction()
const {
return actionFunction_m; }
00205
00210 ActionImplementator* getActionImplementator()
const {
return actionImplementator_mp; }
00211
00216 int getCallbackID()
const {
return callbackID_m; };
00217
00222 BACIValue getValue()
const {
return value_m; }
00223
00228 BACIValue* getValueRef()
const {
return const_cast<BACIValue*>(&value_m); }
00229
00234 bool isCompleted()
const {
return completed_m; }
00235
00240 Completion getCompletion()
const {
return completion_m; }
00241
00245 void setCompletion(
const Completion& c)
00246 {
00247 completed_m =
true;
00248 completion_m = c;
00249 }
00250
00251
private:
00252
00256 int actionFunction_m;
00257
00261 ActionImplementator* actionImplementator_mp;
00262
00266 int callbackID_m;
00267
00271 BACIValue value_m;
00272
00276 bool completed_m;
00277
00281 Completion completion_m;
00282
00286 BACIAction(
const BACIAction&);
00287
00288 };
00289
00293 typedef std::deque<BACIAction*>
BACIActionQueue;
00294
00295
00296
00297 };
00298
00299
#endif