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 // CollectionBase.h: interface for the CollectionBase class. 00024 // 00025 ////////////////////////////////////////////////////////////////////// 00026 00027 #if !defined(_COLLECTIONBASE_H_) 00028 #define _COLLECTIONBASE_H_ 00029 00030 #include "ObjectTable.h" 00031 00032 namespace cmlabs { 00033 00034 class CollectionBase : public Object 00035 { 00036 public: 00037 CollectionBase(); 00038 // CollectionBase(const CollectionBase &Coll); 00039 CollectionBase(const JString& xml); 00040 CollectionBase(XMLNode* node); 00041 virtual ~CollectionBase(); 00042 00043 ObjectTable objectTable; 00044 00045 virtual Object* clone() const; 00046 bool isCollection() const; 00047 //! Get total size of payload 00048 virtual unsigned long getPayloadSize() const; 00049 00050 virtual bool addAll(const CollectionBase* c); 00051 virtual bool copyAll(const CollectionBase* c); 00052 virtual bool takeAll(CollectionBase* c); 00053 virtual bool addAll(const CollectionBase& c); 00054 virtual bool copyAll(const CollectionBase& c); 00055 virtual bool takeAll(CollectionBase& c); 00056 00057 bool equals(const Object* o2) const; 00058 // virtual const CollectionBase& operator =(const CollectionBase& c); 00059 virtual bool operator ==(CollectionBase& c); 00060 virtual bool operator !=(CollectionBase& c); 00061 00062 int getCount() const; 00063 int length() const; 00064 00065 bool removeFirst(); 00066 bool removeLast(); 00067 bool remove(int pos); 00068 bool removeAll(); 00069 00070 JString toHTML(); 00071 JString toXML(); 00072 bool fromXML(const JString& xml); 00073 bool fromXML(XMLNode* node); 00074 00075 JString print() const; 00076 JString printListLine(const JString& separator, const JString& equalsign = " = ", const JString& quotes = "") const; 00077 00078 bool sortKeys(); 00079 bool sortValues(); 00080 bool sortKeysReverse(); 00081 bool sortValuesReverse(); 00082 bool sortRandomMix(); 00083 00084 bool removeNoDelete(int pos); 00085 bool removeAllNoDelete(); 00086 void noDelete(); 00087 void doDelete(); 00088 00089 00090 // *************************************************************** 00091 // Binary Functions 00092 // *************************************************************** 00093 00094 //! Get the size of binary data chunk, -1 for all chunks 00095 long getBinarySize(int chunk); 00096 //! Get the number of data chunks 00097 int getBinaryChunkCount(); 00098 //! Write binary data to buffer at chunk number 'chunk' 00099 long toBinaryBuffer(int chunk, char* buffer, int maxlen); 00100 //! Set the data after separate reception 00101 bool fromBinaryBuffer(int chunk, char* buffer, long len); 00102 00103 //! Get the binary data containing objects 00104 //ObjectCollection* getBinaryDataObjects(); 00105 00106 }; 00107 00108 } // namespace cmlabs 00109 00110 00111 #endif // !defined(_COLLECTIONBASE_H_)