Go to the documentation of this file.00001 #ifndef baciBACICallback_H
00002 #define baciBACICallback_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
00034 #ifndef __cplusplus
00035 #error This is a C++ include file and cannot be used from plain C
00036 #endif
00037
00038 #include "baciExport.h"
00039 #include "baciValue.h"
00040 #include "baciRegistrar.h"
00041
00042 namespace baci {
00043
00044
00045
00046 class BACIComponent;
00047
00055 class baci_EXPORT BACICallback
00056 {
00057
00058 public:
00059
00068 BACICallback(const int& id_, Callback_ptr callback_,
00069 const BACIValue::Type type_,
00070 const CBDescIn& descIn_, BACIComponent* component_p):
00071 id_m(id_), type_m(type_), descIn_m(descIn_), component_mp(component_p),
00072 failureCount_m(0), removeOnFailure_m(true)
00073 {
00074 callback_mp = Callback::_duplicate(callback_);
00075 }
00076
00080 ~BACICallback() {
00081 CORBA::release(callback_mp);
00082 }
00083
00087 BACICallback& operator=(const BACICallback& cb)
00088 {
00089 if (this!=&cb)
00090 {
00091 id_m=cb.id_m;
00092 type_m=cb.type_m;
00093 callback_mp=Callback::_duplicate(cb.callback_mp);
00094 descIn_m=cb.descIn_m;
00095 component_mp=cb.component_mp;
00096 failureCount_m=cb.failureCount_m;
00097 removeOnFailure_m=cb.removeOnFailure_m;
00098 }
00099 return *this;
00100 }
00101
00105 bool operator==(const BACICallback& cb) const { return id_m==cb.id_m; }
00106
00111 int getID() const { return id_m; }
00112
00117 void succeeded() {
00118
00119 failureCount_m=0;
00120 }
00121
00122
00128 void failed();
00129
00134 bool isOK() { return (failureCount_m <= failureLimitCount_m); }
00135
00140 void setRemoveOnFailure(bool removeOnFailure_) { removeOnFailure_m=removeOnFailure_; }
00141
00146 bool doRemoveOnFailure() const { return removeOnFailure_m; }
00147
00152 Callback_ptr getCallback() const { return callback_mp; }
00153
00158 BACIValue::Type getType() const { return type_m; }
00159
00164 CBDescIn getDescIn() const { return descIn_m; }
00165
00170 BACIComponent* getComponent() const { return component_mp; }
00171
00172 private:
00173
00177 int id_m;
00178
00182 Callback_ptr callback_mp;
00183
00187 BACIValue::Type type_m;
00188
00192 CBDescIn descIn_m;
00193
00197 BACIComponent* component_mp;
00198
00202 int failureCount_m;
00203
00207 bool removeOnFailure_m;
00208
00212 static const int failureLimitCount_m;
00213
00217 BACICallback(const BACICallback&);
00218
00219 };
00220
00221
00227 typedef Registrar<int, BACICallback*> BACICallbackTable;
00230
00231
00232 };
00233
00234 #endif
00235
00236
00237
00238