shm_message.h

Go to the documentation of this file.
00001 
00004 #ifndef SHM_MESSAGE_H
00005 #define SHM_MESSAGE_H 1
00006 
00007 #include <string>
00008 #include <vector>
00009 
00013 class shm_message
00014 {
00015  public:
00016 
00017   shm_message() {} ;
00018   /*
00019       string m, 
00020       shm_allocator& a 
00021      ) 
00022   {
00023       char * text = static_cast<char*> ( a.alloc( m.size() + 1 ) );
00024       strncpy( m->message.get(seg), line.c_str(), m.size() + 1 );
00025       message.reset( text, seg );
00026   }
00027   */
00028 
00029   void* operator new(size_t s, shm_allocator& a)
00030   {
00031       return a.alloc(s);
00032   }
00033  
00034   void operator delete(void* p, shm_allocator& a)
00035   {
00036     a.free(p);
00037   }
00038 
00039   int getId() { return sequence_num; };
00040 
00041   int setId( int id ) { return sequence_num = id; };
00042 
00043   char * getText( const shm_segment& seg ) { return message.get(seg); };
00044 
00045   int setText( std::string line, const shm_segment& seg, shm_allocator& a ) 
00046   { 
00047     message.reset( static_cast<char*>( a.alloc( line.size() + 1 ) ), seg );
00048     strcpy( message.get(seg), line.c_str() );
00049     return message.off();
00050   };
00051 
00052   int sequence_num;
00053   shm_ptr<char> message;
00054 
00055 };
00056 
00057 #endif
00058 
00059 /*
00060  * $Log: shm_message.h,v $
00061  * Revision 1.1.1.1  2006/08/30 12:14:48  oommoo
00062  * Initial checkin of project library
00063  *
00064  * 
00065  * SharedMemory notes from :
00066  *
00067  * http://home.earthlink.net/~joshwalker1/writing/SharedMemory.html
00068  *
00069  */
00070  

Project shmq hosted by   SourceForge.net
Documentation generated on Sat Sep 2 10:07:40 2006 for shmq by   doxygen.org 1.4.6