Fixes and improvs. Basic DRA feature.
[anna.git] / example / diameter / launcher / Launcher.hpp
index e69de29..204459a 100644 (file)
@@ -0,0 +1,107 @@
+// 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>
+
+// Process
+#include <MyCommunicator.hpp>
+#include <MyCounterRecorder.hpp>
+#include <TestManager.hpp>
+
+
+namespace anna {
+  namespace timex {
+    class Engine;
+  }
+  namespace diameter {
+    namespace codec {
+      class Engine;
+    }
+  }
+}
+
+class TestManager;
+
+// 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::diameter::codec::Engine *a_codecEngine;
+  anna::diameter::stack::Dictionary *a_baseProtocolDictionary;
+  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;
+
+  // 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 &parameter, const std::string &value) throw(anna::RuntimeException);
+  void initialize() throw(anna::RuntimeException); // HTTP
+  void run() throw(anna::RuntimeException);
+
+public:
+  Launcher();
+
+  void loadServices(const std::string & xmlPathFile, bool eventOperation = false) throw(anna::RuntimeException);
+  void startServices() throw(anna::RuntimeException);
+
+  anna::diameter::codec::Engine *getCodecEngine() const throw() { return a_codecEngine; }
+  //anna::diameter::stack::Dictionary *getBaseProtocolDictionary() const throw() { return a_baseProtocolDictionary; }
+  RealmNode *getWorkingNode() const throw(anna::RuntimeException); // management operations working node
+  bool setWorkingNode(const std::string &name) throw(); // we could update ignoreFlagsOnValidation/integrationAndDebugging over the global codec engine
+                                                        //  but finally, that configuration issues will be global to the process.
+
+  RealmNode *getRealmNode(const std::string &realmName) const throw();
+
+
+  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();
+
+  // helpers
+  bool getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw();
+
+  friend class TestManager;
+};
+
+#endif