00001 00026 #ifndef ODVA_ETHERNETIP_RR_DATA_H 00027 #define ODVA_ETHERNETIP_RR_DATA_H 00028 00029 #include <string> 00030 #include <boost/shared_ptr.hpp> 00031 #include <boost/asio.hpp> 00032 00033 #include "odva_ethernetip/eip_types.h" 00034 #include "odva_ethernetip/cpf_item.h" 00035 #include "odva_ethernetip/serialization/serializable.h" 00036 #include "odva_ethernetip/serialization/reader.h" 00037 #include "odva_ethernetip/serialization/writer.h" 00038 00039 using boost::shared_ptr; 00040 00041 namespace eip { 00042 00043 using serialization::Serializable; 00044 using serialization::Reader; 00045 using serialization::Writer; 00046 00051 class RRData : public Serializable 00052 { 00053 public: 00054 00055 EIP_UDINT interface_handle; 00056 EIP_UINT timeout; 00057 00061 RRData() : interface_handle(0), timeout(0) { } 00062 00067 virtual size_t getLength() const 00068 { 00069 size_t result = sizeof(interface_handle) + sizeof(timeout) + 5 * sizeof(EIP_UINT); 00070 if (getData()) 00071 { 00072 result += getData()->getLength(); 00073 } 00074 return result; 00075 } 00076 00083 virtual Writer& serialize(Writer& writer) const; 00084 00088 virtual Reader& deserialize(Reader& reader, size_t length) 00089 { 00090 deserialize(reader); 00091 return reader; 00092 } 00093 00100 virtual Reader& deserialize(Reader& reader); 00101 00102 protected: 00107 virtual shared_ptr<Serializable> getData() const 00108 { 00109 return shared_ptr<Serializable>(); 00110 } 00111 00116 virtual void setData(CPFItem& item) { } 00117 }; 00118 00119 } // namespace eip 00120 00121 #endif // ODVA_ETHERNETIP_RR_DATA_H