ResponseMessage.h

00001 /*-----------------------------------------------------------------------------
00002  * ResponseMessage declaration
00003  * Ionetrics 2006
00004  * John Williams
00005  * ResponseMessage.h
00006  *---------------------------------------------------------------------------*/
00007 
00008 #ifndef RESPONSEMESSAGE_H
00009 #define RESPONSEMESSAGE_H
00010 
00011 //-----------------------------------------------------------------------------
00012 
00013 #include <string>
00014 #include <vector>
00015 
00016 #include "AnnotatorCommApi.h"
00017 #include "CommandChecksumFailedException.h"
00018 #include "CommandDependentStatusException.h"
00019 #include "CommandFailedException.h"
00020 #include "CommandUnsupportedException.h"
00021 #include "IOException.h"
00022 
00023 using namespace std;
00024 
00025 //-----------------------------------------------------------------------------
00026 
00027 namespace annotatorcomm
00028 {
00029 
00034 class ANNCOMM_API ResponseMessage
00035 {
00036 public:
00037 //-----------------------------------------------------------------------------
00041         static const int HEADER_LEN = 6;
00042         
00046         static const int FOOTER_LEN = 2;
00047         
00048         
00052         static const int MSG_LEN_IDX = 1;
00053         
00057         static const int CMD_ID_IDX = 2;
00058         
00062         static const int RESPONSE_IDX = 4;
00063         
00067         static const int STATUS_IDX = 5;
00068         
00072         static const int CHECKSUM_RIDX = 2;
00073 //-----------------------------------------------------------------------------
00077         static const uint8_t RESP_SUCCESS = 0x00;
00078         
00082         static const uint8_t RESP_FAILED = 0x01;
00083         
00087         static const uint8_t RESP_UNSUPPORTED = 0x02;
00088 //-----------------------------------------------------------------------------
00092         static const uint8_t STATUS_UNSPECIFIED = 0x00;
00093         
00097         static const uint8_t STATUS_UNSUPPORTED = 0x01;
00098         
00102         static const uint8_t STATUS_INVALID_IN_CURRENT_CONFIG = 0x02;
00103 //-----------------------------------------------------------------------------
00104 
00105 public:
00111         ResponseMessage(vector<uint8_t> rsp);
00112         
00118         ResponseMessage operator=(ResponseMessage const & rvalue);
00119         
00125         uint16_t getId() const;
00126         
00132         uint8_t getResponse() const;
00133         
00139         uint8_t getStatus() const;
00140         
00147         string getStatusMessage() const throw(CommandDependentStatusException);
00148         
00160         void resetParamPointer();
00161         
00167         int8_t getNextParamAsInt8();
00168         
00174         uint8_t getNextParamAsUInt8();
00175         
00181         int16_t getNextParamAsInt16();
00182         
00188         uint16_t getNextParamAsUInt16();
00189         
00195         int32_t getNextParamAsInt32();
00196         
00202         uint32_t getNextParamAsUInt32();
00203         
00209         int64_t getNextParamAsInt64();
00210         
00216         uint64_t getNextParamAsUInt64();
00217         
00223         uint8_t getChecksum() const;
00224         
00230         int getRespParamLen() const;
00231         
00237         vector<uint8_t> getParamBytes() const;
00238         
00244         vector<uint8_t> getBytes() const;
00245         
00257         void errorCheck() const throw(CommandChecksumFailedException,
00258                                       CommandDependentStatusException,
00259                                       CommandFailedException,
00260                                       CommandUnsupportedException,
00261                                       IOException);
00262         
00263 private:
00267         const vector<uint8_t> rsp;
00268         
00280         int paramIdx;
00281         
00289         uint8_t getParamByte(int paramIdx) const throw(IOException);
00290         
00299         void errorCheckResponseCode() const throw(CommandDependentStatusException,
00300                                                   CommandFailedException,
00301                                                   CommandUnsupportedException,
00302                                                   IOException);
00303 
00309         void errorCheckChecksum() const throw(CommandChecksumFailedException);
00310 };
00311 
00312 }
00313 
00314 //-----------------------------------------------------------------------------
00315 
00316 #endif /* RESPONSEMESSAGE_H */

Generated on Tue Aug 1 11:14:11 2006 for libAnnotatorComm by  doxygen 1.4.7