cpf_item.h
Go to the documentation of this file.
00001 
00026 #ifndef ODVA_ETHERNETIP_CPF_ITEM_H
00027 #define ODVA_ETHERNETIP_CPF_ITEM_H
00028 
00029 #include <boost/shared_ptr.hpp>
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 using boost::shared_ptr;
00037 
00038 namespace eip {
00039 
00040 using serialization::Serializable;
00041 using serialization::Reader;
00042 using serialization::Writer;
00043 
00048 class CPFItem : public Serializable
00049 {
00050 public:
00051 
00056   CPFItem() : item_type_(EIP_ITEM_NULL) { }
00057 
00063   CPFItem(EIP_UINT item_type, shared_ptr<Serializable> item_data)
00064     : item_type_(item_type), item_data_(item_data) { }
00065 
00070   EIP_UINT getItemType()
00071   {
00072     return item_type_;
00073   }
00074 
00079   void setItemType(EIP_UINT item_type)
00080   {
00081     item_type_ = item_type;
00082   }
00083 
00087   shared_ptr<Serializable> getData()
00088   {
00089     return item_data_;
00090   }
00091 
00096   void setData(shared_ptr<Serializable> data)
00097   {
00098     item_data_ = data;
00099   }
00100 
00105   void getDataAs(Serializable& result);
00106 
00111   virtual EIP_UINT getDataLength() const
00112   {
00113     return item_data_ ? item_data_->getLength() : 0;
00114   }
00115 
00121   virtual size_t getLength() const
00122   {
00123     return 4 + getDataLength();
00124   }
00125 
00132   virtual Writer& serialize(Writer& writer) const;
00133 
00141   virtual Reader& deserialize(Reader& reader, size_t length);
00142 
00149   virtual Reader& deserialize(Reader& reader);
00150 private:
00151   EIP_UINT item_type_;
00152   shared_ptr<Serializable> item_data_;
00153 
00159   void deserializeData(Reader& reader, EIP_UINT item_length);
00160 };
00161 
00162 } // namespace eip
00163 
00164 #endif  // ODVA_ETHERNETIP_CPF_ITEM_H


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Sat Jun 8 2019 20:21:23