source: trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/UpperTestAdapter/TriggerCommandsGUI/TriggerCommands.cpp @ 22

Last change on this file since 22 was 22, checked in by rings, 14 years ago
  • Property svn:executable set to *
File size: 3.3 KB
Line 
1#include "TriggerCommands.h"
2#include <string>
3#include <vector>
4#include <iostream>
5
6#include "Logger/Logger.h"
7
8#include "Register.h"
9#include "CheckIsRegistered.h"
10#include "CheckIsNotRegistered.h"
11#include "CheckCallIsInitialized.h"
12#include "CheckCallIsAnswered.h"
13#include "CheckCallIsEnded.h"
14#include "CheckNewMediaAdded.h"
15#include "CheckNewMediaRemoved.h"
16#include "Default.h"
17
18using namespace std;
19using namespace boost;
20
21namespace UpperTestAdapter {
22 
23namespace Processors {
24 
25namespace TriggerCommandsGUI {
26 
27TriggerCommands::TriggerCommands()
28{
29}
30
31TriggerCommands::~TriggerCommands()
32{
33  Logger::Instance().LogInfo("TriggerCommands::~TriggerCommands");
34  m_successor.reset();
35}
36
37void TriggerCommands::SetEutIpInterface(boost::shared_ptr<EutIPInterface> eutIface)
38{
39  m_successor = shared_ptr<TriggerCommandsImpl>(new Register(eutIface)); // Register
40  shared_ptr<TriggerCommandsImpl> checkIsRegistered = shared_ptr<TriggerCommandsImpl>(new CheckIsRegistered(eutIface)); // CheckIsRegister
41  m_successor.get()->SetSuccessor(checkIsRegistered);
42  shared_ptr<TriggerCommandsImpl> checkIsNotRegistered = shared_ptr<TriggerCommandsImpl>(new CheckIsNotRegistered(eutIface)); // CheckIsNotRegister
43  checkIsRegistered.get()->SetSuccessor(checkIsNotRegistered);
44  shared_ptr<TriggerCommandsImpl> checkCallIsInitialized = shared_ptr<TriggerCommandsImpl>(new CheckCallIsInitialized(eutIface)); // CheckCallIsInitialized
45  checkIsNotRegistered.get()->SetSuccessor(checkCallIsInitialized);
46  shared_ptr<TriggerCommandsImpl> checkCallIsAnswered = shared_ptr<TriggerCommandsImpl>(new CheckCallIsAnswered(eutIface)); // CheckCallIsAnswered
47  checkCallIsInitialized.get()->SetSuccessor(checkCallIsAnswered);
48  shared_ptr<TriggerCommandsImpl> checkCallIsEnded = shared_ptr<TriggerCommandsImpl>(new CheckCallIsEnded(eutIface)); // CheckCallIsEnded
49  checkCallIsAnswered.get()->SetSuccessor(checkCallIsEnded);
50  shared_ptr<TriggerCommandsImpl> checkNewMediaAdded = shared_ptr<TriggerCommandsImpl>(new CheckNewMediaAdded(eutIface)); // CheckNewMediaAdded
51  checkCallIsEnded.get()->SetSuccessor(checkNewMediaAdded);
52  shared_ptr<TriggerCommandsImpl> checkNewMediaRemoved = shared_ptr<TriggerCommandsImpl>(new CheckNewMediaRemoved(eutIface)); // CheckNewMediaRemoved
53  checkNewMediaAdded.get()->SetSuccessor(checkNewMediaRemoved);
54  checkNewMediaRemoved.get()->SetSuccessor(shared_ptr<TriggerCommandsImpl>(new Default(eutIface)));
55
56  Logger::Instance().LogInfo("TriggerCommandsGUI::TriggerCommands::SetEutIpInterface: 9 commands created");
57}
58
59int TriggerCommands::Process(const string &trigger, const vector<string> &parameterList)
60{
61  // Sanity check,
62  if (trigger.length() == 0)
63  {
64    Logger::Instance().LogError("TriggerCommandsGUI::TriggerCommands::Process: trigger is empty.");
65
66    return 1; // See TTCN-3 FncRetCode
67  }
68  if (m_successor.get() == NULL)
69  {
70    Logger::Instance().LogError("TriggerCommandsGUI::TriggerCommands::Process: Bad pointer allocation.");
71
72    return 1; // See TTCN-3 FncRetCode
73  }
74
75  /*stringstream ss;
76  ss << "TriggerCommandsGUI::TriggerCommands::Process: start processing: " << trigger;
77  Logger::Instance().LogInfo(ss.str());*/
78  return m_successor.get()->Process(trigger, parameterList);
79}
80
81} } } // namespaces
82
Note: See TracBrowser for help on using the repository browser.