00001 /* 00002 * Copyright 2004-2006 Intel Corporation 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef _DTNSERVER_H_ 00018 #define _DTNSERVER_H_ 00019 00020 #include <oasys/debug/Logger.h> 00021 #include <oasys/thread/Atomic.h> 00022 #include <oasys/storage/DurableStore.h> 00023 00024 namespace dtn { 00025 00026 class DTNStorageConfig; 00027 00031 class DTNServer : public oasys::Logger { 00032 public: 00033 DTNServer(const char* logpath, 00034 DTNStorageConfig* storage_config); 00035 ~DTNServer(); 00036 00037 DTNStorageConfig* storage_config() { return storage_config_; } 00038 00044 void init(); 00045 00047 bool init_datastore(); 00048 00050 void close_datastore(); 00051 00053 void start(); 00054 00056 bool parse_conf_file(std::string& conf_file, 00057 bool conf_file_set); 00058 00060 void shutdown(); 00061 00063 typedef void (*ShutdownProc) (void* args); 00064 00066 void set_app_shutdown(ShutdownProc proc, void* data); 00067 00068 private: 00069 bool init_; 00070 oasys::atomic_t in_shutdown_; 00071 00072 DTNStorageConfig* storage_config_; 00073 oasys::DurableStore* store_; 00074 00075 bool init_dir(const char* dirname); 00076 bool tidy_dir(const char* dirname); 00077 bool validate_dir(const char* dirname); 00078 00082 void init_commands(); 00083 00087 void init_components(); 00088 }; 00089 00090 } // namespace dtn 00091 00092 #endif /* _DTNSERVER_H_ */