MAK RTIspy API Documentation for HLA 1.3
 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 #define MAKRTI_MT
41 namespace MAKRti
42 {
43  class DtClock;
44 }
45 
46 #ifdef MAKRTI_MT
47 #define MAK_STATIC
48 #else
49 #define MAK_STATIC static
50 #endif
51 
52 const unsigned int DtGreatestValidPortNumber = 65535;
53 
55 DT_DLL_RTIUTIL void DtRtiAttachNotificationPrinter( MAKRti::DtNotifyLevelType level, MAKRti::DtPrinter* printer );
56 
58 DT_DLL_RTIUTIL void DtRtiDetachNotificationPrinter( MAKRti::DtNotifyLevelType level, MAKRti::DtPrinter* printer );
59 
62 DT_DLL_RTIUTIL MAKRti::DtFilename DtRtiSearchPathList( const MAKRti::DtFilename& libName,
63  const MAKRti::DtString& searchPath = "" );
64 
67 DT_DLL_RTIUTIL MAKRti::DtFilename DtRtiLibPath(const MAKRti::DtString& searchPath = "");
68 
71 DT_DLL_RTIUTIL MAKRti::DtString& DtMakeFileNameUnique(MAKRti::DtString& fileName);
72 
75 DT_DLL_RTIUTIL MAKRti::DtFilename& DtResolveAbsoluteFileLocation(const MAKRti::DtString& path,
76  const MAKRti::DtString& fileName, MAKRti::DtFilename& resolvedFilePath);
77 
80 DT_DLL_RTIUTIL MAKRti::DtFilename& DtMakeLogFilePath(const MAKRti::DtString& baseFilePath,
81  const MAKRti::DtString& fileName, bool makeUnique, MAKRti::DtFilename& resolvedFilePath);
82 
95 DT_DLL_RTIUTIL bool DtLocateConfigFile(MAKRti::DtFilename const& fileName, MAKRti::DtFilename& locatedFileName);
96 
103 DT_DLL_RTIUTIL bool DtNonBlockingPollInputLine(MAKRti::DtString& buffer);
104 
105 
109 
112 DT_DLL_RTIUTIL int DtKBHit();
113 
114 DT_DLL_RTIUTIL void DtSetNotifyLevel(unsigned int notifyLevel);
115 
117 DT_DLL_RTIUTIL bool DtReadFile( FILE* fileHandle,
118  char** fileBuffer, unsigned int* fileSize);
119 
122 DT_DLL_RTIUTIL int DtBitsRequiredToRepresent(unsigned long x);
123 
124 
126 DT_DLL_RTIUTIL const MAKRti::DtString& DtGetLocalHostName();
127 
129 DT_DLL_RTIUTIL void DtGetLocalHostName(MAKRti::DtString& hostName);
130 
135 DT_DLL_RTIUTIL MAKRti::DtString DtPerformDNSLookup(MAKRti::DtInetAddr addr);
136 
138 DT_DLL_RTIUTIL MAKRti::DtException const& DtInitialException(MAKRti::DtException const& ex);
139 
142 DT_DLL_RTIUTIL MAKRti::DtOutputStream& DtRtiOutputStream( MAKRti::DtNotifyLevelType level );
143 
144 typedef std::pair< MAKRti::DtInetAddr, int > DtInetAddrAndPort;
145 
146 DT_DLL_RTIUTIL MAKRti::DtString addrAndPortToString(const DtInetAddrAndPort& addrPort);
147 
148 #ifdef _WIN32
149 DT_DLL_RTIUTIL void getRegKey( MAKRti::DtString& val, HKEY rootKey,
150  const MAKRti::DtString& keyPath, const MAKRti::DtString& keyName );
151 DT_DLL_RTIUTIL void setRegKey( const MAKRti::DtString& keyVal, HKEY rootKey,
152  const MAKRti::DtString& keyPath, const MAKRti::DtString& keyName,
153  bool expand );
154 DT_DLL_RTIUTIL void removeRegKey( HKEY rootKey, const MAKRti::DtString& keyPath,
155  const MAKRti::DtString& keyName );
156 
157 DT_DLL_RTIUTIL void setEnvVar( const MAKRti::DtString &val, const MAKRti::DtString& name,
158  bool isSystem, bool expand ) ;
159 DT_DLL_RTIUTIL void getEnvVar( MAKRti::DtString& val, const MAKRti::DtString& name, bool isSystem );
160 DT_DLL_RTIUTIL void removeEnvVar( const MAKRti::DtString& name, bool isSystem );
161 
162 DT_DLL_RTIUTIL void expandEnvVar(MAKRti::DtString& outVar );
163 DT_DLL_RTIUTIL bool canWriteSystemPath();
164 DT_DLL_RTIUTIL bool canWriteUserPath();
165 
166 
167 
168 DT_DLL_RTIUTIL MAKRti::DtString getAssistantRegistryString();
169 DT_DLL_RTIUTIL void getSystemRunLocation(HKEY& rootKey, MAKRti::DtString& regPath);
170 DT_DLL_RTIUTIL void getUserRunLocation(HKEY& rootKey, MAKRti::DtString& regPath);
171 #endif
172 
173 DT_DLL_RTIUTIL void shutdownAssistant(bool force
174 #ifdef _WIN32
175  , std::pair< void*, void* > & resultInfo );
176 #else
177  );
178 #endif
180 
182 {
188 };
189 
191 {
196 };
197 
199 {
204 };
205 
208 DT_DLL_RTIUTIL void queryAssistantStartup( bool& isStartupItem, bool& isUserStartupItem );
209 
210 
213 #define DtRtiFatal DtRtiOutputStream( MAKRti::DtNlFatal )
214 #define DtRtiWarn DtRtiOutputStream( MAKRti::DtNlWarn )
215 #define DtRtiInfo DtRtiOutputStream( MAKRti::DtNlInfo )
216 #define DtRtiVerbose DtRtiOutputStream( MAKRti::DtNlVerbose )
217 #define DtRtiDebug DtRtiOutputStream( MAKRti::DtNlDebug )
218 
220 #define DtIsMember(container, element) (container.find(element) != container.end())
221 
223 template<class T> void DtDeleteVectorOfPointers(T& pointerVector)
224 {
227  typename T::iterator iter = pointerVector.begin();
228  while (iter != pointerVector.end())
229  {
230  delete *iter;
231  iter = pointerVector.erase(iter);
232  }
233 }
234 
238 template<class T> class DtDeepCopyPointerIntoVector
239 {
240 private:
241  std::vector<T*>& myVector;
242 public:
244  DtDeepCopyPointerIntoVector(std::vector<T*>& targetVector) : myVector(targetVector)
245  {
248  }
249 
251  void operator() (T* element)
252  {
253  if (!element)
254  {
255  myVector.push_back(element);
256  }
257  else
258  {
259  myVector.push_back(new T(*element));
260  }
261  }
262 };
263 
264 
266 template<class T> void DtDeleteSetOfPointers(T& pointerSet)
267 {
270  typename T::iterator iter = pointerSet.begin();
271  while (iter != pointerSet.end())
272  {
273  delete *iter;
274  pointerSet.erase(iter);
275  iter = pointerSet.begin();
276  }
277 }
278 
279 
280 
284 template<class T> class DtDeepCopyPointerIntoSet
285 {
286 private:
287  std::set<T*>& mySet;
288 public:
290  DtDeepCopyPointerIntoSet(std::set<T*>& targetSet) : mySet(targetSet)
291  {
294  }
295 
297  void operator() (T* element)
298  {
299  if (!element)
300  {
301  mySet.insert(element);
302  }
303  else
304  {
305  mySet.insert(new T(*element));
306  }
307  }
308 };
309 
310 
316 template<class T, class Y> class DtDeepCopyPointerIntoMap
317 {
318 private:
319  std::map<T*, Y>& myMap;
320 public:
322  DtDeepCopyPointerIntoMap(std::map<T*, Y>& targetMap) : myMap(targetMap)
323  {
325  typename std::map<T*, Y>::iterator iter = myMap.begin();
326  typename std::map<T*, Y>::iterator theEnd = myMap.end();
327  for ( ; iter != theEnd; ++iter )
328  {
329  delete iter->first;
330  }
331  myMap.clear();
332  }
333 
335  void operator() (const std::pair<T* const, Y> element)
336  {
337  if (!element.first)
338  {
339  myMap.insert(element);
340  }
341  else
342  {
343  myMap.insert(std::make_pair(new T(*element.first), element.second));
344  }
345  }
346 };
347 
348 
352 template< typename T, typename TContainer >
353 bool DtUNIQUE_INSERT( const T& value, TContainer& container )
354 {
355  typename TContainer::iterator pos = std::find( container.begin(), container.end(), value );
356  if ( pos != container.end() )
357  {
359  return false;
360  }
361  else
362  {
363  container.insert( pos, value );
364  return true;
365  }
366 };
367 
369 #ifdef DtTHROW_PROPAGATE
370 #undef DtTHROW_PROPAGATE
371 #endif
372 #define DtTHROW_PROPAGATE(exceptionClass,errorMsg, exPtr) \
373  throw exceptionClass(MAKRti::DtString(#exceptionClass": ") + errorMsg, __DtFUNC__, MAKRti::DtFilename::stripPath(__FILE__), __LINE__, exPtr)
374 
376 {
380 };
381 
382 typedef MAKRti::DtTemplatedException<DtRtiExceptionDesignatorDefault> DtRtiException;
383 typedef MAKRti::DtTemplatedException<DtRtiExceptionDesignatorPopup> DtRtiExceptionPopup;
384 typedef MAKRti::DtTemplatedException<DtRtiExceptionDesignatorInvalidRidExpression> DtRtiExceptionInvalidRidExpression;
385 
386 DT_DLL_RTIUTIL typedef std::set<MAKRti::DtInetAddr> DtInetAddrSet;
387 
389 DT_DLL_RTIUTIL MAKRti::DtInetAddr DtDefaultInterfaceAddr();
390 
394 #ifndef __solaris__
395 #ifndef __sgi__
396 DT_DLL_RTIUTIL int DtEnumerateInterfaces(std::vector<MAKRti::DtInetAddr>& addresses,
397  bool ignoreLoopback);
400 DT_DLL_RTIUTIL bool DtIsIpOfLocalInterface(const MAKRti::DtInetAddr& addrInQuestion, bool refresh = false);
401 #endif // sgi
402 #endif // solaris
403 
404 DT_DLL_RTIUTIL unsigned long long DtFirstHostMACAddr();
405 
408 DT_DLL_RTIUTIL MAKRti::DtString timeString(const MAKRti::DtClock& clock);
409 
411 DT_DLL_RTIUTIL MAKRti::DtString timeString();
412 
414 DT_DLL_RTIUTIL void writeMessageToStdErrPipe(const MAKRti::DtString& msg);
415 
416 
417 #endif

Document ID: Generated on Mon Jul 9 10:30:41 EDT 2018 from SVN revision 190224
Copyright © 2005-2018 VT MÄK Inc. All Rights Reserved (www.mak.com)