Init.h

Go to the documentation of this file.
00001 
00020 #ifndef HYPERTABLE_INIT_H
00021 #define HYPERTABLE_INIT_H
00022 
00023 #include "Common/Config.h"
00024 #include "Common/System.h"
00025 
00026 namespace Hypertable { namespace Config {
00027 
00034   template <class PolicyT>
00035   inline void init_with_policy(int argc, char *argv[], const Desc *desc = 0) {
00036     try {
00037       System::initialize();
00038 
00039       ScopedRecLock lock(rec_mutex);
00040       properties = new Properties();
00041 
00042       if (desc)
00043         cmdline_desc(*desc);
00044 
00045       file_loaded = false;
00046       PolicyT::init_options();
00047       parse_args(argc, argv);
00048       PolicyT::init();
00049       sync_aliases(); // init can generate more aliases
00050       //properties->notify();
00051 
00052       if (get_bool("verbose"))
00053         properties->print(std::cout);
00054     }
00055     catch (Exception &e) {
00056       PolicyT::on_init_error(e);
00057     }
00058   }
00059 
00064   template <class PolicyListT>
00065   inline void init_with_policies(int argc, char *argv[], const Desc *desc = 0) {
00066     typedef typename Join<PolicyListT>::type Combined;
00067     init_with_policy<Combined>(argc, argv, desc);
00068   }
00069 
00073   inline void init(int argc, char *argv[], const Desc *desc = NULL) {
00074     init_with_policy<DefaultPolicy>(argc, argv, desc);
00075   }
00076 
00077 }} // namespace Hypertable::Config
00078 
00079 #endif /* HYPERTABLE_INIT_H */