Federate.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 // CERTI - HLA RunTime Infrastructure
00003 // Copyright (C) 2002-2005  ONERA
00004 //
00005 // This program is free software ; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation ; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY ; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program ; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00018 //
00019 // $Id: Federate.cc,v 3.16 2008/11/20 18:21:55 approx Exp $
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 // $Id: Federate.cc,v 3.16 2008/11/20 18:21:55 approx Exp $

Generated on Thu Apr 30 15:53:48 2009 for CERTIDeveloperDocumentation by doxygen 1.5.5