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 // TimeSeries.h: interface for the ObjectDictionary class. 00024 // 00025 ////////////////////////////////////////////////////////////////////// 00026 00027 #if !defined(_TIMESERIES_H_) 00028 #define _TIMESERIES_H_ 00029 00030 #include "Object.h" 00031 #include "JTime.h" 00032 #include "Collections.h" 00033 00034 namespace cmlabs { 00035 00036 class TimeSeries : public Object 00037 { 00038 public: 00039 TimeSeries(); 00040 TimeSeries(const TimeSeries &ts); 00041 TimeSeries(const JString& xml); 00042 TimeSeries(XMLNode *node); 00043 virtual ~TimeSeries(); 00044 00045 const TimeSeries& operator = (const TimeSeries& profile); 00046 Object* clone() const; 00047 //! Get total size of payload 00048 virtual unsigned long getPayloadSize() const; 00049 00050 bool contains(const JTime& time); 00051 int getCount(); 00052 00053 Object* get(int pos); 00054 //! Will only return the first if more with same time exist 00055 Object* get(const JTime& time); 00056 Object* getFirstAfter(const JTime& time); 00057 Object* getLastBefore(const JTime& time); 00058 ObjectCollection* getAllBetween(const JTime& t1, const JTime& t2); 00059 ObjectCollection* getAllBefore(const JTime& time); 00060 ObjectCollection* getAllAfter(const JTime& time); 00061 bool put(const JTime& time, Object* obj); 00062 bool remove(const JTime& time); 00063 bool removeOldest(); 00064 bool removeNewest(); 00065 bool removeAllBetween(const JTime& t1, const JTime& t2); 00066 bool removeAllBefore(const JTime& time); 00067 bool removeAllAfter(const JTime& time); 00068 bool removeAll(); 00069 00070 JTime getTime(int pos); 00071 JTime getFirstTime(); 00072 JTime getLastTime(); 00073 JTime getNextTime(); 00074 JTime getPreviousTime(); 00075 00076 Object* getOldest(); 00077 Object* getNewest(); 00078 00079 // *************************************************************** 00080 // Binary Functions 00081 // *************************************************************** 00082 00083 //! Get the size of binary data chunk, -1 for all chunks 00084 long getBinarySize(int chunk); 00085 //! Get the number of data chunks 00086 int getBinaryChunkCount(); 00087 //! Write binary data to buffer at chunk number 'chunk' 00088 long toBinaryBuffer(int chunk, char* buffer, int maxlen); 00089 //! Set the data after separate reception 00090 bool fromBinaryBuffer(int chunk, char* buffer, long len); 00091 00092 JString print() ; 00093 bool unitTest(); 00094 00095 protected: 00096 00097 SortedCollection times; 00098 ObjectDictionary dict; 00099 }; 00100 00101 } // namespace cmlabs 00102 00103 #endif // !defined(_TIMESERIES_H_)