CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/IOPool/Streamer/interface/OtherMessage.h

Go to the documentation of this file.
00001 
00009 #ifndef IOPool_Streamer_OtherMessage_h
00010 #define IOPool_Streamer_OtherMessage_h
00011 
00012 #include "IOPool/Streamer/interface/MsgTools.h"
00013 #include "IOPool/Streamer/interface/MsgHeader.h"
00014 
00015 //------------------------------Builds the Message -------------------------
00016 
00017 class OtherMessageBuilder
00018 {
00019 public:
00020 
00021   //Constructor to Create OtherMessage
00022   OtherMessageBuilder(void* buf, uint32 code, uint32 bodySize=0):
00023   buf_((uint8*)buf),
00024   h_((Header*)buf) 
00025    {
00026    new (h_) Header (code, (unsigned int)sizeof(Header)+bodySize);
00027    }
00028 
00029   uint32 code() const { return h_->code_; }
00030   uint32 size() const { return convert32(h_->size_); }
00031   uint8* msgBody()    { return buf_+sizeof(Header); }
00032   uint8* startAddress() { return buf_; }
00033 
00034 private:
00035   uint8* buf_;
00036   Header* h_;
00037 };
00038 
00039 // ----------------------- Looks at the Message  ------------------------
00040  
00041 class OtherMessageView 
00042 { 
00043 public: 
00044  
00045  
00046   //Constructor to View OtherMessage 
00047   OtherMessageView(void* buf): 
00048   buf_((uint8*)buf), 
00049   head_((Header*)buf) 
00050   { 
00051    msg_body_start_ = buf_ + sizeof(Header); 
00052   } 
00053  
00054   uint32 code() const { return head_->code_; } 
00055   uint32 size() const { return convert32(head_->size_); } 
00056   uint8* msgBody() const {return msg_body_start_; } 
00057   uint8* startAddress() { return buf_; }
00058   uint32 bodySize() const {
00059     return convert32(head_->size_) - (msg_body_start_ - buf_);
00060   }
00061  
00062 private: 
00063   uint8* buf_; 
00064   uint8* msg_body_start_; 
00065   Header* head_; 
00066 }; 
00067 
00068 #endif
00069