~ubuntu-branches/ubuntu/wily/openms/wily

« back to all changes in this revision

Viewing changes to source/APPLICATIONS/UTILS/OpenMSInfo.C

  • Committer: Package Import Robot
  • Author(s): Filippo Rusconi
  • Date: 2013-12-20 11:30:16 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131220113016-wre5g9bteeheq6he
Tags: 1.11.1-3
* remove version number from libbost development package names;
* ensure that AUTHORS is correctly shipped in all packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- mode: C++; tab-width: 2; -*-
2
 
// vi: set ts=2:
3
 
//
4
 
// --------------------------------------------------------------------------
5
 
//                   OpenMS Mass Spectrometry Framework
6
 
// --------------------------------------------------------------------------
7
 
//  Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
8
 
//
9
 
//  This library is free software; you can redistribute it and/or
10
 
//  modify it under the terms of the GNU Lesser General Public
11
 
//  License as published by the Free Software Foundation; either
12
 
//  version 2.1 of the License, or (at your option) any later version.
13
 
//
14
 
//  This library is distributed in the hope that it will be useful,
15
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 
//  Lesser General Public License for more details.
18
 
//
19
 
//  You should have received a copy of the GNU Lesser General Public
20
 
//  License along with this library; if not, write to the Free Software
21
 
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
1
// --------------------------------------------------------------------------
 
2
//                   OpenMS -- Open-Source Mass Spectrometry
 
3
// --------------------------------------------------------------------------
 
4
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
 
5
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
 
6
//
 
7
// This software is released under a three-clause BSD license:
 
8
//  * Redistributions of source code must retain the above copyright
 
9
//    notice, this list of conditions and the following disclaimer.
 
10
//  * Redistributions in binary form must reproduce the above copyright
 
11
//    notice, this list of conditions and the following disclaimer in the
 
12
//    documentation and/or other materials provided with the distribution.
 
13
//  * Neither the name of any author or any participating institution
 
14
//    may be used to endorse or promote products derived from this software
 
15
//    without specific prior written permission.
 
16
// For a full list of authors, refer to the file AUTHORS.
 
17
// --------------------------------------------------------------------------
 
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
19
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
20
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
21
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
 
