00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_LANG_SYSTEM_H_
00019 #define _DECAF_LANG_SYSTEM_H_
00020
00021 #include <decaf/util/Config.h>
00022 #include <decaf/util/Map.h>
00023 #include <decaf/util/Properties.h>
00024 #include <decaf/lang/Exception.h>
00025 #include <decaf/lang/exceptions/NullPointerException.h>
00026 #include <decaf/internal/AprPool.h>
00027 #include <string>
00028
00029 namespace decaf{
00030 namespace lang{
00031
00032 class Runtime;
00033 class SystemData;
00034
00041 class DECAF_API System {
00042 private:
00043
00044 static SystemData* sys;
00045
00046 protected:
00047
00048 System();
00049
00050 public:
00051
00052 virtual ~System() {}
00053
00054 public:
00055
00074 static void arraycopy( const char* src, std::size_t srcPos,
00075 char* dest, std::size_t destPos, std::size_t length );
00076
00095 static void arraycopy( const unsigned char* src, std::size_t srcPos,
00096 unsigned char* dest, std::size_t destPos, std::size_t length );
00097
00116 static void arraycopy( const short* src, std::size_t srcPos,
00117 short* dest, std::size_t destPos, std::size_t length );
00118
00137 static void arraycopy( const int* src, std::size_t srcPos,
00138 int* dest, std::size_t destPos, std::size_t length );
00139
00158 static void arraycopy( const long long* src, std::size_t srcPos,
00159 long long* dest, std::size_t destPos, std::size_t length );
00160
00179 static void arraycopy( const float* src, std::size_t srcPos,
00180 float* dest, std::size_t destPos, std::size_t length );
00181
00200 static void arraycopy( const double* src, std::size_t srcPos,
00201 double* dest, std::size_t destPos, std::size_t length );
00202
00221 template< typename E >
00222 static void arraycopy( const E* src, std::size_t srcPos,
00223 E* dest, std::size_t destPos, std::size_t length ) {
00224
00225 if( src == NULL ) {
00226 throw decaf::lang::exceptions::NullPointerException(
00227 __FILE__, __LINE__, "Given Source Pointer was null." );
00228 }
00229
00230 if( src == NULL ) {
00231 throw decaf::lang::exceptions::NullPointerException(
00232 __FILE__, __LINE__, "Given Source Pointer was null." );
00233 }
00234
00235 for( std::size_t i = 0; i < length; ++i ) {
00236 dest[destPos+i] = src[srcPos+i];
00237 }
00238 }
00239
00248 static const util::Map<std::string, std::string>& getenv();
00249
00261 static std::string getenv( const std::string& name );
00262
00271 static void unsetenv( const std::string& name );
00272
00283 static void setenv( const std::string& name, const std::string& value );
00284
00297 static long long currentTimeMillis();
00298
00321 static long long nanoTime();
00322
00332 static int availableProcessors();
00333
00343 static decaf::util::Properties& getProperties();
00344
00358 static std::string getProperty( const std::string& key );
00359
00375 static std::string getProperty( const std::string& key, const std::string& defaultValue );
00376
00390 static std::string setProperty( const std::string& key, const std::string& value );
00391
00403 static std::string clearProperty( const std::string& key );
00404
00405 private:
00406
00414 static std::vector< std::string > getEnvArray();
00415
00421 static internal::AprPool& getAprPool();
00422
00423 private:
00424
00425 friend class decaf::lang::Runtime;
00426
00427 static void initSystem( int argc, char **argv );
00428 static void shutdownSystem();
00429
00430 };
00431
00432 }}
00433
00434 #endif