ADTF  3.18.2
builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/sys/system.h
Go to the documentation of this file.
1 
7 #ifndef _SYSTEM_CLASS_HEADER_
8 #define _SYSTEM_CLASS_HEADER_
9 
10 namespace A_UTILS_NS
11 {
12 
14 #define MAX_ETHERNET_PHYSICAL_ADDRESS_LENGTH 6
15 
21 class DOEXPORT cSystem
22 {
23  public:
24 
29  {
30  public:
38  virtual tResult HandleAdapterInfo(const tChar* strName,
39  const tChar* strDescription,
40  tUInt8* pui8PhysicalAddress) = 0;
41  };
42 
47  {
48  public:
52  struct tAdapterInfo
53  {
60  };
61 
62  private:
63  std::vector<tAdapterInfo> m_vecAdapters;
64 
65  public:
67  const tChar* strDescription,
68  tUInt8* pui8PhysicalAddress)
69  {
70  m_vecAdapters.resize(m_vecAdapters.size() + 1);
71  m_vecAdapters.back().strAdapterName = strName;
72  m_vecAdapters.back().strDescription = strDescription;
73  cMemoryBlock::MemCopy(m_vecAdapters.back().aui8PhysicalAddress,
74  pui8PhysicalAddress,
77  }
78 
83  tBool Empty() const
84  {
85  return m_vecAdapters.empty();
86  }
87 
92  tSize Size() const
93  {
94  return m_vecAdapters.size();
95  }
96 
102  const tAdapterInfo& At(tUInt nPos)
103  {
104  return m_vecAdapters.at(nPos);
105  }
106  };
107 
108 
114 
120  static cString GetLastErrorString(const tUInt32 ui32Error);
121 
133  static cString GetEnvVariable(const cString& strName, const cString& strDefaultValue="");
134 
144  static tResult SetEnvVariable(const cString& strName, const cString& strValue);
145 
154 
162 
179  static tInt32 Execute(const cFilename& strExeFile,
180  const cString& strArgs = "",
181  const cFilename& strWorkingPath ="",
182  const tBool bModal = tFalse,
183  cString* pOutput = nullptr,
184  const cFilename oStdErrForward = "");
185 
193  static tResult ChildExecute(tUInt64* pChildProcessId,
194  const cFilename& strExeFile,
195  const cString& strArgs = "");
196 
204  static tResult ChildWait(tUInt64 nChildProcessId, tTimeStamp tmTimeOut = -1);
205 
211  static tResult ChildTerminate(tUInt64 nChildProcessId);
212 
230  static tUInt32 OpenDocument(tHandle hWndParent,
231  const cFilename& strFilename,
232  const cString& strWorkingPath = "",
233  tBool bModal = tFalse,
234  tBool bMessage = tFalse);
235 
247  static tUInt32 OpenFolder(tHandle hWndParent,
248  const cFilename& strFilename,
249  tHandle &hProcessHandle,
250  tBool bModal = tFalse);
251 
260  static tTimeStamp GetTime();
261 
267  static tVoid Sleep(tTimeStamp tmMicroseconds);
268 
274  static tResult GetMACAddress(cString& strMACAddress);
275 
283 
290 
297 
304 
311 
318 
325 
332 
339 
346  static tUInt64 GetPhysicalMemoryUsed(tBool bIncludeCaches = tFalse);
347 
354 
363  static tResult GetMallocInfo(tUInt64& nMallocTotal, tUInt64& nMallocFree, tUInt64& nMallocUsed);
364 
370  static tResult HasIfaceWithMAC(const cString& strMACAddress);
371 
383  static tBool QueryDriveSpace(const cString &strDriveLetter,
384  tUInt64 &uint64FreeSize);
385 
392  static tResult SwapEndian(tUInt8* pui8Value);
393 
400  static tResult SwapEndian(tInt8* pi8Value);
401 
408  static tResult SwapEndian(tUInt16* pui16Value);
409 
416  static tResult SwapEndian(tInt16* pi16Value);
417 
424  static tResult SwapEndian(tUInt32* pui32Value);
425 
432  static tResult SwapEndian(tInt32* pi32Value);
433 
440  static tResult SwapEndian(tUInt64* pui64Value);
441 
448  static tResult SwapEndian(tInt64* pi64Value);
449 
456  static tResult HostToNetwork(tUInt16* pui16Value);
457 
464  static tResult HostToNetwork(tUInt32* pui32Value);
465 
472  static tResult HostToNetwork(tUInt64* pui64Value);
473 
480  static tResult NetworkToHost(tUInt16* pui16Value);
481 
488  static tResult NetworkToHost(tUInt32* pui32Value);
489 
496  static tResult NetworkToHost(tUInt64* pui64Value);
497 
498 
511  const cString &strOriginator,
512  const cString &strOriginatorName,
513  const cString &strRecipient,
514  const cString &strRecipientName,
515  const cString &strSubject,
516  const cString &strText,
517  const cString &strFilePath);
518 
526 };
527 
528 } // namespace A_UTILS_NS
529 
530 #endif // _SYSTEM_CLASS_HEADER_
uint8_t tUInt8
type definition for unsigned integer values (8bit) (platform and compiler independent type).
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
int64_t tInt64
type definition for signed integer values (64bit) (platform and compiler independent type).
int16_t tInt16
type definition for signed integer values (16bit) (platform and compiler independent type).
int32_t tInt32
type definition for signed integer values (32bit) (platform and compiler independent type).
unsigned int tUInt
type definition for unsigned integer value (platform and compiler dependent type).
void tVoid
The tVoid is always the definition for the void (non-type).
uint16_t tUInt16
type definition for unsigned integer values (16bit) (platform and compiler independent type).
tVoid * tHandle
type definition for a handle value (platform and compiler dependent type).
int tInt
type definition for signed integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
uint32_t tUInt32
type definition for unsigned integer values (32bit) (platform and compiler independent type).
size_t tSize
type definition for a array size values, map size values etc.
int8_t tInt8
type definition for signed integer values (8bit) (platform and compiler independent type).
uint64_t tUInt64
type definition for unsigned integer values (64bit) (platform and compiler independent type).
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
File name class.
Definition: filename.h:59
static tVoid MemCopy(tVoid *pDest, const tVoid *pSrc, tSize nCount)
Copies data from one buffer to another.
virtual tResult HandleAdapterInfo(const tChar *strName, const tChar *strDescription, tUInt8 *pui8PhysicalAddress)=0
This will be called for each available ethernet adapter.
tResult HandleAdapterInfo(const tChar *strName, const tChar *strDescription, tUInt8 *pui8PhysicalAddress)
This will be called for each available ethernet adapter.
const tAdapterInfo & At(tUInt nPos)
Returns the given adapter information at position nPos.
static tUInt64 GetVirtualMemoryUsedByMe()
Returns the amount of virtual memory currently used by the calling process.
static tResult SwapEndian(tInt8 *pi8Value)
Swaps the bytes of a 8 Bit value in place.
static tTimeStamp GetTime()
On Windows platform method will return elapsed time in microseconds since the system was started.
static tResult HasIfaceWithMAC(const cString &strMACAddress)
Checks whether he host as an interface with a specific MAC address.
static cString GetLastErrorString(const tUInt32 ui32Error)
Returns a descriptive string of the last error.
static tResult NetworkToHost(tUInt16 *pui16Value)
Swaps the bytes of a 16 Bit value from network to host byte order.
static tUInt32 GetLastSystemError()
Returns the last system error.
static tResult SwapEndian(tUInt16 *pui16Value)
Swaps the bytes of a 16 Bit value in place.
static tUInt64 GetCurrentProcessId()
Returns the current process id.
static cString GetEnvVariable(const cString &strName, const cString &strDefaultValue="")
This function fetches values from the system's environment configuration.
static tVoid Sleep(tTimeStamp tmMicroseconds)
The calling thread will sleep for the specified amount of time.
static tUInt64 GetVirtualUserMemoryTotal()
Returns the total amount of virtual memory for User-mode applications.
static tUInt64 GetVirtualMemoryUsed()
Returns the amount of virtual memory currently used (system global)
static tInt32 Execute(const cFilename &strExeFile, const cString &strArgs="", const cFilename &strWorkingPath="", const tBool bModal=tFalse, cString *pOutput=nullptr, const cFilename oStdErrForward="")
Starts an executable and optionally wait for the application to close down.
static tResult HostToNetwork(tUInt32 *pui32Value)
Swaps the bytes of a 32 Bit value from host to network byte order.
static tUInt64 GetVirtualUserMemoryUsed()
Returns the amount of virtual user memory currently used (process)
static tResult ChildTerminate(tUInt64 nChildProcessId)
Terminates a child process.
static tUInt64 GetPhysicalMemoryUsedByMe()
Returns the amount of physical memory currently used by the calling process.
static tResult SetEnvVariable(const cString &strName, const cString &strValue)
This function creates a system's environment variable for the current execution.
static cString GetUserName()
This function gets the user name currently logged on.
static tResult SwapEndian(tInt32 *pi32Value)
Swaps the bytes of a 32 Bit value in place.
static tBool QueryDriveSpace(const cString &strDriveLetter, tUInt64 &uint64FreeSize)
This Function retrieves the free disk space in bytes for the specified location (win32).
static tResult SwapEndian(tUInt8 *pui8Value)
Swaps the bytes of a 8 Bit value in place.
static tResult GetEthernetAdapterInfo(IAdapterInfoCallback *pAdapterInfo)
Returns all detected ethernet adapters.
static tResult NetworkToHost(tUInt32 *pui32Value)
Swaps the bytes of a 32 Bit value from network to host byte order.
static tResult HostToNetwork(tUInt64 *pui64Value)
Swaps the bytes of a 64 Bit value from host to network byte order.
static tResult ChildWait(tUInt64 nChildProcessId, tTimeStamp tmTimeOut=-1)
Wait until a child process exits.
static tInt32 GetCurrentThreadId()
Returns the current thread id.
static tResult SwapEndian(tUInt32 *pui32Value)
Swaps the bytes of a 32 Bit value in place.
static tResult GetMallocInfo(tUInt64 &nMallocTotal, tUInt64 &nMallocFree, tUInt64 &nMallocUsed)
Returns information about the status of malloc memory handling.
static cString GetComputerName()
This function gets the name of the local computer.
static tUInt64 GetPhysicalMemoryUsed(tBool bIncludeCaches=tFalse)
Returns the amount of physical memory currently used (system global)
static tUInt32 OpenDocument(tHandle hWndParent, const cFilename &strFilename, const cString &strWorkingPath="", tBool bModal=tFalse, tBool bMessage=tFalse)
Opens a document with the registered standard application.
static tResult ChildExecute(tUInt64 *pChildProcessId, const cFilename &strExeFile, const cString &strArgs="")
Starts a child process.
static tInt GetProcessorCount()
Returns the count of processors.
static tResult SwapEndian(tInt64 *pi64Value)
Swaps the bytes of a 64 Bit value in place.
static tResult HostToNetwork(tUInt16 *pui16Value)
Swaps the bytes of a 16 Bit value from host to network byte order.
static tResult GetMACAddress(cString &strMACAddress)
Returns the MAC Address of the first networking interface.
static tUInt64 GetPhysicalMemoryTotal()
Returns the total amount of physical memory.
static tUInt64 GetVirtualMemoryTotal()
Returns the total amount of virtual memory.
static tResult SwapEndian(tUInt64 *pui64Value)
Swaps the bytes of a 64 Bit value in place.
static tResult NetworkToHost(tUInt64 *pui64Value)
Swaps the bytes of a 64 Bit value from network to host byte order.
static tResult SwapEndian(tInt16 *pi16Value)
Swaps the bytes of a 16 Bit value in place.
static tUInt32 OpenFolder(tHandle hWndParent, const cFilename &strFilename, tHandle &hProcessHandle, tBool bModal=tFalse)
Opens an Explorer window that points to the specified folder.
static tResult SendMail(const cString &strOriginator, const cString &strOriginatorName, const cString &strRecipient, const cString &strRecipientName, const cString &strSubject, const cString &strText, const cString &strFilePath)
Sends an email (win32).
#define tFalse
Value for tBool.
Definition: constants.h:60
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
Definition: d_ptr.h:11