00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : David BEILLOIN (MMM yyyy) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef SO_MEMORY_BUFFER_H 00026 #define SO_MEMORY_BUFFER_H 00027 00028 #include <ScaleViz/SoScaleViz.h> 00029 00030 class SoMemoryObject; 00031 00032 SoEXTENDER_Documented class SoMemoryBuffer 00033 { 00034 public: 00035 00037 SoMemoryBuffer(); 00038 00040 SoMemoryBuffer( char* data, 00041 const size_t size, 00042 const size_t nbElement = 1, 00043 char* externalPointer = NULL ); 00044 00046 SoMemoryBuffer(SoMemoryObject* memObj); 00047 00049 virtual ~SoMemoryBuffer(); 00050 00052 void setSize( const size_t size, const size_t nbElement = 1 ); 00053 00055 inline size_t getSize() const; 00056 00058 inline size_t getNbElement() const; 00059 00061 char* getPointer() const; 00062 00064 char* getExternalPointer() const; 00065 00066 private: 00067 // Size of the buffer 00068 size_t m_size; 00069 size_t m_nbElement; 00070 00071 // Pointer on the current data 00072 char* m_data; 00073 00074 // Current internal byte size 00075 size_t m_ByteSize; 00076 00077 // Indicate if the internal memory has been allocated outside by the user 00078 // in this case only the user can free the memory area 00079 bool m_externalAlloc; 00080 00081 char* m_externalPointer; 00082 00083 SoMemoryObject* m_memObj; 00084 }; 00085 00086 00087 inline size_t 00088 SoMemoryBuffer::getSize() const 00089 { 00090 return ( m_size * m_nbElement ); 00091 } 00092 00093 inline size_t 00094 SoMemoryBuffer::getNbElement() const 00095 { 00096 return m_nbElement; 00097 } 00098 00099 inline char* 00100 SoMemoryBuffer::getPointer() const 00101 { 00102 return m_data; 00103 } 00104 00105 inline char* 00106 SoMemoryBuffer::getExternalPointer() const 00107 { 00108 return m_externalPointer; 00109 } 00110 00111 #endif // SO_MEMORY_BUFFER_H 00112 00113 00114 00115 00116