00001 00026 #ifndef ODVA_ETHERNETIP_SEQUENCED_ADDRESS_ITEM_H 00027 #define ODVA_ETHERNETIP_SEQUENCED_ADDRESS_ITEM_H 00028 00029 #include <string> 00030 00031 #include "odva_ethernetip/eip_types.h" 00032 #include "odva_ethernetip/serialization/reader.h" 00033 #include "odva_ethernetip/serialization/writer.h" 00034 #include "odva_ethernetip/serialization/serializable.h" 00035 00036 namespace eip { 00037 00038 using std::string; 00039 using serialization::Serializable; 00040 using serialization::Reader; 00041 using serialization::Writer; 00042 00046 class SequencedAddressItem : public Serializable 00047 { 00048 public: 00049 EIP_UDINT connection_id; 00050 EIP_UDINT sequence_num; 00051 00052 SequencedAddressItem(EIP_UDINT connection = 0, EIP_UDINT sequence = 0) 00053 : connection_id(connection), sequence_num(sequence) { } 00054 00059 virtual size_t getLength() const 00060 { 00061 return sizeof(connection_id) + sizeof(sequence_num); 00062 } 00063 00070 virtual Writer& serialize(Writer& writer) const 00071 { 00072 writer.write(connection_id); 00073 writer.write(sequence_num); 00074 return writer; 00075 } 00076 00080 virtual Reader& deserialize(Reader& reader, size_t length) 00081 { 00082 return deserialize(reader); 00083 } 00084 00091 virtual Reader& deserialize(Reader& reader) 00092 { 00093 reader.read(connection_id); 00094 reader.read(sequence_num); 00095 return reader; 00096 } 00097 }; 00098 00099 } // namespace eip 00100 00101 #endif // ODVA_ETHERNETIP_SEQUENCED_ADDRESS_ITEM_H