OpenCMISS-Zinc C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
context.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_CONTEXT_HPP__
11 #define CMZN_CONTEXT_HPP__
12 
13 #include "zinc/context.h"
14 
20 namespace OpenCMISS
21 {
27 namespace Zinc
28 {
29 class Fontmodule;
30 class Glyphmodule;
31 class Lightmodule;
32 class Materialmodule;
33 class Region;
34 class Scenefiltermodule;
35 class Sceneviewermodule;
36 class Spectrummodule;
37 class Tessellationmodule;
38 class Timekeepermodule;
39 
48 class Context
49 {
50 private:
51 
52  cmzn_context_id id;
53 
54 public:
55 
56  Context() : id(0)
57  { }
58  // Creates a new zinc Context instance
59  Context(const char *contextName) :
60  id(cmzn_context_create(contextName))
61  { }
62 
63  // takes ownership of C handle, responsibility for destroying it
64  explicit Context(cmzn_context_id context_id) :
65  id(context_id)
66  { }
67 
68  Context(const Context& context) :
69  id(cmzn_context_access(context.id))
70  { }
71 
72  ~Context()
73  {
74  if (0 != id)
75  {
76  cmzn_context_destroy(&id);
77  }
78  }
79 
85  bool isValid() const
86  {
87  return (0 != id);
88  }
89 
90  Context& operator=(const Context& context)
91  {
92  cmzn_context_id temp_id = cmzn_context_access(context.id);
93  if (0 != id)
94  {
95  cmzn_context_destroy(&id);
96  }
97  id = temp_id;
98  return *this;
99  }
100 
106  cmzn_context_id getId() const
107  {
108  return id;
109  }
110 
119  int getVersion(int *versionOut3)
120  {
121  return cmzn_context_get_version(id, versionOut3);
122  }
123 
130  {
131  return cmzn_context_get_revision(id);
132  }
133 
145  {
146  return cmzn_context_get_version_string(id);
147  }
148 
160  inline Region createRegion();
161 
167  inline Region getDefaultRegion();
168 
174  inline Fontmodule getFontmodule();
175 
183  inline Glyphmodule getGlyphmodule();
184 
191  inline Lightmodule getLightmodule();
192 
202 
210 
218 
226 
234 
242 
243 };
244 
245 inline bool operator==(const Context& a, const Context& b)
246 {
247  return a.getId() == b.getId();
248 }
249 
250 } // namespace Zinc
251 }
252 
253 #endif /* CMZN_CONTEXT_HPP__ */
Fontmodule getFontmodule()
Definition: font.hpp:404
bool isValid() const
Definition: context.hpp:85
Module managing all light objects.
Definition: light.hpp:484
int getVersion(int *versionOut3)
Definition: context.hpp:119
Module managing all fonts.
Definition: font.hpp:273
Materialmodule getMaterialmodule()
Definition: material.hpp:533
int getRevision()
Definition: context.hpp:129
Glyphmodule getGlyphmodule()
Definition: glyph.hpp:911
A hierarchical block/namespace owning domains and fields.
Definition: region.hpp:33
Module managing all scene filters.
Definition: scenefilter.hpp:313
Region getDefaultRegion()
Definition: region.hpp:416
Module object for creating and managing scene viewers.
Definition: sceneviewer.hpp:1187
Sceneviewermodule getSceneviewermodule()
Definition: sceneviewer.hpp:1262
The context is the primary object created for each instance of Zinc.
Definition: context.hpp:48
Module managing all spectrums.
Definition: spectrum.hpp:922
Module managing all materials.
Definition: material.hpp:350
Timekeepermodule getTimekeepermodule()
Definition: timekeeper.hpp:289
Module managing all glyphs.
Definition: glyph.hpp:675
char * getVersionString()
Definition: context.hpp:144
Scenefiltermodule getScenefiltermodule()
Definition: scenefilter.hpp:518
Module managing all tessellation objects.
Definition: tessellation.hpp:323
Module for finding and managing timekeepers.
Definition: timekeeper.hpp:222
cmzn_context_id getId() const
Definition: context.hpp:106
Lightmodule getLightmodule()
Definition: light.hpp:662
Spectrummodule getSpectrummodule()
Definition: spectrum.hpp:1077
Region createRegion()
Definition: region.hpp:421
Tessellationmodule getTessellationmodule()
Definition: tessellation.hpp:501