00001
00002
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 #include "DataSource/DataConnect.h"
00028 #include "DataSource/DataSource.h"
00029 #include "DataSource/DataSourceObject.h"
00030 #include "DataSource/DataConnectCreator.h"
00031 #include "Utility/IpplInfo.h"
00032 #include "Profile/Profiler.h"
00033
00034
00036
00037 DataConnect::DataConnect(const char *nm, const char *id, int dtm, int n)
00038 : NamedObj(nm), MyID(id), DefTransMethod(dtm), nodes(n)
00039 {
00040 if (n <= 0)
00041 nodes = DataConnectCreator::getDefaultNodes();
00042 }
00043
00044
00046
00047 DataConnect::~DataConnect()
00048 {
00049 disconnectConnections();
00050 }
00051
00052
00054
00055 bool DataConnect::onConnectNode() const {
00056 return (Ippl::myNode() < getNodes());
00057 }
00058
00059
00061
00062
00063 bool DataConnect::connected() const {
00064 return false;
00065 }
00066
00067
00069
00070
00071
00072
00073
00074 DataConnect *DataConnect::connect(const char *nm, DataSource *s, int tm) {
00075 TAU_PROFILE("DataConnect::connect()",
00076 "DataConnect * (char *, DataSource *, int",
00077 TAU_VIZ);
00078 DataConnect *conn = 0;
00079 if (connected() && s != 0)
00080 conn = s->connect(nm, this, tm);
00081 return conn;
00082 }
00083
00084 DataConnect *DataConnect::connect(const char *nm, DataSource& s, int tm) {
00085 return connect(nm, &s, tm);
00086 }
00087
00088
00090
00091
00092
00093 bool DataConnect::connect(DataSourceObject *dso) {
00094 TAU_PROFILE("DataConnect::connect()", "DataSourceObject *", TAU_VIZ);
00095
00096
00097 if (dso == 0 || dso->getSource() == 0 || dso->getConnection() != this)
00098 return false;
00099
00100
00101
00102 return dso->getSource()->connect(dso);
00103 }
00104
00105
00107
00108 void DataConnect::updateConnections(DataConnect *dc) {
00109 TAU_PROFILE("DataConnect::updateConnections()", "void (DataConnect *)",
00110 TAU_VIZ);
00111 for (iterator a = begin(); a != end(); ++a)
00112 (*a)->updateConnection(dc);
00113 }
00114
00115
00117
00118 void DataConnect::disconnectConnections() {
00119 TAU_PROFILE("DataConnect::disconnectConnections()", "void ()", TAU_VIZ);
00120 while (! SourceList.empty() )
00121 checkout(SourceList.front());
00122 }
00123
00124
00126
00127 void DataConnect::interact(const char *str, DataConnect *dc) {
00128 TAU_PROFILE("DataConnect::interact()", "void (const char *, DataConnect *)",
00129 TAU_VIZ);
00130 for (iterator a = begin(); a != end(); ++a)
00131 (*a)->interact(str, dc);
00132 }
00133
00134
00136
00137 bool DataConnect::checkin(DataSource *ds) {
00138 TAU_PROFILE("DataConnect::checkin()", "bool (DataSource *)", TAU_VIZ);
00139
00140
00141 for (iterator a = begin(); a != end(); ++a) {
00142 if (*a == ds)
00143 return true;
00144 }
00145
00146
00147 SourceList.push_back(ds);
00148 return true;
00149 }
00150
00151
00153
00154 bool DataConnect::checkout(DataSource *ds, bool NeedDisconnect) {
00155 TAU_PROFILE("DataConnect::checkout()", "bool (DataSource *, bool)", TAU_VIZ);
00156
00157
00158
00159
00160 for (iterator a = begin(); a != end(); ++a) {
00161 if (*a == ds) {
00162
00163
00164
00165 SourceList.erase(a);
00166 if (NeedDisconnect) {
00167
00168 ds->disconnect(this);
00169 } else {
00170
00171 }
00172 return true;
00173 }
00174 }
00175
00176
00177
00178 return false;
00179 }
00180
00182
00183
00184 void DataConnect::ready()
00185 {
00186 }
00187
00188
00189
00190
00191
00192