activemq-cpp-3.3.0

src/main/decaf/internal/net/Network.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_INTERNAL_NET_NETWORK_H_
00019 #define _DECAF_INTERNAL_NET_NETWORK_H_
00020 
00021 #include <decaf/util/Config.h>
00022 
00023 #include <decaf/util/concurrent/Mutex.h>
00024 #include <decaf/internal/util/Resource.h>
00025 #include <decaf/internal/util/GenericResource.h>
00026 
00027 namespace decaf {
00028 namespace internal {
00029 namespace net {
00030 
00031     class NetworkData;
00032 
00039     class DECAF_API Network {
00040     private:
00041 
00042         NetworkData* data;
00043 
00044         static Network* networkRuntime;
00045 
00046     private:
00047 
00048         Network( const Network& );
00049         Network& operator= ( const Network& );
00050 
00051     protected:
00052 
00053         Network();
00054 
00055     public:
00056 
00057         virtual ~Network();
00058 
00069         decaf::util::concurrent::Mutex* getRuntimeLock();
00070 
00081         void addNetworkResource( decaf::internal::util::Resource* value );
00082 
00083         template<typename T>
00084         void addAsResource( T* value ) {
00085 
00086             util::GenericResource<T>* resource = new util::GenericResource<T>( value );
00087             this->addNetworkResource( resource );
00088         }
00089 
00106         void addShutdownTask( decaf::lang::Runnable* task );
00107 
00108     public:   // Static methods
00109 
00117         static Network* getNetworkRuntime();
00118 
00122         static void initializeNetworking();
00123 
00129         static void shutdownNetworking();
00130 
00131     };
00132 
00133 }}}
00134 
00135 #endif /* _DECAF_INTERNAL_NET_NETWORK_H_ */