fintp_ws
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SequenceResponse.h
Go to the documentation of this file.
1 /*
2 * FinTP - Financial Transactions Processing Application
3 * Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>
17 * or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
18 * phone +40212554577, office@allevo.ro <mailto:office@allevo.ro>, www.allevo.ro.
19 */
20 
21 #ifndef SEQUENCERESPONSE_H
22 #define SEQUENCERESPONSE_H
23 
24 #include <map>
25 
26 #include "SequenceType.h"
27 #include "AcknowledgementRange.h"
28 #include "Nack.h"
29 #include "Ack.h"
30 
31 namespace wsrm
32 {
33  //EXPIMP_TEMPLATE template class ExportedWsObject std::vector< wsrm::AcknowledgementRange >;
34  //EXPIMP_TEMPLATE template class ExportedWsObject std::map< string, wsrm::Nack >;
35 
37  {
38  protected :
39 
40  SequenceResponse( SequenceType::Type type = SequenceType::Sequence, const string& identifier = "", const string& elementName = "name", const string& namespaceId = "ns", const string& namespaceUri = "uri" );
41 
42  public:
43 
44  virtual ~SequenceResponse();
45 
46  void AddChild( const wsrm::AcknowledgementRange& ackRange ){ m_Acks.push_back( ackRange ); }
47  void AddChild( const string& reference, const wsrm::Nack& nack ){ (void)m_Nacks.insert( pair< string, wsrm::Nack >( reference, nack ) ); }
48  void AddChild( const string& reference, const wsrm::Ack& ack ){ (void)m_DistinctAcks.insert( pair< string, wsrm::Ack >( reference, ack ) ); }
49  const AcknowledgementRangeSequence& getAcknowledgementRanges() const { return m_Acks; }
50  const map< string, wsrm::Ack >& getAcks() const { return m_DistinctAcks; }
51  const map< string, wsrm::Nack >& getNacks() const { return m_Nacks; }
52  const wsrm::Nack& getNack( const string& reference ) { return m_Nacks[ reference ]; }
53  const wsrm::Ack& getAck( const string& reference ) { return m_DistinctAcks[ reference ]; }
54 
55  virtual bool IsAck( const unsigned long sequence ) const = 0;
56  virtual bool IsAck( const string reference ) const { return false; };
57  virtual bool IsNack( const string reference ) const = 0;
58  unsigned int seqSize() const
59  {
60  return m_Nacks.size() + m_DistinctAcks.size() ;
61  };
62 
63  static SequenceResponse* Deserialize( DOMNode* root, const string& messageFilename );
64 
65  protected :
66 
67  virtual string internalSerialize() const = 0;
68  virtual DOMNode* internalSerialize( DOMNode* root ) const = 0;
69 
70  virtual WSSerializable* internalDeserialize( const DOMNode* root ) = 0;
71 
72  protected :
73 
75  map< string, wsrm::Nack > m_Nacks;
76  map< string, wsrm::Ack > m_DistinctAcks;
77  };
78 }
79 
80 
81 #endif // SEQUENCERESPONSE_H