00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023 #include "Federate.hh"
00024 #include "PrettyDebug.hh"
00025
00026 #include <algorithm>
00027
00028 #ifdef _WIN32
00029 #include <windows.h>
00030 #else
00031 #include <cstring>
00032 #include <string>
00033 #endif
00034
00035 static PrettyDebug G("GENDOC",__FILE__);
00036
00037 using std::string ;
00038
00039 namespace certi {
00040 namespace rtig {
00041
00042
00044 Federate::Federate(const char *the_name, FederateHandle the_handle)
00045 throw (RTIinternalError)
00046 : handle(the_handle), name(the_name), regulator(false), constrained(false),
00047 cras(true), iras(true), aras(false), asas(false),
00048 saving(false), restoring(false)
00049 {
00050 if (handle == 0)
00051 throw RTIinternalError("Bad initialization parameter for Federate.");
00052 }
00053
00054
00056 void
00057 Federate::addSynchronizationLabel(const char *label)
00058 throw (RTIinternalError)
00059 {
00060 G.Out(pdGendoc,"enter Federate::addSynchronizationLabel");
00061
00062 string s = label ;
00063 SyncList::iterator it = std::find(syncLabels.begin(), syncLabels.end(), s);
00064 if (it == syncLabels.end())
00065 syncLabels.push_back(s);
00066 else
00067 throw RTIinternalError("Synchronization label pending in federate.");
00068
00069 G.Out(pdGendoc,"exit Federate::addSynchronizationLabel");
00070
00071 }
00072
00073
00075 void
00076 Federate::removeSynchronizationLabel(const char *label)
00077 throw (RTIinternalError)
00078 {
00079 string s = label ;
00080 SyncList::iterator it = std::find(syncLabels.begin(), syncLabels.end(), s);
00081 if (it == syncLabels.end())
00082 throw RTIinternalError("Synch. label not in federate.");
00083 else
00084 syncLabels.erase(it);
00085 }
00086
00087
00089 bool
00090 Federate::isSynchronizationLabel(const char *label) const
00091 {
00092 return std::find(syncLabels.begin(), syncLabels.end(), string(label)) != syncLabels.end();
00093 }
00094
00095 }}
00096
00097