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 "opencmiss/zinc/context.h"
14 
20 namespace OpenCMISS
21 {
27 namespace Zinc
28 {
29 class Fontmodule;
30 class Glyphmodule;
31 class Lightmodule;
32 class Logger;
33 class Materialmodule;
34 class Region;
35 class Scenefiltermodule;
36 class Sceneviewermodule;
37 class Spectrummodule;
38 class Tessellationmodule;
39 class Timekeepermodule;
40 
49 class Context
50 {
51 private:
52 
53  cmzn_context_id id;
54 
55 public:
56 
57  Context() : id(0)
58  { }
59  // Creates a new zinc Context instance
60  Context(const char *contextName) :
61  id(cmzn_context_create(contextName))
62  { }
63 
64  // takes ownership of C handle, responsibility for destroying it
65  explicit Context(cmzn_context_id context_id) :
66  id(context_id)
67  { }
68 
69  Context(const Context& context) :
70  id(cmzn_context_access(context.id))
71  { }
72 
73  ~Context()
74  {
75  if (0 != id)
76  {
77  cmzn_context_destroy(&id);
78  }
79  }
80 
86  bool isValid() const
87  {
88  return (0 != id);
89  }
90 
91  Context& operator=(const Context& context)
92  {
93  cmzn_context_id temp_id = cmzn_context_access(context.id);
94  if (0 != id)
95  {
96  cmzn_context_destroy(&id);
97  }
98  id = temp_id;
99  return *this;
100  }
101 
107  cmzn_context_id getId() const
108  {
109  return id;
110  }
111 
120  int getVersion(int *versionOut3)
121  {
122  return cmzn_context_get_version(id, versionOut3);
123  }
124 
130  const char* getRevision()
131  {
132  return cmzn_context_get_revision(id);
133  }
134 
146  {
147  return cmzn_context_get_version_string(id);
148  }
149 
161  inline Region createRegion();
162 
169  inline Region getDefaultRegion();
170 
178  inline int setDefaultRegion(const Region& region);
179 
185  inline Fontmodule getFontmodule();
186 
194  inline Glyphmodule getGlyphmodule();
195 
202  inline Lightmodule getLightmodule();
203 
209  inline Logger getLogger();
210 
220 
228 
236 
244 
252 
260 
261 };
262 
263 inline bool operator==(const Context& a, const Context& b)
264 {
265  return a.getId() == b.getId();
266 }
267 
268 } // namespace Zinc
269 }
270 
271 #endif /* CMZN_CONTEXT_HPP__ */
Fontmodule getFontmodule()
Definition: font.hpp:404
bool isValid() const
Definition: context.hpp:86
Module managing all light objects.
Definition: light.hpp:484
int getVersion(int *versionOut3)
Definition: context.hpp:120
int setDefaultRegion(const Region &region)
Definition: region.hpp:421
Module managing all fonts.
Definition: font.hpp:273
Materialmodule getMaterialmodule()
Definition: material.hpp:560
Glyphmodule getGlyphmodule()
Definition: glyph.hpp:1176
A hierarchical block/namespace owning domains and fields.
Definition: region.hpp:33
Module managing all scene filters.
Definition: scenefilter.hpp:313
Font object controlling attributes of rendering text.
Definition: logger.hpp:28
Region getDefaultRegion()
Definition: region.hpp:416
Module object for creating and managing scene viewers.
Definition: sceneviewer.hpp:1234
Sceneviewermodule getSceneviewermodule()
Definition: sceneviewer.hpp:1336
The context is the primary object created for each instance of Zinc.
Definition: context.hpp:49
Module managing all spectrums.
Definition: spectrum.hpp:1037
Module managing all materials.
Definition: material.hpp:350
Timekeepermodule getTimekeepermodule()
Definition: timekeeper.hpp:313
Module managing all glyphs.
Definition: glyph.hpp:714
char * getVersionString()
Definition: context.hpp:145
const char * getRevision()
Definition: context.hpp:130
Scenefiltermodule getScenefiltermodule()
Definition: scenefilter.hpp:518
Module managing all tessellation objects.
Definition: tessellation.hpp:354
Module for finding and managing timekeepers.
Definition: timekeeper.hpp:222
cmzn_context_id getId() const
Definition: context.hpp:107
Lightmodule getLightmodule()
Definition: light.hpp:666
Spectrummodule getSpectrummodule()
Definition: spectrum.hpp:1442
Region createRegion()
Definition: region.hpp:426
Tessellationmodule getTessellationmodule()
Definition: tessellation.hpp:783
Logger getLogger()
Definition: logger.hpp:429