+// ANNA - Anna is Not Nothingness Anymore //
+// //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
+// //
+// See project site at http://redmine.teslayout.com/projects/anna-suite //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+#ifndef example_diameter_launcher_Launcher_hpp
+#define example_diameter_launcher_Launcher_hpp
+
+// Standard
+#include <fstream>
+#include <string>
+#include <map>
+
+// Project
+#include <anna/core/core.hpp>
+#include <anna/comm/comm.hpp>
+#include <anna/time/Date.hpp>
+#include <anna/diameter/codec/Message.hpp>
+
+// Process
+#include <MyCommunicator.hpp>
+#include <MyCounterRecorder.hpp>
+#include <TestManager.hpp>
+
+
+#define SH_COMMAND_TAG_FOR_REPLACE__CYCLE_ID "##cycleid##"
+#define SH_COMMAND_TAG_FOR_REPLACE__TESTCASE_ID "##testcaseid##"
+#define SH_COMMAND_TAG_FOR_REPLACE__TESTSTEP_ID "##teststepid##"
+
+
+namespace anna {
+ namespace timex {
+ class Engine;
+ }
+ namespace diameter {
+ namespace codec {
+ class Engine;
+ }
+ }
+}
+
+class TestManager;
+class RealmNode;
+class MyDiameterEntity;
+class MyLocalServer;
+class MyDiameterEngine;
+
+// RealmNode resources
+class RealmNode;
+typedef std::map<std::string, RealmNode*> realm_nodes_t;
+typedef std::map<std::string, RealmNode*>::const_iterator realm_nodes_it;
+typedef std::map<std::string, RealmNode*>::iterator realm_nodes_nc_it;
+
+
+class Launcher : public anna::comm::Application {
+
+ // Start time:
+ anna::time::Date a_start_time;
+
+ // Core engines:
+ MyCommunicator *a_communicator;
+ anna::timex::Engine* a_timeEngine;
+ MyCounterRecorder *a_counterRecorder;
+ anna::Millisecond a_admlMinResolution;
+ MyCounterRecorderClock *a_counterRecorderClock;
+
+ // Nodes deployment:
+ realm_nodes_t a_nodes;
+ RealmNode *a_workingNode;
+ RealmNode *a_operatedRealm; // auxiliary for eventOperation
+
+ // comm resources:
+ anna::comm::ServerSocket* a_httpServerSocket; // HTTP
+
+ const anna::Millisecond &getADMLMinResolution() const throw() { return a_admlMinResolution; }
+
+ void servicesFromXML(const anna::xml::Node* servicesNode, bool eventOperation) throw(anna::RuntimeException);
+ anna::Millisecond checkTimeMeasure(const std::string ¶meter, const std::string &value) throw(anna::RuntimeException);
+ void initialize() throw(anna::RuntimeException); // HTTP
+ void run() throw(anna::RuntimeException);
+
+public:
+ Launcher();
+ //~Launcher(); TODO
+
+ void loadServices(const std::string & xmlPathFile, bool eventOperation = false) throw(anna::RuntimeException);
+ void startServices() throw(anna::RuntimeException);
+
+ bool setWorkingNode(const std::string &name) throw();
+ RealmNode *getRealmNode(const std::string &realmName) const throw(anna::RuntimeException);
+ RealmNode *getRealmNode(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException);
+ bool uniqueRealm() const throw() { return (a_nodes.size() == 1); }
+
+ // Operated realm for communication resources smart assignment ////////////////////////////////////////////////////////////
+ void updateOperatedRealmNodeWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException);
+ RealmNode *getOperatedRealm() const throw(anna::RuntimeException);
+ MyDiameterEntity *getOperatedEntity() const throw(anna::RuntimeException);
+ MyLocalServer *getOperatedServer() const throw(anna::RuntimeException);
+ MyDiameterEngine *getOperatedEngine() const throw(anna::RuntimeException);
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+ MyCommunicator *getCommunicator() throw() { return a_communicator; }
+ void eventOperation(const std::string &, std::string &) throw(anna::RuntimeException);
+ void forceCountersRecord() throw(anna::RuntimeException) { if (a_counterRecorderClock) a_counterRecorderClock->tick(); }
+
+ anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+ void resetStatistics() throw();
+ void resetCounters() throw();
+ void signalUSR2() throw(anna::RuntimeException);
+ std::string help() const throw();
+ anna::xml::Node* oamAndStatsAsXML(anna::xml::Node* parent) const throw();
+
+ // helpers
+ bool getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw();
+
+ friend class TestManager;
+};
+
+#endif