fintp_utils
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PlatformDeps.h
Go to the documentation of this file.
1 /*
2 * FinTP - Financial Transactions Processing Application
3 * Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>
17 * or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
18 * phone +40212554577, office@allevo.ro <mailto:office@allevo.ro>, www.allevo.ro.
19 */
20 
21 #ifndef PLATFORM_DEPS_H
22 #define PLATFORM_DEPS_H
23 
24 #include "DllMainUtils.h"
25 #include <boost/cstdint.hpp>
26 #include <string>
27 using namespace std;
28 
29 namespace FinTP
30 {
33  {
34  public :
35 
36  // Path separator
37  static const string PATH_SEPARATOR;
38 
39  // Combines two paths( relative + relative or absolute + relative )
40  // <returns>The combine path</returns>
41  static string Combine( const string& path1, const string& path2 );
42 
43  // Finds the filename in the specified path
44  //<returns>The full filename( filename + extension )</returns>
45  static string GetFilename( const string& path );
46  };
47 
49  {
50  //private :
51  // Convert();
52 
53  public :
54 
55  template <class T>
56  static T ChangeEndian( T value )
57  {
58  for ( size_t i = 0; i < sizeof(T)/2; i++ )
59  {
60  char* valueAdr = reinterpret_cast<char*>( &value );
61  char temp = valueAdr[i];
62  valueAdr[i] = valueAdr[ sizeof(T)-1-i ];
63  valueAdr[ sizeof(T)-1-i ] = temp;
64  }
65  return value;
66  }
67  };
68 
70  {
71  private :
72  Platform();
73 
74  static string m_MachineName;
75  static string m_MachineUID;
76  static boost::uint16_t m_MachineHash;
77  // Path separator
78  static const string NEWLINE_SEPARATOR;
79 
80  public :
81 
82  static string GetOSName();
83  static string GetMachineName();
84  static string GetIp( const string& name="" );
85  static string GetName( const string& ip="" );
86  static string GetUID();
87  static boost::uint16_t GetUIDHash();
88  static string getNewLineSeparator();
89  };
90 
92  {
93  private :
94  Process();
95 
96  public :
97  static long GetPID();
98  };
99 }
100 
101 #endif //PLATFORM_DEPS_H