#include "UnitManager.h" #include "../Common/Toolbox.h" using namespace TREPS::Common; namespace TREPS { namespace UnitManager { UnitManagerClass::UnitManagerClass(void) : app(NULL), loader(NULL) { this->app = ApplicationClass::getInstance(); } UnitManagerClass::~UnitManagerClass(void) { if (this->loader != NULL) { this->loader->close(); delete this->loader; this->loader = NULL; } } bool UnitManagerClass::init(const char *file_path) { //create xml loader if (this->loader == NULL) this->loader = new XMLManagerClass(); this->loader->close(); if (!this->loader->isExist(file_path)) { LOG4CXX_INFO(this->app->getLog()->getPtr(),"Cannot find units file : " << file_path); return false; } //load file if (!this->loader->loadFile(file_path)) { LOG4CXX_INFO(this->app->getLog()->getPtr(),"Cannot load units file : " << file_path); return false; } //xsd validation if (!this->loader->isValid(TREPS_UNITS_XSD)) { LOG4CXX_INFO(this->app->getLog()->getPtr(),"Invalid units file : " << file_path); return false; } return true; } } }