//****************************************************************************** //****************************************************************************** //****************************************************************************** // Copy a message from a byte buffer // // 1) Extract the header parameters. // 2) Create a new message object of the type specifed by the identifiers // that were extracted from the header // 3) Copy the data from the byte buffer into the new message object // and returns a pointer to the base class. public ByteContent makeMsgFromBuffer(ByteBuffer aBuffer) { // Set buffer direction for get. aBuffer.setCopyFrom(); // Extract the header parameters. aBuffer.rewind(); extractMessageHeaderParms(aBuffer); aBuffer.rewind(); // Guard. if (!mHeaderValidFlag) { return(null); } // Call inheritor's creator to create a new message based on the // message type that was extracted from the header. ByteContent aMsg = mMsgCreator.createMsg(mMessageType); // Guard if (aMsg == null) { return(null); } // Call inheritor's copier to copy from the buffer to the message. aMsg.copyToFrom(aBuffer); // Done. return(aMsg); }
public void getFromBuffer(ByteContent aContent) { // Set copy direction setCopyFrom(); // Call ByteContent supplied member function to do the get aContent.copyToFrom(this); }
//*************************************************************************** //*************************************************************************** //*************************************************************************** // Copy a message to a byte buffer. public void putMsgToBuffer(ByteBuffer aBuffer, ByteContent aMsg) { // Call inheritor's override to preprocess the message before it is sent. processBeforeSend(aMsg); // Set buffer direction for put. aBuffer.setCopyTo(); // Call inheritor's copier to copy from the message to the buffer. aMsg.copyToFrom(aBuffer); }
//****************************************************************************** //****************************************************************************** //****************************************************************************** //****************************************************************************** //****************************************************************************** //****************************************************************************** // Copy reference types //--------------------------------------------------------------------------- // copy does either a copy to the buffer or a copy from the buffer // // These either put an item to the byte buffer or get an // item from the byte buffer, based on the value of the // buffer copy direction flag. //****************************************************************************** //****************************************************************************** //****************************************************************************** public void copy(ByteContent aContent) { aContent.copyToFrom(this); }