source: trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/UpperTestAdapter/TriggerCommandsOffLine/TriggerCommands.cpp @ 37

Last change on this file since 37 was 22, checked in by rings, 14 years ago
  • Property svn:executable set to *
File size: 3.0 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 TriggerCommandsOffLine {
26 
27TriggerCommands::TriggerCommands()
28{
29  m_successor = shared_ptr<TriggerCommandsImpl>(new Register); // Register
30  shared_ptr<TriggerCommandsImpl> checkIsRegistered = shared_ptr<TriggerCommandsImpl>(new CheckIsRegistered); // CheckIsRegister
31  m_successor.get()->SetSuccessor(checkIsRegistered);
32  shared_ptr<TriggerCommandsImpl> checkIsNotRegistered = shared_ptr<TriggerCommandsImpl>(new CheckIsNotRegistered); // CheckIsNotRegister
33  checkIsRegistered.get()->SetSuccessor(checkIsNotRegistered);
34  shared_ptr<TriggerCommandsImpl> checkCallIsInitialized = shared_ptr<TriggerCommandsImpl>(new CheckCallIsInitialized); // CheckCallIsInitialized
35  checkIsNotRegistered.get()->SetSuccessor(checkCallIsInitialized);
36  shared_ptr<TriggerCommandsImpl> checkCallIsAnswered = shared_ptr<TriggerCommandsImpl>(new CheckCallIsAnswered); // CheckCallIsAnswered
37  checkCallIsInitialized.get()->SetSuccessor(checkCallIsAnswered);
38  shared_ptr<TriggerCommandsImpl> checkCallIsEnded = shared_ptr<TriggerCommandsImpl>(new CheckCallIsEnded); // CheckCallIsEnded
39  checkCallIsAnswered.get()->SetSuccessor(checkCallIsEnded);
40  shared_ptr<TriggerCommandsImpl> checkNewMediaAdded = shared_ptr<TriggerCommandsImpl>(new CheckNewMediaAdded); // CheckNewMediaAdded
41  checkCallIsEnded.get()->SetSuccessor(checkNewMediaAdded);
42  shared_ptr<TriggerCommandsImpl> checkNewMediaRemoved = shared_ptr<TriggerCommandsImpl>(new CheckNewMediaRemoved); // CheckNewMediaRemoved
43  checkNewMediaAdded.get()->SetSuccessor(checkNewMediaRemoved);
44  checkNewMediaRemoved.get()->SetSuccessor(shared_ptr<TriggerCommandsImpl>(new Default));
45
46  Logger::Instance().LogInfo("TriggerCommandsOffLine::TriggerCommands::TriggerCommands: 9 commands created");
47}
48
49TriggerCommands::~TriggerCommands()
50{
51        m_successor.reset();
52}
53
54void TriggerCommands::SetEutIpInterface(boost::shared_ptr<EutIPInterface> eutIface)
55{
56  Logger::Instance().LogInfo("TriggerCommands::~TriggerCommands");
57  m_successor.reset();
58}
59
60int TriggerCommands::Process(const string &trigger, const vector<string> &parameterList)
61{
62  // Sanity check,
63  if (trigger.length() == 0)
64  {
65    Logger::Instance().LogError("TriggerCommandsOffLine::TriggerCommands::Process: trigger is empty.");
66    return 1; // See TTCN-3 FncRetCode .
67  }
68
69  stringstream ss;
70  ss << "TriggerCommandsOffLine::TriggerCommands::Process: start processing: " << trigger;
71  Logger::Instance().LogInfo(ss.str());
72  return m_successor.get()->Process(trigger, parameterList);
73}
74
75} } } // namespaces
76
Note: See TracBrowser for help on using the repository browser.