DRDE/ACTK1_0/common/init.cpp

103 lines
2.4 KiB
C++
Raw Permalink Normal View History

#include "common/SystemProperties.hpp"
#include "common/Logger.hpp"
#include "common/ErrorPkg.hpp"
#include "se/SendSE.hpp"
#include "se/ReceiveSE.hpp"
#include "se/IPVersion.hpp"
#include "se/PostalInfoType.hpp"
#include "se/StandardCommandType.hpp"
#include "se/AddRemType.hpp"
#include "se/StandardObjectType.hpp"
#include "se/PeriodUnit.hpp"
#include "se/PollOperation.hpp"
#include "se/TransferOp.hpp"
#include "xml/XMLParser.hpp"
#include "xml/XMLInit.hpp"
#include <xercesc/util/PlatformUtils.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>
2014-01-21 23:01:41 +00:00
#include "common/init.hpp"
#include <iostream>
#include <signal.h>
2014-01-18 20:35:18 +00:00
#define MDLOG_USER
#include <mdLogger.h>
2014-01-10 20:05:42 +00:00
const char *otePeer="epp.ote.donuts.co";
2014-01-21 01:34:40 +00:00
int tkScenario=0;
2014-01-18 20:35:18 +00:00
mdLogger mdLog;
2014-01-10 20:05:42 +00:00
namespace {
void initEnumTypes()
{
// These classes are decendants of EnumType and so have static storage
// listing valid values. The init() method must be called to establish
// these values.
IPVersion::init();
PostalInfoType::init();
StandardCommandType::init();
AddRemType::init();
StandardObjectType::init();
PeriodUnit::init();
PollOperation::init();
TransferOp::init();
}
class Init
{
public:
Init(const std::string& system_props_file)
{
try
{
// SystemProperties, Logger and ErrorPkg must be initialised in
// this order.
sigset_t new_set, old_set;
sigemptyset(&new_set);
sigaddset(&new_set,SIGPIPE);
sigprocmask(SIG_BLOCK,&new_set,&old_set);
SystemProperties::init(system_props_file);
Logger::init();
ErrorPkg::init();
XMLInit::init();
XMLParser::init();
XMLWriter::init();
ReceiveSE::init();
SendSE::init();
initEnumTypes();
}
catch (EPPException& e)
{
std::cerr << "Toolkit initialisation exception: " << e.getMessage() << std::endl;
throw;
}
catch (std::exception& e)
{
std::cerr << "Toolkit initialisation exception: " << e.what() << std::endl;
throw;
}
}
};
2014-01-10 20:05:42 +00:00
} // anonymous namespace
void init(const std::string& system_props_file)
{
static const Init doInit(system_props_file);
}
2014-01-10 20:05:42 +00:00
2014-01-10 22:26:28 +00:00
2014-01-16 15:35:39 +00:00
void scenario(int scenario,const std::string& system_props_file)
2014-01-10 20:05:42 +00:00
{
tkScenario = scenario;
2014-01-18 20:35:18 +00:00
if (tkScenario >= ACTK_OTEB)
mdLog.init(false);
2014-01-16 15:35:39 +00:00
static const Init doInit(system_props_file);
2014-01-10 20:05:42 +00:00
}