/* Copyright (c) 20011 Hovanes Egiyan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _BaseIUMessage_HH_ #define _BaseIUMessage_HH_ extern "C" { #include #include }; #include #include using namespace std; typedef vector ByteArray; class BaseIUMessage : public ByteArray { protected: public: static int bmsDebFlag; //! Mask for one byte (0xFF) static const uint8_t bmsByteMask; //! Default constructor BaseIUMessage() {;} //! Constructor with just one single element BaseIUMessage( uint8_t number ) : ByteArray( 1, number ) {;} //! Create a buffer based on the address and the length BaseIUMessage( const unsigned char* buffer, int bufLength ); //! Copy constructor utilizing assignment operator BaseIUMessage( const BaseIUMessage& msg ) { *this = operator=( msg ); } //! Append the message from the right end, which is the //! last byte of the message in the argument will be the //! lasst byte of the resulting message. BaseIUMessage& operator<<( const BaseIUMessage& msg ); //! Method to print the content of the message void print( ostream& os ) const; //! Assignment operator BaseIUMessage& operator=( const BaseIUMessage& msg ); //! Return the address of the first element of the data array //! Although this is not an official feature of the STL vectors //! it always seems to work. Returns the address of the fist //! element of the vector. uint8_t* data_addr() { return &((*this)[0]); } }; //! Non-member function to print BaseIUMessage class through stream ostream& operator<<( ostream& os, const BaseIUMessage& msg ); #endif // _BaseIUMessage_HH_