00001 /***************************** License ********************************** 00002 00003 Copyright (C) 2008 by Communicative Machines 00004 http://www.cmlabs.com All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 ************************************************************************/ 00021 00022 00023 // BinaryBuffer.h: interface for the VideoBuffer class. 00024 // 00025 ////////////////////////////////////////////////////////////////////// 00026 00027 #if !defined(AFX_BINARYBUFFER_H__BF475DE2_2471_4C38_A8C6_895D616B3DF7__INCLUDED_) 00028 #define AFX_BINARYBUFFER_H__BF475DE2_2471_4C38_A8C6_895D616B3DF7__INCLUDED_ 00029 00030 #if _MSC_VER > 1000 00031 #pragma once 00032 #endif // _MSC_VER > 1000 00033 00034 #include "Object.h" 00035 #include "JString.h" 00036 #include "JTime.h" 00037 #include "Dictionary.h" 00038 #include "ObjectCollection.h" 00039 // #include <thread.h> 00040 #include "JSemaphore.h" 00041 00042 namespace cmlabs { 00043 00044 class BinaryBufferEntry : public Object { 00045 public: 00046 BinaryBufferEntry() { object = NULL; } 00047 virtual ~BinaryBufferEntry() { if (object != NULL) delete(object); } 00048 Object* clone() const {return NULL;} 00049 00050 long count; 00051 JTime timestamp; 00052 JString source; 00053 JString datatype; 00054 Dictionary inUseBy; 00055 Object* object; 00056 void* next; 00057 void* prev; 00058 }; 00059 00060 class BinaryBuffer : public Object 00061 { 00062 public: 00063 BinaryBuffer(long size = 100); 00064 virtual ~BinaryBuffer(); 00065 00066 bool addEntry(JTime stamp, JString source, JString datatype, Object* obj); 00067 bool reset(); 00068 bool deleteAll(); 00069 00070 Object* clone() const {return NULL;} 00071 JString print() ; 00072 JString printLast() ; 00073 00074 BinaryBufferEntry* getLastEntry(); 00075 00076 BinaryBufferEntry* waitForNextEntryAfter(JTime t, long ms = 1000); 00077 BinaryBufferEntry* getNextEntryAfter(JTime t); 00078 00079 long count; 00080 long buffersize; 00081 00082 protected: 00083 00084 ObjectCollection* inUseTable; 00085 00086 JMutex mutex; 00087 00088 BinaryBufferEntry* first; 00089 BinaryBufferEntry* last; 00090 BinaryBufferEntry* current; 00091 00092 JString print(BinaryBufferEntry* entry) ; 00093 bool checkInUseTable(); 00094 }; 00095 00096 } // namespace cmlabs 00097 00098 #endif // !defined(AFX_BINARYBUFFER_H__BF475DE2_2471_4C38_A8C6_895D616B3DF7__INCLUDED_)