Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
System.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Barbarian Group
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #pragma once
24 
25 #include "cinder/Cinder.h"
26 
27 #include <vector>
28 #include <string>
29 #include <iostream>
30 
31 namespace cinder {
32 
35 class System {
36  public:
38  static bool hasSse2();
40  static bool hasSse3();
42  static bool hasSse4_1();
44  static bool hasSse4_2();
46  static bool hasX86_64();
48  static bool hasArm();
50  static int getNumCpus();
52  static int getNumCores();
55  static int getOsMajorVersion();
58  static int getOsMinorVersion();
61  static int getOsBugFixVersion();
62 
64  static bool hasMultiTouch();
66  static int32_t getMaxMultiTouchPoints();
68  static std::string demangleTypeName( const char *mangledName );
69 
70 #if defined( CINDER_COCOA_TOUCH )
71  static bool isDeviceIphone();
72  static bool isDeviceIpad();
73 #endif
74 
77  public:
78  const std::string& getName() const { return mName; }
79  const std::string& getIpAddress() const { return mIpAddress; }
80 
82  : mName( name ), mIpAddress( ip ) {}
83 
84  private:
85  std::string mName, mIpAddress;
86  };
88  static std::vector<NetworkAdapter> getNetworkAdapters();
90  static std::string getIpAddress();
91 
92  private:
93  enum { HAS_SSE2, HAS_SSE3, HAS_SSE4_1, HAS_SSE4_2, HAS_X86_64, HAS_ARM, PHYSICAL_CPUS, LOGICAL_CPUS, OS_MAJOR, OS_MINOR, OS_BUGFIX, MULTI_TOUCH, MAX_MULTI_TOUCH_POINTS,
94 #if defined( CINDER_COCOA_TOUCH)
95  IS_IPHONE, IS_IPAD,
96 #endif
97  TOTAL_CACHE_TYPES };
98 
99  System();
100  static std::shared_ptr<System> instance();
101  static std::shared_ptr<System> sInstance;
102 
103  bool mCachedValues[TOTAL_CACHE_TYPES];
104  bool mHasSSE2, mHasSSE3, mHasSSE4_1, mHasSSE4_2, mHasX86_64, mHasArm;
105  int mPhysicalCPUs, mLogicalCPUs;
106  int32_t mOSMajorVersion, mOSMinorVersion, mOSBugFixVersion;
107  bool mHasMultiTouch;
108  uint32_t mMaxMultiTouchPoints;
109 #if defined( CINDER_MSW ) && ! defined( _WIN64 )
110  uint32_t mCPUID_EBX, mCPUID_ECX, mCPUID_EDX;
111 #endif
112 };
113 
114 inline std::ostream& operator<<( std::ostream &outp, const System::NetworkAdapter &adapter )
115 {
116  outp << adapter.getName() << std::string(": IP: ") << adapter.getIpAddress();
117  return outp;
118 }
119 
120 class SystemExc : public std::exception {
121 };
122 
124 };
125 
126 } // namespace cinder
static bool hasSse4_2()
Returns whether the system supports the SSE4.2 instruction set. Inaccurate on MSW x64...
Definition: System.cpp:325
Queries system software and hardware capabilities of the computer. Values are cached so there is low ...
Definition: System.h:35
GLsizei const GLchar ** string
Definition: GLee.h:2427
static bool hasSse4_1()
Returns whether the system supports the SSE4.1 instruction set. Inaccurate on MSW x64...
Definition: System.cpp:307
static bool hasSse2()
Returns whether the system supports the SSE2 instruction set.
Definition: System.cpp:267
static int getNumCores()
Returns the number of cores (or logical processors) in the system. A single processor dual core machi...
Definition: System.cpp:430
static int32_t getMaxMultiTouchPoints()
Returns the maximum number of simultaneous touches supported by the system's MultiTouch implementatio...
Definition: System.cpp:559
static std::vector< NetworkAdapter > getNetworkAdapters()
Returns a list of the network adapters associated with the machine. Not cached.
Definition: System.cpp:600
static int getOsBugFixVersion()
Definition: System.cpp:501
static int getOsMinorVersion()
Definition: System.cpp:477
static bool hasX86_64()
Returns whether the system supports the x86-64 instruction set. Inaccurate on MSW x64...
Definition: System.cpp:360
NetworkAdapter(const std::string &name, const std::string &ip)
Definition: System.h:81
Definition: System.h:123
static int getOsMajorVersion()
Definition: System.cpp:453
const std::string & getName() const
Definition: System.h:78
std::ostream & operator<<(std::ostream &lhs, const ColorT< float > &rhs)
Definition: Color.cpp:203
GLuint const GLchar * name
Definition: GLee.h:2259
const std::string & getIpAddress() const
Definition: System.h:79
static int getNumCpus()
Returns the number of physical processors in the system. A single processor dual core machine returns...
Definition: System.cpp:383
static bool hasMultiTouch()
Returns whether the system supports MultiTouch. Also returns true under Windows 7 in the presence of ...
Definition: System.cpp:528
Represents a single Network Adapter of the system.
Definition: System.h:76
static std::string demangleTypeName(const char *mangledName)
Returns the result of.
Definition: System.cpp:587
static std::string getIpAddress()
Returns a best guess at the machine's "IP address". Not cached. Computers often have multiple IP addr...
Definition: System.cpp:690
Definition: System.h:120
static bool hasSse3()
Returns whether the system supports the SSE3 instruction set.
Definition: System.cpp:287
static bool hasArm()
Returns whether the system supports the ARM instruction set.
Definition: System.cpp:343