gizmod/Main.cpp

Go to the documentation of this file.
00001 
00013 /*
00014   
00015   Copyright (c) 2007, Tim Burrell
00016   Licensed under the Apache License, Version 2.0 (the "License");
00017   you may not use this file except in compliance with the License.
00018   You may obtain a copy of the License at 
00019 
00020         http://www.apache.org/licenses/LICENSE-2.0
00021 
00022   Unless required by applicable law or agreed to in writing, software
00023   distributed under the License is distributed on an "AS IS" BASIS,
00024   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00025   See the License for the specific language governing permissions and 
00026   limitations under the License. 
00027   
00028 */
00029 
00030 #if HAVE_CONFIG_H
00031 #include "config.h"
00032 #endif
00033 
00034 #include "Main.hpp"
00035 #include "GizmoDaemon.hpp"
00036 #include "../libH/Exception.hpp"
00037 #include <cstdlib>
00038 #include <iostream>
00039 #include <boost/shared_ptr.hpp>
00040 #include <boost/filesystem/operations.hpp>
00041 
00042 using namespace std;
00043 using namespace H;
00044 using namespace boost;
00045 using namespace boost::filesystem;
00046 
00055 int main (int argc, char * argv []) {
00056         // set filesystem to native filesystem checking
00057         path::default_name_check(native);
00058         
00059         bool ReloadGizmod;
00060         do {
00061                 // create the Gizmod
00062                 shared_ptr<GizmoDaemon> pGizmod;
00063                 try {
00064                         pGizmod = shared_ptr<GizmoDaemon>(new GizmoDaemon);
00065                 } catch (H::Exception & e) {
00066                         cerr << "\nUnable to Initialize Gizmod :: " << e.message() << "\n\n";
00067                         return EXIT_FAILURE;
00068                 }
00069                 
00070                 // try initializing
00071                 try {
00072                         if (!pGizmod->initialize(argc, argv))
00073                                 return EXIT_SUCCESS;
00074                 } catch (H::Exception & e) {
00075                         cerr << "\nUnable to Initialize Gizmod :: " << e.message() << "\n\n";
00076                         return EXIT_FAILURE;
00077                 }
00078                 
00079                 // Setup
00080                 try {
00081                         pGizmod->initGizmod();
00082                 } catch (H::Exception & e) {
00083                         cerr << "Unable to Initialize Gizmod :: " << e.message() << "\n\n";
00084                         return EXIT_FAILURE;
00085                 }
00086                 
00087                 // enter the run loop
00088                 try {
00089                         pGizmod->enterLoop();
00090                 } catch (H::Exception & e) {
00091                         cerr << "Fatal Error :: " << e.message() << "\n\n";
00092                         return EXIT_FAILURE;
00093                 }
00094                 
00095                 // check whether or not to reload the config
00096                 ReloadGizmod = pGizmod->getReloadConfig();
00097         } while (ReloadGizmod);
00098                 
00099         return EXIT_SUCCESS;
00100 }

Generated on Wed Nov 7 10:04:16 2007 for gizmod by  doxygen 1.5.3