source: trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Dispatcher/ProtocolInfo.cpp @ 27

Last change on this file since 27 was 22, checked in by rings, 14 years ago
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#include "ProtocolInfo.h"
2
3ProtocolInfoElement::ProtocolInfoElement()
4{
5}
6ProtocolInfoElement::~ProtocolInfoElement()
7{
8}
9bool ProtocolInfoElement::Match (const ProtocolInfoElement & toCompare) const
10{
11        return GetId() == toCompare.GetId();
12}
13
14ProtocolInfo::ProtocolInfo()
15{
16}
17
18ProtocolInfo::~ProtocolInfo()
19{
20        int nLen = size();
21        for (int i = 0; i < nLen; ++i)
22                delete (*this)[i];
23}
24void ProtocolInfo::AddItem(ProtocolInfoElement * info)
25{
26        push_back(info);
27}
28
29bool ProtocolInfo::Match(ProtocolInfo & info) const
30{
31        size_t nLen = size();
32        if (nLen != info.size())
33                return false;
34        for (unsigned int i = 0; i < nLen; ++i)
35                if (!(*this)[i]->Match(*info[i]))
36                        return false;
37        return true;
38}
39
40size_t ProtocolInfo::Count()
41{
42        return size();
43}
44const ProtocolInfoElement * ProtocolInfo::operator[] ( int nIndex ) const
45{
46        return std::vector<ProtocolInfoElement *>::operator[](nIndex);
47}
48
49
50IPv4Info::IPv4Info() :
51        m_nSrcAddr(0),
52        m_nDstAddr(0)
53{
54}
55
56IPv4Info::IPv4Info(const IPv4Info & src) :
57        m_nSrcAddr(src.m_nSrcAddr),
58        m_nDstAddr(src.m_nDstAddr)
59{
60}
61
62IPv4Info::~IPv4Info()
63{
64}
65bool IPv4Info::Match (const ProtocolInfoElement & toCompare) const
66{
67        if (!ProtocolInfoElement::Match(toCompare))
68                return false;
69        const IPv4Info & tmp = dynamic_cast<const IPv4Info &>(toCompare);
70        return m_nSrcAddr == tmp.m_nSrcAddr && m_nDstAddr == tmp.m_nDstAddr;
71}
72
73ProtocolInfoElement * IPv4Info::Clone() const
74{
75        return new IPv4Info(*this);
76}
77
78TransportLayerInfo::TransportLayerInfo() :
79        m_nSrcPort(0),
80        m_nDstPort(0)
81{
82}
83
84TransportLayerInfo::TransportLayerInfo(const TransportLayerInfo & src) :
85        m_nSrcPort(src.m_nSrcPort),
86        m_nDstPort(src.m_nDstPort)
87{
88}
89
90TransportLayerInfo::~TransportLayerInfo()
91{
92}
93bool TransportLayerInfo::Match (const ProtocolInfoElement & toCompare) const
94{
95        if (!ProtocolInfoElement::Match(toCompare))
96                return false;
97        const TransportLayerInfo & tmp = dynamic_cast<const TransportLayerInfo &>(toCompare);
98        return m_nSrcPort == tmp.m_nSrcPort && m_nDstPort == tmp.m_nDstPort;
99}
100
101TcpInfo::TcpInfo()
102{
103}
104
105TcpInfo::TcpInfo(const TcpInfo & src) :
106        TransportLayerInfo(src)
107{
108}
109
110TcpInfo::~TcpInfo()
111{
112}
113
114ProtocolInfoElement * TcpInfo::Clone() const
115{
116        return new TcpInfo(*this);
117}
118
119
120UdpInfo::UdpInfo()
121{
122}
123
124UdpInfo::UdpInfo(const UdpInfo & src) :
125        TransportLayerInfo(src)
126{
127}
128
129UdpInfo::~UdpInfo()
130{
131}
132
133ProtocolInfoElement * UdpInfo::Clone() const
134{
135        return new UdpInfo(*this);
136}
137
Note: See TracBrowser for help on using the repository browser.