activemq-cpp-3.8.2
System.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_LANG_SYSTEM_H_
19 #define _DECAF_LANG_SYSTEM_H_
20 
21 #include <decaf/util/Config.h>
22 #include <decaf/util/Map.h>
23 #include <decaf/util/Properties.h>
24 #include <decaf/lang/Exception.h>
26 #include <decaf/internal/AprPool.h>
27 #include <string>
28 
29 namespace decaf{
30 namespace lang{
31 
32  class Runtime;
33  class SystemData;
34 
41  class DECAF_API System {
42  private:
43 
44  static SystemData* sys;
45 
46  protected:
47 
48  System();
49 
50  public:
51 
52  virtual ~System() {}
53 
54  public: // Static Methods
55 
74  static void arraycopy( const char* src, std::size_t srcPos,
75  char* dest, std::size_t destPos, std::size_t length );
76 
95  static void arraycopy( const unsigned char* src, std::size_t srcPos,
96  unsigned char* dest, std::size_t destPos, std::size_t length );
97 
116  static void arraycopy( const short* src, std::size_t srcPos,
117  short* dest, std::size_t destPos, std::size_t length );
118 
137  static void arraycopy( const int* src, std::size_t srcPos,
138  int* dest, std::size_t destPos, std::size_t length );
139 
158  static void arraycopy( const long long* src, std::size_t srcPos,
159  long long* dest, std::size_t destPos, std::size_t length );
160 
179  static void arraycopy( const float* src, std::size_t srcPos,
180  float* dest, std::size_t destPos, std::size_t length );
181 
200  static void arraycopy( const double* src, std::size_t srcPos,
201  double* dest, std::size_t destPos, std::size_t length );
202 
221  template< typename E >
222  static void arraycopy( const E* src, std::size_t srcPos,
223  E* dest, std::size_t destPos, std::size_t length ) {
224 
225  if( src == NULL ) {
227  __FILE__, __LINE__, "Given Source Pointer was null." );
228  }
229 
230  if( src == NULL ) {
232  __FILE__, __LINE__, "Given Source Pointer was null." );
233  }
234 
235  for( std::size_t i = 0; i < length; ++i ) {
236  dest[destPos+i] = src[srcPos+i];
237  }
238  }
239 
248  static const util::Map<std::string, std::string>& getenv();
249 
261  static std::string getenv( const std::string& name );
262 
271  static void unsetenv( const std::string& name );
272 
283  static void setenv( const std::string& name, const std::string& value );
284 
297  static long long currentTimeMillis();
298 
321  static long long nanoTime();
322 
332  static int availableProcessors();
333 
343  static decaf::util::Properties& getProperties();
344 
358  static std::string getProperty( const std::string& key );
359 
375  static std::string getProperty( const std::string& key, const std::string& defaultValue );
376 
390  static std::string setProperty( const std::string& key, const std::string& value );
391 
403  static std::string clearProperty( const std::string& key );
404 
405  private:
406 
414  static std::vector< std::string > getEnvArray();
415 
421  static internal::AprPool& getAprPool();
422 
423  private:
424 
425  friend class decaf::lang::Runtime;
426 
427  static void initSystem( int argc, char **argv );
428  static void shutdownSystem();
429 
430  };
431 
432 }}
433 
434 #endif /*_DECAF_LANG_SYSTEM_H_*/
#define NULL
Definition: Config.h:33
Wraps an APR pool object so that classes in decaf can create a static member for use in static method...
Definition: AprPool.h:33
virtual ~System()
Definition: System.h:52
Definition: Runtime.h:26
static void arraycopy(const E *src, std::size_t srcPos, E *dest, std::size_t destPos, std::size_t length)
Copies the number of elements specified by length from the source array starting at the given source ...
Definition: System.h:222
An object that maps keys to values.
Definition: Map.h:88
Definition: NullPointerException.h:32
#define DECAF_API
Definition: Config.h:29
The System class provides static methods for accessing system level resources and performing some sys...
Definition: System.h:41
Java-like properties class for mapping string names to string values.
Definition: Properties.h:53
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25