MAK RTIspy API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rtiUtil.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2003 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: rtiUtil.h,v $ $Revision: 1.23 $ $State: Exp $
7 *********************************************************************/
8 
11 
12 #ifndef DtRtiUtil_H_
13 #define DtRtiUtil_H_
14 
15 #include "rtiMsConfig.h"
16 
17 #include <set>
18 #include <map>
19 #include <algorithm>
20 #include <utility>
21 #include <vector>
22 
23 #include <vlutil/vlPrint.h>
24 #include <vlutil/vlFilename.h>
25 #include <vlutil/vlUtil.h>
26 #include <vlutil/vlPrint.h>
27 #include <vlutil/vlExceptions.h>
28 #include <vlutil/vlString.h>
29 #include <vlutil/vlInetAddr.h>
30 
31 #ifndef _WIN32
32 #ifndef __sgi__
33 #ifndef __solaris__
34 #include <netinet/if_ether.h>
35 #include <net/if.h>
36 #endif
37 #endif
38 #endif
39 
40 
41 const unsigned int DtGreatestValidPortNumber = 65535;
42 
44 DT_DLL_RTIUTIL void DtRtiAttachNotificationPrinter( MAKRti::DtNotifyLevelType level, MAKRti::DtPrinter* printer );
45 
47 DT_DLL_RTIUTIL void DtRtiDetachNotificationPrinter( MAKRti::DtNotifyLevelType level, MAKRti::DtPrinter* printer );
48 
51 DT_DLL_RTIUTIL MAKRti::DtFilename DtRtiSearchPathList( const MAKRti::DtFilename& libName,
52  const MAKRti::DtString& searchPath = "" );
53 
56 DT_DLL_RTIUTIL MAKRti::DtFilename DtRtiLibPath(const MAKRti::DtString& searchPath = "");
57 
58 
71 DT_DLL_RTIUTIL bool DtLocateConfigFile(MAKRti::DtFilename const& fileName, MAKRti::DtFilename& locatedFileName);
72 
79 DT_DLL_RTIUTIL bool DtNonBlockingPollInputLine(MAKRti::DtString& buffer);
80 
81 
85 
89 
91 
93 DT_DLL_RTIUTIL bool DtReadFile( FILE* fileHandle,
94  char** fileBuffer, unsigned int* fileSize);
95 
98 int DtBitsRequiredToRepresent(unsigned long x);
99 
100 
102 DT_DLL_RTIUTIL const MAKRti::DtString& DtGetLocalHostName();
103 
108 DT_DLL_RTIUTIL MAKRti::DtString DtPerformDNSLookup(MAKRti::DtInetAddr addr);
109 
111 DT_DLL_RTIUTIL MAKRti::DtException const& DtInitialException(MAKRti::DtException const& ex);
112 
115 DT_DLL_RTIUTIL MAKRti::DtOutputStream& DtRtiOutputStream( MAKRti::DtNotifyLevelType level );
116 
117 typedef std::pair< MAKRti::DtInetAddr, int > DtInetAddrAndPort;
118 
119 #ifdef _WIN32
120 DT_DLL_RTIUTIL void getRegKey( MAKRti::DtString& val, HKEY rootKey,
121  const MAKRti::DtString& keyPath, const MAKRti::DtString& keyName );
122 DT_DLL_RTIUTIL void setRegKey( const MAKRti::DtString& keyVal, HKEY rootKey,
123  const MAKRti::DtString& keyPath, const MAKRti::DtString& keyName,
124  bool expand );
125 DT_DLL_RTIUTIL void removeRegKey( HKEY rootKey, const MAKRti::DtString& keyPath,
126  const MAKRti::DtString& keyName );
127 
128 DT_DLL_RTIUTIL void setEnvVar( const MAKRti::DtString &val, const MAKRti::DtString& name,
129  bool isSystem, bool expand ) ;
130 DT_DLL_RTIUTIL void getEnvVar( MAKRti::DtString& val, const MAKRti::DtString& name, bool isSystem );
131 DT_DLL_RTIUTIL void removeEnvVar( const MAKRti::DtString& name, bool isSystem );
132 
133 DT_DLL_RTIUTIL void expandEnvVar(MAKRti::DtString& outVar );
134 DT_DLL_RTIUTIL bool canWriteSystemPath();
135 DT_DLL_RTIUTIL bool canWriteUserPath();
136 
137 
138 
139 DT_DLL_RTIUTIL MAKRti::DtString getAssistantRegistryString();
140 DT_DLL_RTIUTIL void getSystemRunLocation(HKEY& rootKey, MAKRti::DtString& regPath);
141 DT_DLL_RTIUTIL void getUserRunLocation(HKEY& rootKey, MAKRti::DtString& regPath);
142 #endif
143 
144 DT_DLL_RTIUTIL void shutdownAssistant(bool force
145 #ifdef _WIN32
146  , std::pair< void*, void* > & resultInfo );
147 #else
148  );
149 #endif
151 
153 {
159 };
160 
162 {
167 };
168 
170 {
175 };
176 
179 DT_DLL_RTIUTIL void queryAssistantStartup( bool& isStartupItem, bool& isUserStartupItem );
180 
181 
184 #define DtRtiFatal DtRtiOutputStream( MAKRti::DtNlFatal )
185 #define DtRtiWarn DtRtiOutputStream( MAKRti::DtNlWarn )
186 #define DtRtiInfo DtRtiOutputStream( MAKRti::DtNlInfo )
187 #define DtRtiVerbose DtRtiOutputStream( MAKRti::DtNlVerbose )
188 #define DtRtiDebug DtRtiOutputStream( MAKRti::DtNlDebug )
189 
191 #define DtIsMember(container, element) (container.find(element) != container.end())
192 
194 template<class T> void DtDeleteVectorOfPointers(T& pointerVector)
195 {
198  typename T::iterator iter = pointerVector.begin();
199  while (iter != pointerVector.end())
200  {
201  delete *iter;
202  iter = pointerVector.erase(iter);
203  }
204 }
205 
209 template<class T> class DtDeepCopyPointerIntoVector
210 {
211 private:
212  std::vector<T*>& myVector;
213 public:
215  DtDeepCopyPointerIntoVector(std::vector<T*>& targetVector) : myVector(targetVector)
216  {
219  }
220 
222  void operator() (T* element)
223  {
224  if (!element)
225  {
226  myVector.push_back(element);
227  }
228  else
229  {
230  myVector.push_back(new T(*element));
231  }
232  }
233 };
234 
235 
237 template<class T> void DtDeleteSetOfPointers(T& pointerSet)
238 {
241  typename T::iterator iter = pointerSet.begin();
242  while (iter != pointerSet.end())
243  {
244  delete *iter;
245  pointerSet.erase(iter);
246  iter = pointerSet.begin();
247  }
248 }
249 
250 
251 
255 template<class T> class DtDeepCopyPointerIntoSet
256 {
257 private:
258  std::set<T*>& mySet;
259 public:
261  DtDeepCopyPointerIntoSet(std::set<T*>& targetSet) : mySet(targetSet)
262  {
265  }
266 
268  void operator() (T* element)
269  {
270  if (!element)
271  {
272  mySet.insert(element);
273  }
274  else
275  {
276  mySet.insert(new T(*element));
277  }
278  }
279 };
280 
281 
287 template<class T, class Y> class DtDeepCopyPointerIntoMap
288 {
289 private:
290  std::map<T*, Y>& myMap;
291 public:
293  DtDeepCopyPointerIntoMap(std::map<T*, Y>& targetMap) : myMap(targetMap)
294  {
296  typename std::map<T*, Y>::iterator iter = myMap.begin();
297  typename std::map<T*, Y>::iterator theEnd = myMap.end();
298  for ( ; iter != theEnd; ++iter )
299  {
300  delete iter->first;
301  }
302  myMap.clear();
303  }
304 
306  void operator() (const std::pair<T* const, Y> element)
307  {
308  if (!element.first)
309  {
310  myMap.insert(element);
311  }
312  else
313  {
314  myMap.insert(std::make_pair(new T(*element.first), element.second));
315  }
316  }
317 };
318 
319 
323 template< typename T, typename TContainer >
324 bool DtUNIQUE_INSERT( const T& value, TContainer& container )
325 {
326  typename TContainer::iterator pos = std::find( container.begin(), container.end(), value );
327  if ( pos != container.end() )
328  {
330  return false;
331  }
332  else
333  {
334  container.insert( pos, value );
335  return true;
336  }
337 };
338 
340 #ifdef DtTHROW_PROPAGATE
341 #undef DtTHROW_PROPAGATE
342 #endif
343 #define DtTHROW_PROPAGATE(exceptionClass,errorMsg, exPtr) \
344  throw exceptionClass(MAKRti::DtString(#exceptionClass": ") + errorMsg, __DtFUNC__, MAKRti::DtFilename::stripPath(__FILE__), __LINE__, exPtr)
345 
347 {
351 };
352 
353 typedef MAKRti::DtTemplatedException<DtRtiExceptionDesignatorDefault> DtRtiException;
354 typedef MAKRti::DtTemplatedException<DtRtiExceptionDesignatorPopup> DtRtiExceptionPopup;
355 typedef MAKRti::DtTemplatedException<DtRtiExceptionDesignatorInvalidRidExpression> DtRtiExceptionInvalidRidExpression;
356 
357 
359 DT_DLL_RTIUTIL MAKRti::DtInetAddr DtDefaultInterfaceAddr();
360 
364 #ifndef __solaris__
365 #ifndef __sgi__
366 DT_DLL_RTIUTIL int DtEnumerateInterfaces(std::vector<MAKRti::DtInetAddr>& addresses,
367  bool ignoreLoopback);
370 DT_DLL_RTIUTIL bool DtIsIpOfLocalInterface(const MAKRti::DtInetAddr& addrInQuestion, bool refresh = false);
371 #endif // sgi
372 #endif // solaris
373 
374 DT_DLL_RTIUTIL unsigned long long DtFirstHostMACAddr();
375 
376 
377 
378 
379 #endif

Document ID: Generated on Wed Mar 11 20:26:49 EDT 2015 from SVN revision 150939
Copyright © 2005-2015 VT MÄK Inc. All Rights Reserved (www.mak.com)