]> git.mxchange.org Git - simgear.git/blob - simgear/hla/RTI13Ambassador.hxx
hla: Make use of SGLocation.
[simgear.git] / simgear / hla / RTI13Ambassador.hxx
1 // Copyright (C) 2009 - 2010  Mathias Froehlich - Mathias.Froehlich@web.de
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Library General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16 //
17
18 #ifndef RTI13Ambassador_hxx
19 #define RTI13Ambassador_hxx
20
21 #include <cstdlib>
22 #include <list>
23 #include <memory>
24 #include <vector>
25 #include <map>
26 #include <set>
27
28 #ifndef RTI_USES_STD_FSTREAM
29 #define RTI_USES_STD_FSTREAM
30 #endif
31
32 #include <RTI.hh>
33 #include <fedtime.hh>
34
35 #include <simgear/debug/logstream.hxx>
36 #include <simgear/structure/SGWeakReferenced.hxx>
37 #include <simgear/structure/SGSharedPtr.hxx>
38 #include <simgear/structure/SGWeakPtr.hxx>
39 #include <simgear/timing/timestamp.hxx>
40
41 #include "RTIObjectClass.hxx"
42 #include "RTIData.hxx"
43 #include "RTI13Federate.hxx"
44 #include "RTI13ObjectInstance.hxx"
45
46 namespace simgear {
47
48 class RTI13Federate;
49
50 class RTI13Ambassador : public SGReferenced {
51 public:
52     ~RTI13Ambassador()
53     { }
54
55     void createFederationExecution(const std::string& name, const std::string& objectModel)
56     { _rtiAmbassador.createFederationExecution(name.c_str(), objectModel.c_str()); }
57     void destroyFederationExecution(const std::string& name)
58     { _rtiAmbassador.destroyFederationExecution(name.c_str()); }
59
60     RTI::FederateHandle joinFederationExecution(const std::string& federate, const std::string& federation, RTI::FederateAmbassador* federateAmbassador)
61     { return _rtiAmbassador.joinFederationExecution(federate.c_str(), federation.c_str(), federateAmbassador); }
62     void resignFederationExecution()
63     { _rtiAmbassador.resignFederationExecution(RTI::DELETE_OBJECTS_AND_RELEASE_ATTRIBUTES); }
64
65     void registerFederationSynchronizationPoint(const std::string& label, const RTIData& tag)
66     { _rtiAmbassador.registerFederationSynchronizationPoint(label.c_str(), tag.data()); }
67     void synchronizationPointAchieved(const std::string& label)
68     { _rtiAmbassador.synchronizationPointAchieved(label.c_str()); }
69
70     void publishObjectClass(const RTI::ObjectClassHandle& handle, const RTI::AttributeHandleSet& attributeHandleSet)
71     { _rtiAmbassador.publishObjectClass(handle, attributeHandleSet); }
72     void unpublishObjectClass(const RTI::ObjectClassHandle& handle)
73     { _rtiAmbassador.unpublishObjectClass(handle); }
74
75     void publishInteractionClass(const RTI::InteractionClassHandle& handle)
76     { _rtiAmbassador.publishInteractionClass(handle); }
77     void unpublishInteractionClass(const RTI::InteractionClassHandle& handle)
78     { _rtiAmbassador.unpublishInteractionClass(handle); }
79
80     void subscribeObjectClassAttributes(const RTI::ObjectClassHandle& handle, const RTI::AttributeHandleSet& attributeHandleSet, bool active)
81     { _rtiAmbassador.subscribeObjectClassAttributes(handle, attributeHandleSet, active ? RTI::RTI_TRUE : RTI::RTI_FALSE); }
82     void unsubscribeObjectClass(const RTI::ObjectClassHandle& handle)
83     { _rtiAmbassador.unsubscribeObjectClass(handle); }
84
85     void subscribeInteractionClass(const RTI::InteractionClassHandle& handle, bool active)
86     { _rtiAmbassador.subscribeInteractionClass(handle, active ? RTI::RTI_TRUE : RTI::RTI_FALSE); }
87     void unsubscribeInteractionClass(const RTI::InteractionClassHandle& handle)
88     { _rtiAmbassador.unsubscribeInteractionClass(handle); }
89
90     RTI::ObjectHandle registerObjectInstance(const RTI::ObjectClassHandle& handle)
91     { return _rtiAmbassador.registerObjectInstance(handle); }
92     void updateAttributeValues(const RTI::ObjectHandle& objectHandle, const RTI::AttributeHandleValuePairSet& attributeValues,
93                                const SGTimeStamp& timeStamp, const RTIData& tag)
94     { _rtiAmbassador.updateAttributeValues(objectHandle, attributeValues, toFedTime(timeStamp), tag.data()); }
95     void updateAttributeValues(const RTI::ObjectHandle& objectHandle, const RTI::AttributeHandleValuePairSet& attributeValues, const RTIData& tag)
96     { _rtiAmbassador.updateAttributeValues(objectHandle, attributeValues, tag.data()); }
97
98     // RTI::EventRetractionHandle sendInteraction(RTI::InteractionClassHandle interactionClassHandle, const RTI::ParameterHandleValuePairSet& parameters, const RTI::FedTime& fedTime, const RTIData& tag)
99     // { return _rtiAmbassador.sendInteraction(interactionClassHandle, parameters, fedTime, tag.data()); }
100     // void sendInteraction(RTI::InteractionClassHandle interactionClassHandle, const RTI::ParameterHandleValuePairSet& parameters, const RTIData& tag)
101     // { _rtiAmbassador.sendInteraction(interactionClassHandle, parameters, tag.data()); }
102
103     void deleteObjectInstance(const RTI::ObjectHandle& objectHandle, const SGTimeStamp& timeStamp, const RTIData& tag)
104     { /* RTI::EventRetractionHandle h = */ _rtiAmbassador.deleteObjectInstance(objectHandle, toFedTime(timeStamp), tag.data()); }
105     void deleteObjectInstance(const RTI::ObjectHandle& objectHandle, const RTIData& tag)
106     { _rtiAmbassador.deleteObjectInstance(objectHandle, tag.data()); }
107     void localDeleteObjectInstance(const RTI::ObjectHandle& objectHandle)
108     { _rtiAmbassador.localDeleteObjectInstance(objectHandle); }
109
110     void requestObjectAttributeValueUpdate(const RTI::ObjectHandle& handle, const RTI::AttributeHandleSet& attributeHandleSet)
111     { _rtiAmbassador.requestObjectAttributeValueUpdate(handle, attributeHandleSet); }
112     void requestClassAttributeValueUpdate(const RTI::ObjectClassHandle& handle, const RTI::AttributeHandleSet& attributeHandleSet)
113     { _rtiAmbassador.requestClassAttributeValueUpdate(handle, attributeHandleSet); }
114
115     // Ownership Management -------------------
116
117     // bool unconditionalAttributeOwnershipDivestiture(const RTIHandle& objectHandle, const RTIHandleSet& attributeHandles)
118     // {
119     //     try {
120     //         std::auto_ptr<RTI::AttributeHandleSet> attributeHandleSet(RTI::AttributeHandleSetFactory::create(attributeHandles.size()));
121     //         for (RTIHandleSet::const_iterator i = attributeHandles.begin(); i != attributeHandles.end(); ++i)
122     //             attributeHandleSet->add(*i);
123     //         _rtiAmbassador.unconditionalAttributeOwnershipDivestiture(objectHandle, *attributeHandleSet);
124     //         return true;
125     //     } catch (RTI::ObjectNotKnown& e) {
126     //     } catch (RTI::AttributeNotDefined& e) {
127     //     } catch (RTI::AttributeNotOwned& e) {
128     //     } catch (RTI::FederateNotExecutionMember& e) {
129     //     } catch (RTI::ConcurrentAccessAttempted& e) {
130     //     } catch (RTI::SaveInProgress& e) {
131     //     } catch (RTI::RestoreInProgress& e) {
132     //     } catch (RTI::RTIinternalError& e) {
133     //     }
134     //     return false;
135     // }
136     // bool negotiatedAttributeOwnershipDivestiture(const RTIHandle& objectHandle, const RTIHandleSet& attributeHandles, const RTIData& tag)
137     // {
138     //     try {
139     //         std::auto_ptr<RTI::AttributeHandleSet> attributeHandleSet(RTI::AttributeHandleSetFactory::create(attributeHandles.size()));
140     //         for (RTIHandleSet::const_iterator i = attributeHandles.begin(); i != attributeHandles.end(); ++i)
141     //             attributeHandleSet->add(*i);
142     //         _rtiAmbassador.negotiatedAttributeOwnershipDivestiture(objectHandle, *attributeHandleSet, tag.data());
143     //         return true;
144     //     } catch (RTI::ObjectNotKnown& e) {
145     //     } catch (RTI::AttributeNotDefined& e) {
146     //     } catch (RTI::AttributeNotOwned& e) {
147     //     } catch (RTI::AttributeAlreadyBeingDivested& e) {
148     //     } catch (RTI::FederateNotExecutionMember& e) {
149     //     } catch (RTI::ConcurrentAccessAttempted& e) {
150     //     } catch (RTI::SaveInProgress& e) {
151     //     } catch (RTI::RestoreInProgress& e) {
152     //     } catch (RTI::RTIinternalError& e) {
153     //     }
154     //     return false;
155     // }
156     // bool attributeOwnershipAcquisition(const RTIHandle& objectHandle, const RTIHandleSet& attributeHandles, const RTIData& tag)
157     // {
158     //     try {
159     //         std::auto_ptr<RTI::AttributeHandleSet> attributeHandleSet(RTI::AttributeHandleSetFactory::create(attributeHandles.size()));
160     //         for (RTIHandleSet::const_iterator i = attributeHandles.begin(); i != attributeHandles.end(); ++i)
161     //             attributeHandleSet->add(*i);
162     //         _rtiAmbassador.attributeOwnershipAcquisition(objectHandle, *attributeHandleSet, tag.data());
163     //         return true;
164     //     } catch (RTI::ObjectNotKnown& e) {
165     //     } catch (RTI::ObjectClassNotPublished& e) {
166     //     } catch (RTI::AttributeNotDefined& e) {
167     //     } catch (RTI::AttributeNotPublished& e) {
168     //     } catch (RTI::FederateOwnsAttributes& e) {
169     //     } catch (RTI::FederateNotExecutionMember& e) {
170     //     } catch (RTI::ConcurrentAccessAttempted& e) {
171     //     } catch (RTI::SaveInProgress& e) {
172     //     } catch (RTI::RestoreInProgress& e) {
173     //     } catch (RTI::RTIinternalError& e) {
174     //     }
175     //     return false;
176     // }
177     // bool attributeOwnershipAcquisitionIfAvailable(const RTIHandle& objectHandle, const RTIHandleSet& attributeHandles)
178     // {
179     //     try {
180     //         std::auto_ptr<RTI::AttributeHandleSet> attributeHandleSet(RTI::AttributeHandleSetFactory::create(attributeHandles.size()));
181     //         for (RTIHandleSet::const_iterator i = attributeHandles.begin(); i != attributeHandles.end(); ++i)
182     //             attributeHandleSet->add(*i);
183     //         _rtiAmbassador.attributeOwnershipAcquisitionIfAvailable(objectHandle, *attributeHandleSet);
184     //         return true;
185     //     } catch (RTI::ObjectNotKnown& e) {
186     //     } catch (RTI::ObjectClassNotPublished& e) {
187     //     } catch (RTI::AttributeNotDefined& e) {
188     //     } catch (RTI::AttributeNotPublished& e) {
189     //     } catch (RTI::FederateOwnsAttributes& e) {
190     //     } catch (RTI::AttributeAlreadyBeingAcquired& e) {
191     //     } catch (RTI::FederateNotExecutionMember& e) {
192     //     } catch (RTI::ConcurrentAccessAttempted& e) {
193     //     } catch (RTI::SaveInProgress& e) {
194     //     } catch (RTI::RestoreInProgress& e) {
195     //     } catch (RTI::RTIinternalError& e) {
196     //     }
197     //     return false;
198     // }
199     // RTIHandleSet attributeOwnershipReleaseResponse(const RTIHandle& objectHandle, const RTIHandleSet& attributeHandles)
200     // {
201     //     try {
202     //         std::auto_ptr<RTI::AttributeHandleSet> attributeHandleSet(RTI::AttributeHandleSetFactory::create(attributeHandles.size()));
203     //         for (RTIHandleSet::const_iterator i = attributeHandles.begin(); i != attributeHandles.end(); ++i)
204     //             attributeHandleSet->add(*i);
205     //         attributeHandleSet.reset(_rtiAmbassador.attributeOwnershipReleaseResponse(objectHandle, *attributeHandleSet));
206     //         RTIHandleSet handleSet;
207     //         RTI::ULong numAttribs = attributeHandleSet->size();
208     //         for (RTI::ULong i = 0; i < numAttribs; ++i)
209     //             handleSet.insert(attributeHandleSet->getHandle(i));
210     //         return handleSet;
211     //     } catch (RTI::ObjectNotKnown& e) {
212     //     } catch (RTI::AttributeNotDefined& e) {
213     //     } catch (RTI::AttributeNotOwned& e) {
214     //     } catch (RTI::FederateWasNotAskedToReleaseAttribute& e) {
215     //     } catch (RTI::FederateNotExecutionMember& e) {
216     //     } catch (RTI::ConcurrentAccessAttempted& e) {
217     //     } catch (RTI::SaveInProgress& e) {
218     //     } catch (RTI::RestoreInProgress& e) {
219     //     } catch (RTI::RTIinternalError& e) {
220     //     }
221     //     return RTIHandleSet();
222     // }
223     // bool cancelNegotiatedAttributeOwnershipDivestiture(const RTIHandle& objectHandle, const RTIHandleSet& attributeHandles)
224     // {
225     //     try {
226     //         std::auto_ptr<RTI::AttributeHandleSet> attributeHandleSet(RTI::AttributeHandleSetFactory::create(attributeHandles.size()));
227     //         for (RTIHandleSet::const_iterator i = attributeHandles.begin(); i != attributeHandles.end(); ++i)
228     //             attributeHandleSet->add(*i);
229     //         _rtiAmbassador.cancelNegotiatedAttributeOwnershipDivestiture(objectHandle, *attributeHandleSet);
230     //         return true;
231     //     } catch (RTI::ObjectNotKnown& e) {
232     //     } catch (RTI::AttributeNotDefined& e) {
233     //     } catch (RTI::AttributeNotOwned& e) {
234     //     } catch (RTI::AttributeDivestitureWasNotRequested& e) {
235     //     } catch (RTI::FederateNotExecutionMember& e) {
236     //     } catch (RTI::ConcurrentAccessAttempted& e) {
237     //     } catch (RTI::SaveInProgress& e) {
238     //     } catch (RTI::RestoreInProgress& e) {
239     //     } catch (RTI::RTIinternalError& e) {
240     //     }
241     //     return false;
242     // }
243     // bool cancelAttributeOwnershipAcquisition(const RTIHandle& objectHandle, const RTIHandleSet& attributeHandles)
244     // {
245     //     try {
246     //         std::auto_ptr<RTI::AttributeHandleSet> attributeHandleSet(RTI::AttributeHandleSetFactory::create(attributeHandles.size()));
247     //         for (RTIHandleSet::const_iterator i = attributeHandles.begin(); i != attributeHandles.end(); ++i)
248     //             attributeHandleSet->add(*i);
249     //         _rtiAmbassador.cancelAttributeOwnershipAcquisition(objectHandle, *attributeHandleSet);
250     //         return true;
251     //     } catch (RTI::ObjectNotKnown& e) {
252     //     } catch (RTI::AttributeNotDefined& e) {
253     //     } catch (RTI::AttributeAlreadyOwned& e) {
254     //     } catch (RTI::AttributeAcquisitionWasNotRequested& e) {
255     //     } catch (RTI::FederateNotExecutionMember& e) {
256     //     } catch (RTI::ConcurrentAccessAttempted& e) {
257     //     } catch (RTI::SaveInProgress& e) {
258     //     } catch (RTI::RestoreInProgress& e) {
259     //     } catch (RTI::RTIinternalError& e) {
260     //     }
261     //     return false;
262     // }
263     // bool queryAttributeOwnership(const RTIHandle& objectHandle, const RTIHandle& attributeHandle)
264     // {
265     //     try {
266     //         _rtiAmbassador.queryAttributeOwnership(objectHandle, attributeHandle);
267     //         return true;
268     //     } catch (RTI::ObjectNotKnown& e) {
269     //     } catch (RTI::AttributeNotDefined& e) {
270     //     } catch (RTI::FederateNotExecutionMember& e) {
271     //     } catch (RTI::ConcurrentAccessAttempted& e) {
272     //     } catch (RTI::SaveInProgress& e) {
273     //     } catch (RTI::RestoreInProgress& e) {
274     //     } catch (RTI::RTIinternalError& e) {
275     //     }
276     //     return false;
277     // }
278     bool isAttributeOwnedByFederate(const RTI::ObjectHandle& objectHandle, const RTI::AttributeHandle& attributeHandle)
279     { return _rtiAmbassador.isAttributeOwnedByFederate(objectHandle, attributeHandle); }
280
281     /// Time Management
282
283     void enableTimeRegulation(const SGTimeStamp& lookahead)
284     {
285         RTIfedTime federateTime;
286         federateTime.setZero();
287         _rtiAmbassador.enableTimeRegulation(federateTime, toFedTime(lookahead));
288     }
289     void disableTimeRegulation()
290     { _rtiAmbassador.disableTimeRegulation();}
291
292     void enableTimeConstrained()
293     { _rtiAmbassador.enableTimeConstrained(); }
294     void disableTimeConstrained()
295     { _rtiAmbassador.disableTimeConstrained(); }
296
297     void timeAdvanceRequest(const SGTimeStamp& time)
298     { _rtiAmbassador.timeAdvanceRequest(toFedTime(time)); }
299     void timeAdvanceRequestAvailable(const SGTimeStamp& time)
300     { _rtiAmbassador.timeAdvanceRequestAvailable(toFedTime(time)); }
301     void flushQueueRequest(const SGTimeStamp& time)
302     { _rtiAmbassador.flushQueueRequest(toFedTime(time)); }
303
304     bool queryGALT(SGTimeStamp& timeStamp)
305     {
306         RTIfedTime fedTime;
307         fedTime.setPositiveInfinity();
308         _rtiAmbassador.queryLBTS(fedTime);
309         if (fedTime.isPositiveInfinity())
310             return false;
311         timeStamp = toTimeStamp(fedTime);
312         return true;
313     }
314     bool queryLITS(SGTimeStamp& timeStamp)
315     {
316         RTIfedTime fedTime;
317         fedTime.setPositiveInfinity();
318         _rtiAmbassador.queryMinNextEventTime(fedTime);
319         if (fedTime.isPositiveInfinity())
320             return false;
321         timeStamp = toTimeStamp(fedTime);
322         return true;
323     }
324     void queryFederateTime(SGTimeStamp& timeStamp)
325     {
326         RTIfedTime fedTime;
327         _rtiAmbassador.queryFederateTime(fedTime);
328         timeStamp = toTimeStamp(fedTime);
329     }
330     void modifyLookahead(const SGTimeStamp& timeStamp)
331     { _rtiAmbassador.modifyLookahead(toFedTime(timeStamp)); }
332     void queryLookahead(SGTimeStamp& timeStamp)
333     {
334         RTIfedTime fedTime;
335         _rtiAmbassador.queryLookahead(fedTime);
336         timeStamp = toTimeStamp(fedTime);
337     }
338
339     RTI::ObjectClassHandle getObjectClassHandle(const std::string& name)
340     { return _rtiAmbassador.getObjectClassHandle(name.c_str()); }
341     std::string getObjectClassName(const RTI::ObjectClassHandle& handle)
342     { return rtiToStdString(_rtiAmbassador.getObjectClassName(handle)); }
343
344     RTI::AttributeHandle getAttributeHandle(const std::string& attributeName, const RTI::ObjectClassHandle& objectClassHandle)
345     { return _rtiAmbassador.getAttributeHandle(attributeName.c_str(), objectClassHandle); }
346     std::string getAttributeName(const RTI::AttributeHandle& attributeHandle, const RTI::ObjectClassHandle& objectClassHandle)
347     { return rtiToStdString(_rtiAmbassador.getAttributeName(attributeHandle, objectClassHandle)); }
348
349     RTI::InteractionClassHandle getInteractionClassHandle(const std::string& name)
350     { return _rtiAmbassador.getInteractionClassHandle(name.c_str()); }
351     std::string getInteractionClassName(const RTI::InteractionClassHandle& handle)
352     { return rtiToStdString(_rtiAmbassador.getInteractionClassName(handle)); }
353
354     RTI::ParameterHandle getParameterHandle(const std::string& parameterName, const RTI::InteractionClassHandle& interactionClassHandle)
355     { return _rtiAmbassador.getParameterHandle(parameterName.c_str(), interactionClassHandle); }
356     std::string getParameterName(const RTI::ParameterHandle& parameterHandle, const RTI::InteractionClassHandle& interactionClassHandle)
357     { return rtiToStdString(_rtiAmbassador.getParameterName(parameterHandle, interactionClassHandle)); }
358
359     RTI::ObjectHandle getObjectInstanceHandle(const std::string& name)
360     { return _rtiAmbassador.getObjectInstanceHandle(name.c_str()); }
361     std::string getObjectInstanceName(const RTI::ObjectHandle& objectHandle)
362     { return rtiToStdString(_rtiAmbassador.getObjectInstanceName(objectHandle)); }
363
364     // RTIHandle getRoutingSpaceHandle(const std::string& routingSpaceName)
365     // {
366     //     try {
367     //         return _rtiAmbassador.getRoutingSpaceHandle(routingSpaceName.c_str());
368     //     } catch (RTI::NameNotFound& e) {
369     //     } catch (RTI::FederateNotExecutionMember& e) {
370     //     } catch (RTI::ConcurrentAccessAttempted& e) {
371     //     } catch (RTI::RTIinternalError& e) {
372     //     }
373     //     return RTIHandle(-1);
374     // }
375     // std::string getRoutingSpaceName(const RTIHandle& routingSpaceHandle)
376     // {
377     //     std::string routingSpaceName;
378     //     try {
379     //         rtiToStdString(routingSpaceName, _rtiAmbassador.wgetRoutingSpaceName(routingSpaceHandle));
380     //     } catch (RTI::SpaceNotDefined& e) {
381     //     } catch (RTI::FederateNotExecutionMember& e) {
382     //     } catch (RTI::ConcurrentAccessAttempted& e) {
383     //     } catch (RTI::RTIinternalError& e) {
384     //     }
385     //     return routingSpaceName;
386     // }
387
388     void enableClassRelevanceAdvisorySwitch()
389     { _rtiAmbassador.enableClassRelevanceAdvisorySwitch(); }
390     void disableClassRelevanceAdvisorySwitch()
391     { _rtiAmbassador.disableClassRelevanceAdvisorySwitch(); }
392
393     void enableAttributeRelevanceAdvisorySwitch()
394     { _rtiAmbassador.enableAttributeRelevanceAdvisorySwitch(); }
395     void disableAttributeRelevanceAdvisorySwitch()
396     { _rtiAmbassador.disableAttributeRelevanceAdvisorySwitch(); }
397
398     void enableAttributeScopeAdvisorySwitch()
399     { _rtiAmbassador.enableAttributeScopeAdvisorySwitch(); }
400     void disableAttributeScopeAdvisorySwitch()
401     { _rtiAmbassador.disableAttributeScopeAdvisorySwitch(); }
402
403     void enableInteractionRelevanceAdvisorySwitch()
404     { _rtiAmbassador.enableInteractionRelevanceAdvisorySwitch(); }
405     void disableInteractionRelevanceAdvisorySwitch()
406     { _rtiAmbassador.disableInteractionRelevanceAdvisorySwitch(); }
407
408
409     bool tick()
410     { return _rtiAmbassador.tick(); }
411     bool tick(double minimum, double maximum)
412     { return _rtiAmbassador.tick(minimum, maximum); }
413
414
415     static SGTimeStamp toTimeStamp(const RTI::FedTime& fedTime)
416     {
417         RTIfedTime referenceTime(fedTime);
418         return SGTimeStamp::fromSec(referenceTime.getTime() + 0.5e-9);
419     }
420
421     static RTIfedTime toFedTime(const SGTimeStamp& timeStamp)
422     {
423         RTIfedTime referenceTime;
424         referenceTime.setZero();
425         referenceTime += timeStamp.toSecs();
426         return referenceTime;
427     }
428
429     static std::string rtiToStdString(char* n)
430     {
431         if (!n)
432             return std::string();
433         std::string s;
434         s.assign(n);
435         delete[] n;
436         return s;
437     }
438
439     // The connection class
440     RTI::RTIambassador _rtiAmbassador;
441     SGWeakPtr<RTI13Federate> _federate;
442 };
443
444 } // namespace simgear
445
446 #endif