activemq-cpp-3.3.0

src/main/decaf/lang/System.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
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:  // Static Methods
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 /*_DECAF_LANG_SYSTEM_H_*/