00001 /* 00002 * MessageQueue.h 00003 * 00004 * Smalltalk like class library for C++ 00005 * Message queue accessor. Header. 00006 * 00007 * Copyright (c) 2003 Martin Dvorak, Milan Cermak 00008 */ 00009 /* 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 #ifndef __MESSAGEQUEUE_H 00025 #define __MESSAGEQUEUE_H 00026 00027 #include <stlib/IOAccessor.h> 00028 00029 namespace OS { 00030 00031 class Core::ByteArray; 00032 class Core::String; 00033 00037 class MessageQueue : public Core::IOAccessor 00038 { 00039 protected: 00041 int queueid; 00043 int queueCreationKey; 00045 bool active; 00047 int _priority; 00048 00049 public: 00059 MessageQueue(int queueKey, bool exclusive); 00060 00061 static MessageQueue *open(void); 00062 static MessageQueue *open(String *key, bool exclusive = false); 00063 static MessageQueue *open(bool exclusive); 00064 00065 /* Accessing protocol */ 00066 virtual long bufferSize(void); 00067 virtual long priority(void); 00068 virtual void priority(long level); 00069 00074 virtual void close(void); 00075 00080 virtual int key(void) 00081 { return queueCreationKey; } 00082 00083 /* Data transfer protocol */ 00084 virtual int readInto(ByteArray *buffer, long startIndex, long count); 00085 virtual int writeFrom(ByteArray *buffer, long startIndex, long count); 00086 00087 /* Positioning protocol */ 00088 virtual void seekTo(long position); 00089 00090 /* Testing protocol */ 00092 virtual bool isActive(void) 00093 { return active; } 00094 }; 00095 00096 }; 00097 00098 #endif /* __MESSAGEQUEUE_H */