OpenCMISS-Zinc C++ API Documentation
stream.hpp
Go to the documentation of this file.
1 
4 /* OpenCMISS-Zinc Library
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 
10 #ifndef CMZN_STREAM_HPP__
11 #define CMZN_STREAM_HPP__
12 
13 #include "opencmiss/zinc/stream.h"
14 
15 namespace OpenCMISS
16 {
17 namespace Zinc
18 {
19 
20 class StreamresourceFile;
21 class StreamresourceMemory;
22 
38 {
39 protected:
40 
41  cmzn_streamresource_id id;
42 
43 public:
44 
45  Streamresource() : id(0)
46  { }
47 
48  // takes ownership of C handle, responsibility for destroying it
49  explicit Streamresource(cmzn_streamresource_id in_streamresource_id) : id(in_streamresource_id)
50  { }
51 
52  Streamresource(const Streamresource& streamResource) : id(cmzn_streamresource_access(streamResource.id))
53  { }
54 
55  Streamresource& operator=(const Streamresource& streamResource)
56  {
57  cmzn_streamresource_id temp_id = cmzn_streamresource_access(streamResource.id);
58  if (0 != id)
59  {
60  cmzn_streamresource_destroy(&id);
61  }
62  id = temp_id;
63  return *this;
64  }
65 
67  {
68  if (0 != id)
69  {
70  cmzn_streamresource_destroy(&id);
71  }
72  }
73 
79  bool isValid() const
80  {
81  return (0 != id);
82  }
83 
89  cmzn_streamresource_id getId() const
90  {
91  return id;
92  }
93 
101  inline StreamresourceFile castFile();
113 
114 };
115 
124 {
125 public:
126 
128  { }
129 
130  // takes ownership of C handle, responsibility for destroying it
131  explicit StreamresourceFile(cmzn_streamresource_file_id streamresource_file_id) :
132  Streamresource(reinterpret_cast<cmzn_streamresource_id>(streamresource_file_id))
133  { }
134 
141  char *getName()
142  {
143  return cmzn_streamresource_file_get_name(
144  reinterpret_cast<cmzn_streamresource_file_id>(id));
145  }
146 
147 };
148 
158 {
159 public:
160 
162  { }
163 
164  // takes ownership of C handle, responsibility for destroying it
165  explicit StreamresourceMemory(cmzn_streamresource_memory_id streamresource_memory_id) :
166  Streamresource(reinterpret_cast<cmzn_streamresource_id>(streamresource_memory_id))
167  { }
168 
180  int getBuffer(void **memory_buffer_references, unsigned int *memory_buffer_sizes)
181  {
182  return cmzn_streamresource_memory_get_buffer(
183  reinterpret_cast<cmzn_streamresource_memory_id>(id), memory_buffer_references,
184  memory_buffer_sizes);
185  }
186 
187 };
188 
190 {
191  return StreamresourceFile(cmzn_streamresource_cast_file(id));
192 }
193 
195 {
196  return StreamresourceMemory(cmzn_streamresource_cast_memory(id));
197 }
198 
202 
214 {
215 protected:
216 
217  cmzn_streaminformation_id id;
218 
219 public:
220 
221  Streaminformation() : id(0)
222  { }
223 
224  // takes ownership of C handle, responsibility for destroying it
225  explicit Streaminformation(cmzn_streaminformation_id in_streaminformation_id) : id(in_streaminformation_id)
226  { }
227 
228  Streaminformation(const Streaminformation& streamInformation) :
229  id(cmzn_streaminformation_access(streamInformation.id))
230  { }
231 
236  {
237  DATA_COMPRESSION_TYPE_INVALID = CMZN_STREAMINFORMATION_DATA_COMPRESSION_TYPE_INVALID,
239  DATA_COMPRESSION_TYPE_DEFAULT = CMZN_STREAMINFORMATION_DATA_COMPRESSION_TYPE_DEFAULT,
247  DATA_COMPRESSION_TYPE_NONE = CMZN_STREAMINFORMATION_DATA_COMPRESSION_TYPE_NONE,
252  DATA_COMPRESSION_TYPE_GZIP = CMZN_STREAMINFORMATION_DATA_COMPRESSION_TYPE_GZIP,
259  DATA_COMPRESSION_TYPE_BZ2 = CMZN_STREAMINFORMATION_DATA_COMPRESSION_TYPE_BZIP2
266  };
267 
268  Streaminformation& operator=(const Streaminformation& streamInformation)
269  {
270  cmzn_streaminformation_id temp_id = cmzn_streaminformation_access(streamInformation.id);
271  if (0 != id)
272  {
273  cmzn_streaminformation_destroy(&id);
274  }
275  id = temp_id;
276  return *this;
277  }
278 
280  {
281  if (0 != id)
282  {
283  cmzn_streaminformation_destroy(&id);
284  }
285  }
286 
292  bool isValid() const
293  {
294  return (0 != id);
295  }
296 
302  cmzn_streaminformation_id getId() const
303  {
304  return id;
305  }
306 
323  {
324  return StreamresourceFile(reinterpret_cast<cmzn_streamresource_file_id>(
325  cmzn_streaminformation_create_streamresource_file(id, file_name)));
326  }
327 
344  {
345  return StreamresourceMemory(reinterpret_cast<cmzn_streamresource_memory_id>(
346  cmzn_streaminformation_create_streamresource_memory(id)));
347  }
348 
367  unsigned int buffer_length)
368  {
369  return StreamresourceMemory(reinterpret_cast<cmzn_streamresource_memory_id>(
370  cmzn_streaminformation_create_streamresource_memory_buffer(id, buffer, buffer_length)));
371  }
372 
390  unsigned int buffer_length)
391  {
392  return StreamresourceMemory(reinterpret_cast<cmzn_streamresource_memory_id>(
393  cmzn_streaminformation_create_streamresource_memory_buffer_copy(id, buffer, buffer_length)));
394  }
395 
404  enum DataCompressionType getResourceDataCompressionType(const Streamresource& resource)
405  {
406  return static_cast<DataCompressionType>(
407  cmzn_streaminformation_get_resource_data_compression_type(
408  reinterpret_cast<cmzn_streaminformation_id>(id), resource.getId()));
409  }
410 
423  int setResourceDataCompressionType(const Streamresource& resource, DataCompressionType dataCompressionType)
424  {
425  return cmzn_streaminformation_set_resource_data_compression_type(
426  reinterpret_cast<cmzn_streaminformation_id>(id), resource.getId(),
427  static_cast<cmzn_streaminformation_data_compression_type>(dataCompressionType));
428  }
429 
436  enum DataCompressionType getDataCompressionType()
437  {
438  return static_cast<DataCompressionType>(
439  cmzn_streaminformation_get_data_compression_type(
440  reinterpret_cast<cmzn_streaminformation_id>(id)));
441  }
442 
453  {
454  return cmzn_streaminformation_set_data_compression_type(
455  reinterpret_cast<cmzn_streaminformation_id>(id),
456  static_cast<cmzn_streaminformation_data_compression_type>(dataCompressionType));
457  }
458 
466  inline StreaminformationImage castImage();
474  inline StreaminformationRegion castRegion();
482  inline StreaminformationScene castScene();
483 
484 };
485 
486 } // namespace Zinc
487 }
488 
489 
490 #endif /* CMZN_STREAM_HPP__ */
StreamresourceFile castFile()
Definition: stream.hpp:189
A derived streamresource describing a file.
Definition: stream.hpp:123
A description of a resource for reading from or writing to.
Definition: stream.hpp:37
int getBuffer(void **memory_buffer_references, unsigned int *memory_buffer_sizes)
Definition: stream.hpp:180
A region-specific stream information object.
Definition: streamregion.hpp:31
int setDataCompressionType(DataCompressionType dataCompressionType)
Definition: stream.hpp:452
Base type listing resources and options for stream I/O.
Definition: stream.hpp:213
StreamresourceMemory createStreamresourceMemoryBufferCopy(const void *buffer, unsigned int buffer_length)
Definition: stream.hpp:389
A scene-specific stream information object.
Definition: streamscene.hpp:31
int setResourceDataCompressionType(const Streamresource &resource, DataCompressionType dataCompressionType)
Definition: stream.hpp:423
char * getName()
Definition: stream.hpp:141
DataCompressionType
Definition: stream.hpp:235
A derived stream resource describing a block of memory.
Definition: stream.hpp:157
An image-specific stream information object.
Definition: streamimage.hpp:30
StreamresourceMemory castMemory()
Definition: stream.hpp:194
StreamresourceFile createStreamresourceFile(const char *file_name)
Definition: stream.hpp:322
StreamresourceMemory createStreamresourceMemory()
Definition: stream.hpp:343
bool isValid() const
Definition: stream.hpp:292
The OpenCMISS namespace.
Definition: context.hpp:20
StreamresourceMemory createStreamresourceMemoryBuffer(const void *buffer, unsigned int buffer_length)
Definition: stream.hpp:366
cmzn_streaminformation_id getId() const
Definition: stream.hpp:302
cmzn_streamresource_id getId() const
Definition: stream.hpp:89
bool isValid() const
Definition: stream.hpp:79