| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /****************************************************************************** 00002 * VRS - The Virtual Rendering System 00003 * Copyright (C) 2003 Computer Graphics Systems Group at the 00004 * Hasso-Plattner-Institute (HPI), Potsdam, Germany. 00005 * 00006 * This library is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or (at 00009 * your option) any later version. This library is distributed in the hope 00010 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 00011 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Lesser General Public License for more details. You should have received 00013 * a copy of the GNU Lesser+ General Public License along with this library; if 00014 * not, write to the FreeSoftware Foundation, Inc., 59 Temple Place, Suite 330, 00015 * Boston, MA, 02111-1307, USA. 00016 ******************************************************************************/ 00017 00018 // $Id: memorydataresource.h 5055 2005-10-06 09:53:07Z baumann $ 00019 // $Date: 2005-10-06 11:53:07 +0200 (Thu, 06 Oct 2005) $ 00020 // $Revision: 5055 $ 00021 // $State$ 00022 // $Author: baumann $ 00023 // 00024 // $Log$ 00025 // Revision 1.20 2005/10/06 09:53:07 baumann 00026 // made pointer() method from base class visible 00027 // 00028 // Revision 1.19 2005/10/06 09:46:43 baumann 00029 // - impl cleaned up 00030 // - is now resizable 00031 // 00032 // Revision 1.18 2005/01/03 01:43:09 klimetschek 00033 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00034 // - removed vrs.vcproj 00035 // minor things: 00036 // - added all glutexamples to vrs4glut.sln 00037 // - fixed some problems in glutexamples 00038 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00039 // 00040 // Revision 1.17 2004/11/03 11:56:56 saar 00041 // Class comment changed (Doxygen style) 00042 // 00043 // Revision 1.16 2004/03/12 16:28:40 baumann 00044 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00045 // 00046 // Revision 1.15 2004/01/19 11:43:58 baumann 00047 // serialization mechanism improved 00048 // 00049 // Revision 1.14 2004/01/19 07:28:04 baumann 00050 // serialization mechanism improved 00051 // 00052 // Revision 1.13 2003/07/06 13:02:14 baumann 00053 // using "new char[]" and "delete []" instead of malloc() and free() 00054 // 00055 // Revision 1.12 2002/10/29 10:32:52 baumann 00056 // macros VRS_CLASSNAME_* and VRS_IMPL_TYPEINFO_* removed 00057 // 00058 // Revision 1.11 2002/03/03 21:44:25 kosta 00059 // VRS_TYPEINFO-macro rewritten 00060 // 00061 // Revision 1.10 2002/02/19 10:34:17 kosta 00062 // undone all changes since 2002-02-15 00063 // 00064 // Revision 1.7 2002/02/13 09:00:05 kosta 00065 // additonal c'tor added, which copies an existing memory chunk 00066 // 00067 // Revision 1.6 2002/02/05 07:48:26 kosta 00068 // new persistency macros: 00069 // VRS_SERIALIZABLE(CLASS_NAME); 00070 // VRS_SERIALIZABLE_ABSTRACT_CLASS(CLASS_NAME); 00071 // VRS_SERIALIZABLE_NO_SO_CLASS(CLASS_NAME) 00072 // 00073 // Revision 1.5 2002/02/04 13:07:20 kosta 00074 // VRS_SERIALIZABLE macros completely rewritten 00075 // 00076 // Revision 1.4 2002/01/15 16:25:54 kosta 00077 // macros rewritten for a better namespace support 00078 // 00079 // Revision 1.3 2001/11/13 16:36:31 kirsch 00080 // changed line feed to unix style (removed control-M) 00081 // 00082 // Revision 1.2 2001/07/13 14:27:02 doellner 00083 // interfaces revised, assertions added 00084 // 00085 // Revision 1.1.1.1 2001/06/08 08:09:21 kirsch 00086 // imported alpha-version by olli 00087 // 00088 00089 00090 #ifndef VRS_IO_MEMORYDATARESOURCE_H 00091 #define VRS_IO_MEMORYDATARESOURCE_H 00092 00093 #include <vrs/io/dataresource.h> 00094 #include <vector> 00095 00096 namespace VRS { 00097 00099 class VRS_CORE_API MemoryDataResource : 00100 public DataResource 00101 { 00102 public: 00103 VRS_TYPEINFO(MemoryDataResource, DataResource); 00104 VRS_SERIALIZABLE(MemoryDataResource); 00105 00106 typedef std::vector<unsigned char> Bytes; 00107 00108 MemoryDataResource(unsigned int size, bool isWritable = true); 00109 MemoryDataResource(const void* sourceData, unsigned int size, bool isWritable = true); 00110 MemoryDataResource(const Bytes& bytes, bool isWritable = true); 00111 00112 void setWritable(bool onOff); 00113 00114 virtual void* pointer() const; 00115 using DataResource::pointer; 00116 00117 virtual unsigned int size() const; 00118 00119 virtual bool isWritable() const; 00120 00121 const Bytes& bytes() const; 00122 Bytes& bytes(); 00123 00124 protected: 00125 MemoryDataResource(); // only for persistency 00126 00127 private: 00128 Bytes m_bytes; 00129 bool m_isWritable; 00130 }; // class MemoryDataResource 00131 00132 } // namespace VRS 00133 00134 #endif // VRS_IO_MEMORYDATARESOURCE_H