00001 #ifndef SHARED_MEMORY_CLASS
00002 #define SHARED_MEMORY_CLASS
00003
00004 #ifndef EMBEDDED_BUILD
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <basis/object_base.h>
00021
00022
00023 class byte_filer;
00024 class rendezvous;
00025
00027
00032 class OPSYSTEM_CLASS_STYLE shared_memory : public virtual object_base
00033 {
00034 public:
00035 shared_memory(int size, const char *identity);
00037
00043 virtual ~shared_memory();
00045
00048 IMPLEMENT_CLASS_NAME("shared_memory");
00049
00050 bool valid() const { return _valid; }
00052
00054 int size() const { return _size; }
00056
00057 const istring &identity() const;
00059
00060 bool first_usage(byte *locked_memory, int max_compare);
00062
00068 byte *lock();
00070
00074 void unlock(byte * &to_unlock);
00076
00078 static istring unique_shared_mem_identifier(int sequencer);
00080
00085 private:
00086 rendezvous *_locking;
00087 #ifdef __UNIX__
00088 int _the_memory;
00089 #elif defined(__WIN32__)
00090 void *_the_memory;
00091 #endif
00092 bool _valid;
00093 istring *_identity;
00094 int _size;
00095
00096
00097 byte *locked_grab_memory();
00098 void locked_release_memory(byte * &to_unlock);
00099
00100 static istring special_filename(const istring &identity);
00102
00103
00104 shared_memory(const shared_memory &);
00105 shared_memory &operator =(const shared_memory &);
00106 };
00107
00108 #endif // embedded.
00109
00110 #endif // outer guard.
00111