OpenCMISS-Zinc C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
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 "zinc/stream.h"
14 
15 namespace OpenCMISS
16 {
17 namespace Zinc
18 {
19 
20 class StreamresourceFile;
21 class StreamresourceMemory;
22 
37 {
38 protected:
39 
40  cmzn_streamresource_id id;
41 
42 public:
43 
44  Streamresource() : id(0)
45  { }
46 
47  // takes ownership of C handle, responsibility for destroying it
48  explicit Streamresource(cmzn_streamresource_id in_streamresource_id) : id(in_streamresource_id)
49  { }
50 
51  Streamresource(const Streamresource& streamResource) : id(cmzn_streamresource_access(streamResource.id))
52  { }
53 
54  Streamresource& operator=(const Streamresource& streamResource)
55  {
56  cmzn_streamresource_id temp_id = cmzn_streamresource_access(streamResource.id);
57  if (0 != id)
58  {
59  cmzn_streamresource_destroy(&id);
60  }
61  id = temp_id;
62  return *this;
63  }
64 
66  {
67  if (0 != id)
68  {
69  cmzn_streamresource_destroy(&id);
70  }
71  }
72 
78  bool isValid() const
79  {
80  return (0 != id);
81  }
82 
88  cmzn_streamresource_id getId() const
89  {
90  return id;
91  }
92 
100  inline StreamresourceFile castFile();
112 
113 };
114 
123 {
124 public:
125 
127  { }
128 
129  // takes ownership of C handle, responsibility for destroying it
130  explicit StreamresourceFile(cmzn_streamresource_file_id streamresource_file_id) :
131  Streamresource(reinterpret_cast<cmzn_streamresource_id>(streamresource_file_id))
132  { }
133 
140  char *getName()
141  {
142  return cmzn_streamresource_file_get_name(
143  reinterpret_cast<cmzn_streamresource_file_id>(id));
144  }
145 
146 };
147 
157 {
158 public:
159 
161  { }
162 
163  // takes ownership of C handle, responsibility for destroying it
164  explicit StreamresourceMemory(cmzn_streamresource_memory_id streamresource_memory_id) :
165  Streamresource(reinterpret_cast<cmzn_streamresource_id>(streamresource_memory_id))
166  { }
167 
179  int getBuffer(void **memory_buffer_references, unsigned int *memory_buffer_sizes)
180  {
181  return cmzn_streamresource_memory_get_buffer(
182  reinterpret_cast<cmzn_streamresource_memory_id>(id), memory_buffer_references,
183  memory_buffer_sizes);
184  }
185 
186 };
187 
189 {
190  return StreamresourceFile(cmzn_streamresource_cast_file(id));
191 }
192 
194 {
195  return StreamresourceMemory(cmzn_streamresource_cast_memory(id));
196 }
197 
201 
213 {
214 protected:
215 
216  cmzn_streaminformation_id id;
217 
218 public:
219 
220  Streaminformation() : id(0)
221  { }
222 
223  // takes ownership of C handle, responsibility for destroying it
224  explicit Streaminformation(cmzn_streaminformation_id in_streaminformation_id) : id(in_streaminformation_id)
225  { }
226 
227  Streaminformation(const Streaminformation& streamInformation) :
228  id(cmzn_streaminformation_access(streamInformation.id))
229  { }
230 
235  {
236  DATA_COMPRESSION_TYPE_INVALID = CMZN_STREAMINFORMATION_DATA_COMPRESSION_TYPE_INVALID,
238  DATA_COMPRESSION_TYPE_DEFAULT = CMZN_STREAMINFORMATION_DATA_COMPRESSION_TYPE_DEFAULT,
246  DATA_COMPRESSION_TYPE_NONE = CMZN_STREAMINFORMATION_DATA_COMPRESSION_TYPE_NONE,
251  DATA_COMPRESSION_TYPE_GZIP = CMZN_STREAMINFORMATION_DATA_COMPRESSION_TYPE_GZIP,
258  DATA_COMPRESSION_TYPE_BZ2 = CMZN_STREAMINFORMATION_DATA_COMPRESSION_TYPE_BZIP2
265  };
266 
267  Streaminformation& operator=(const Streaminformation& streamInformation)
268  {
269  cmzn_streaminformation_id temp_id = cmzn_streaminformation_access(streamInformation.id);
270  if (0 != id)
271  {
272  cmzn_streaminformation_destroy(&id);
273  }
274  id = temp_id;
275  return *this;
276  }
277 
278  ~Streaminformation()
279  {
280  if (0 != id)
281  {
282  cmzn_streaminformation_destroy(&id);
283  }
284  }
285 
291  bool isValid() const
292  {
293  return (0 != id);
294  }
295 
301  cmzn_streaminformation_id getId() const
302  {
303  return id;
304  }
305 
322  {
323  return StreamresourceFile(reinterpret_cast<cmzn_streamresource_file_id>(
324  cmzn_streaminformation_create_streamresource_file(id, file_name)));
325  }
326 
343  {
344  return StreamresourceMemory(reinterpret_cast<cmzn_streamresource_memory_id>(
345  cmzn_streaminformation_create_streamresource_memory(id)));
346  }
347 
366  unsigned int buffer_length)
367  {
368  return StreamresourceMemory(reinterpret_cast<cmzn_streamresource_memory_id>(
369  cmzn_streaminformation_create_streamresource_memory_buffer(id, buffer, buffer_length)));
370  }
371 
381  {
382  return static_cast<DataCompressionType>(
383  cmzn_streaminformation_get_resource_data_compression_type(
384  reinterpret_cast<cmzn_streaminformation_id>(id), resource.getId()));
385  }
386 
399  int setResourceDataCompressionType(const Streamresource& resource, DataCompressionType dataCompressionType)
400  {
401  return cmzn_streaminformation_set_resource_data_compression_type(
402  reinterpret_cast<cmzn_streaminformation_id>(id), resource.getId(),
403  static_cast<cmzn_streaminformation_data_compression_type>(dataCompressionType));
404  }
405 
413  {
414  return static_cast<DataCompressionType>(
415  cmzn_streaminformation_get_data_compression_type(
416  reinterpret_cast<cmzn_streaminformation_id>(id)));
417  }
418 
429  {
430  return cmzn_streaminformation_set_data_compression_type(
431  reinterpret_cast<cmzn_streaminformation_id>(id),
432  static_cast<cmzn_streaminformation_data_compression_type>(dataCompressionType));
433  }
434 
459 
460 };
461 
462 } // namespace Zinc
463 }
464 
465 
466 #endif /* CMZN_STREAM_HPP__ */
StreamresourceFile castFile()
Definition: stream.hpp:188
A derived streamresource describing a file.
Definition: stream.hpp:122
enum DataCompressionType getResourceDataCompressionType(const Streamresource &resource)
Definition: stream.hpp:380
A description of a resource for reading from or writing to.
Definition: stream.hpp:36
int getBuffer(void **memory_buffer_references, unsigned int *memory_buffer_sizes)
Definition: stream.hpp:179
A region-specific stream information object.
Definition: streamregion.hpp:31
int setDataCompressionType(DataCompressionType dataCompressionType)
Definition: stream.hpp:428
StreaminformationImage castImage()
Definition: streamimage.hpp:211
Base type listing resources and options for stream I/O.
Definition: stream.hpp:212
A scene-specific stream information object.
Definition: streamscene.hpp:31
StreaminformationRegion castRegion()
Definition: streamregion.hpp:367
int setResourceDataCompressionType(const Streamresource &resource, DataCompressionType dataCompressionType)
Definition: stream.hpp:399
char * getName()
Definition: stream.hpp:140
DataCompressionType
Definition: stream.hpp:234
A derived stream resource describing a block of memory.
Definition: stream.hpp:156
An image-specific stream information object.
Definition: streamimage.hpp:30
StreamresourceMemory castMemory()
Definition: stream.hpp:193
enum DataCompressionType getDataCompressionType()
Definition: stream.hpp:412
StreamresourceFile createStreamresourceFile(const char *file_name)
Definition: stream.hpp:321
StreamresourceMemory createStreamresourceMemory()
Definition: stream.hpp:342
bool isValid() const
Definition: stream.hpp:291
StreaminformationScene castScene()
Definition: streamscene.hpp:308
StreamresourceMemory createStreamresourceMemoryBuffer(const void *buffer, unsigned int buffer_length)
Definition: stream.hpp:365
cmzn_streaminformation_id getId() const
Definition: stream.hpp:301
cmzn_streamresource_id getId() const
Definition: stream.hpp:88
bool isValid() const
Definition: stream.hpp:78