cpp_photon/include/entrypoint.hpp

56 lines
1.2 KiB
C++
Raw Normal View History

2005-02-07 02:00:48 +00:00
//This file is part of Photon (http://photon.sourceforge.net)
//Copyright (C) 2004-2005 James Turk
//
// Author:
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: entrypoint.hpp,v 1.7 2005/08/07 07:12:46 cozman Exp $
2005-02-07 02:00:48 +00:00
2005-02-13 22:12:02 +00:00
#ifndef PHOTON_ENTRYPOINT_HPP
#define PHOTON_ENTRYPOINT_HPP
2005-02-07 02:00:48 +00:00
2005-02-13 22:12:02 +00:00
#include "Log.hpp"
2005-02-07 02:00:48 +00:00
2005-07-19 01:31:37 +00:00
// Title: Entrypoint
int PhotonMain(const photon::StrVec& args);
2005-02-07 02:00:48 +00:00
int main(int argc, const char** argv)
2005-02-07 02:00:48 +00:00
{
2005-07-19 01:31:37 +00:00
// logging of uncaught exceptions to console
photon::Log log;
log.addSink(photon::LogSinkPtr(new photon::ConsoleSink("out")));
2005-02-07 02:00:48 +00:00
try
{
new photon::Application(argv[0]);
2005-07-19 01:31:37 +00:00
// push arguments into StrVec
photon::StrVec args;
2005-02-07 02:00:48 +00:00
for(int i=0; i < argc; ++i)
2005-03-15 19:21:51 +00:00
{
2005-02-07 02:00:48 +00:00
args.push_back(argv[i]);
2005-03-15 19:21:51 +00:00
}
int retVal = PhotonMain(args);
photon::Application::destroy();
2005-03-15 19:21:51 +00:00
return retVal;
2005-02-07 02:00:48 +00:00
}
catch(photon::Exception &e) // log exceptions as errors (confusing?)
2005-02-07 02:00:48 +00:00
{
2005-05-15 02:50:52 +00:00
log.error() << e;
return 1;
2005-02-07 02:00:48 +00:00
}
catch(photon::Error &e) // log errors as critical errors
2005-02-07 02:00:48 +00:00
{
2005-05-15 02:50:52 +00:00
log.critical() << e;
2005-02-07 02:00:48 +00:00
return 1;
}
}
2005-02-13 22:12:02 +00:00
#endif //PHOTON_ENTRYPOINT_HPP