22
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
23
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
24
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 
25
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 
26
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 
27
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 
28
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
29
//
23
30
// --------------------------------------------------------------------------
24
31
// $Maintainer: Chris Bielow $
42
49
  {
43
50
 
44
51
    enum OpenMS_OS {OS_UNKNOWN, OS_MACOS, OS_WINDOWS, OS_LINUX};
45
 
    std::string OpenMS_OSNames[] = {"unkown","MacOS","Windows","Linux"};
 
52
    std::string OpenMS_OSNames[] = {"unkown", "MacOS", "Windows", "Linux"};
46
53
    enum OpenMS_Architecture {ARCH_UNKOWN, ARCH_32BIT, ARCH_64BIT};
47
 
    std::string OpenMS_ArchNames[] = {"unkown","32bit","64bit"};
 
54
    std::string OpenMS_ArchNames[] = {"unkown", "32bit", "64bit"};
48
55
 
49
56
#if WIN32
50
57
    OpenMS_Architecture getArchOnWin();
53
60
 
54
61
    struct OpenMSOSInfo
55
62
    {
56
 
      OpenMSOSInfo()
57
 
        : os(OS_UNKNOWN),
58
 
          os_version("unkown"),
59
 
          arch(ARCH_UNKOWN)
 
63
      OpenMSOSInfo() :
 
64
        os(OS_UNKNOWN),
 
65
        os_version("unkown"),
 
66
        arch(ARCH_UNKOWN)
60
67
      {}
61
68
 
62
69
      OpenMS_OS os;
67
74
      {
68
75
        return OpenMS_OSNames[os];
69
76
      }
 
77
 
70
78
      String getArchAsString() const
71
79
      {
72
80
        return OpenMS_ArchNames[arch];
73
81
      }
 
82
 
74
83
    };
75
84
 
76
85
    static OpenMSOSInfo getOSInfo()
77
86
    {
78
87
      OpenMSOSInfo info;
79
 
#if defined (WIN32) // Windows
 
88
#if defined(WIN32)  // Windows
80
89
      info.os = OS_WINDOWS;
81
90
      info.arch = getArchOnWin();
82
91
      info.os_version = getWinOSVersion();
83
92
#elif (defined(__MACH__) && defined(__APPLE__)) // MacOS
84
93
      info.os = OS_MACOS;
85
94
 
86
 
// check if we can use QSysInfo 
 
95
// check if we can use QSysInfo
87
96
#if defined(Q_WS_MAC)
88
 
                        // identify 
89
 
                        switch (QSysInfo::MacintoshVersion)
90
 
                        {
91
 
                                case QSysInfo::MV_10_2: 
92
 
                                {
93
 
                                        info.os_version = "10.2";
94
 
                                        break;
95
 
                                }
96
 
                                case QSysInfo::MV_10_3: 
97
 
                                {
98
 
                                        info.os_version = "10.3";
99
 
                                        break;
100
 
                                }
101
 
                                case QSysInfo::MV_10_4: 
102
 
                                {
103
 
                                        info.os_version = "10.4";
104
 
                                        break;
105
 
                                }
106
 
                                case QSysInfo::MV_10_5:
107
 
                                {
108
 
                                        info.os_version = "10.5";
109
 
                                        break;
110
 
                                }
111
 
                                case QSysInfo::MV_10_6:
112
 
                                {
113
 
                                        info.os_version = "10.6";
114
 
                                        break;
115
 
                                }
116
 
                                default:
117
 
                                {
118
 
                                        info.os_version = "unsupported";
119
 
                                }                               
120
 
                        }
121
 
 
122
 
                        // identify architecture
123
 
                        if(QSysInfo::WordSize == 32) 
124
 
                        {
125
 
                                info.arch = ARCH_32BIT;
126
 
                        }
127
 
                        else
128
 
                        {
129
 
                                info.arch = ARCH_64BIT;                 
130
 
                        }
131
 
#endif                  
132
 
                        
 
97
      // identify
 
98
      switch (QSysInfo::MacintoshVersion)
 
99
      {
 
100
      case QSysInfo::MV_10_2:
 
101
      {
 
102
        info.os_version = "10.2";
 
103
        break;
 
104
      }
 
105
 
 
106
      case QSysInfo::MV_10_3:
 
107
      {
 
108
        info.os_version = "10.3";
 
109
        break;
 
110
      }
 
111
 
 
112
      case QSysInfo::MV_10_4:
 
113
      {
 
114
        info.os_version = "10.4";
 
115
        break;
 
116
      }
 
117
 
 
118
      case QSysInfo::MV_10_5:
 
119
      {
 
120
        info.os_version = "10.5";
 
121
        break;
 
122
      }
 
123
 
 
124
      case QSysInfo::MV_10_6:
 
125
      {
 
126
        info.os_version = "10.6";
 
127
        break;
 
128
      }
 
129
 
 
130
      default:
 
131
      {
 
132
        info.os_version = "unsupported";
 
133
      }
 
134
      }
 
135
 
 
136
      // identify architecture
 
137
      if (QSysInfo::WordSize == 32)
 
138
      {
 
139
        info.arch = ARCH_32BIT;
 
140
      }
 
141
      else
 
142
      {
 
143
        info.arch = ARCH_64BIT;
 
144
      }
 
145
#endif
 
146
 
133
147
#else //Linux
134
148
      info.os = OS_LINUX;
135
149
      //TODO
145
159
#include <windows.h>
146
160
#include <stdio.h>
147
161
 
148
 
    typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
 
162
    typedef BOOL (WINAPI * LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
149
163
 
150
164
    LPFN_ISWOW64PROCESS fnIsWow64Process;
151
165
 
153
167
    {
154
168
#ifdef OPENMS_64BIT_ARCHITECTURE
155
169
      return ARCH_64BIT;
 
170
 
156
171
#else
157
172
      BOOL bIsWow64 = FALSE;
158
173
 
161
176
      //and GetProcAddress to get a pointer to the function if available.
162
177
 
163
178
      fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
164
 
          GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
 
179
        GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
165
180
 
166
 
      if(NULL != fnIsWow64Process)
 
181
      if (NULL != fnIsWow64Process)
167
182
      {
168
 
          if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
169
 
          {
170
 
             return ARCH_UNKOWN;
171
 
          }
 
183
        if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
 
184
        {
 
185
          return ARCH_UNKOWN;
 
186
        }
172
187
      }
173
188
      if (bIsWow64)
174
189
      {
189
204
      GetVersionEx(&osvi);
190
205
      return String(osvi.dwMajorVersion) + "." + String(osvi.dwMinorVersion);
191
206
    }
 
207
 
192
208
#endif // WIN32 API functions
193
209
 
194
210
  } // NS Internal
198
214
// We do not want this class to show up in the docu:
199
215
/// @cond TOPPCLASSES
200
216
 
201
 
int main( int /*argc*/, const char** /*argv*/ )
 
217
int main(int /*argc*/, const char ** /*argv*/)
202
218
{
203
 
        cout << "OpenMS Version:" << "\n";
204
 
        cout << "==================" << "\n";
205
 
        cout << "Version      : " << VersionInfo::getVersion() << "\n";
206
 
        cout << "Build time   : " << VersionInfo::getTime() << "\n";
207
 
        cout << "SVN revision : " << VersionInfo::getRevision() << "\n";
208
 
        cout << "\n";
209
 
        cout << "Installation information:" << "\n";
210
 
        cout << "==================" << "\n";
 
219
  cout << "OpenMS Version:" << "\n";
 
220
  cout << "==================" << "\n";
 
221
  cout << "Version      : " << VersionInfo::getVersion() << "\n";
 
222
  cout << "Build time   : " << VersionInfo::getTime() << "\n";
 
223
  cout << "SVN revision : " << VersionInfo::getRevision() << "\n";
 
224
  cout << "\n";
 
225
  cout << "Installation information:" << "\n";
 
226
  cout << "==================" << "\n";
211
227
  cout << "Data path    : " << File::getOpenMSDataPath() << "\n";
212
228
  cout << "Temp path    : " << File::getTempDirectory() << "\n";
213
229
  cout << "Userdata path: " << File::getUserDirectory() << "\n";
214
230
 
215
 
        cout << "\n";
216
 
        cout << "Build information:" << "\n";
217
 
        cout << "==================" << "\n";
218
 
        cout << "Source path  : " << OPENMS_SOURCE_PATH << "\n";
219
 
        cout << "Binary path  : " << OPENMS_BINARY_PATH << "\n";
220
 
        cout << "\n";
 
231
  cout << "\n";
 
232
  cout << "Build information:" << "\n";
 
233
  cout << "==================" << "\n";
 
234
  cout << "Source path  : " << OPENMS_SOURCE_PATH << "\n";
 
235
  cout << "Binary path  : " << OPENMS_BINARY_PATH << "\n";
 
236
  cout << "\n";
221
237
 
222
238
  OpenMS::Internal::OpenMSOSInfo info = OpenMS::Internal::getOSInfo();
223
239
  // experimental: OS information
224
240
  cout << "OS Information:" << "\n";
225
 
        cout << "==================" << "\n";
 
241
  cout << "==================" << "\n";
226
242
  cout << "Name: " << info.getOSAsString() << "\n";
227
243
  cout << "Version: " << info.os_version << "\n";
228
244
  cout << "Architecture: " << info.getArchAsString() << "\n";
229
 
        cout << "\n";
230
 
 
231
 
 
232
 
        return 0;
 
245
  cout << "\n";
 
246
 
 
247
 
 
248
  return 0;
233
249
}
234
250
 
235
251
/// @endcond
236
 
 
237
 
 
238