Lumiera  0.pre.03
»edit your freedom«
model-port-registry.hpp
Go to the documentation of this file.
1 /*
2  MODEL-PORT-REGISTRY.hpp - creating and organising and accessing model ports
3 
4  Copyright (C)
5  2010, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
40 #ifndef STEAM_FIXTURE_MODEL_PORT_REGISTRY_H
41 #define STEAM_FIXTURE_MODEL_PORT_REGISTRY_H
42 
43 #include "lib/error.hpp"
44 #include "lib/optional-ref.hpp"
45 #include "steam/asset/pipe.hpp"
46 #include "steam/asset/struct.hpp"
48 
49 #include <map>
50 
51 namespace steam {
52 namespace fixture {
53 
54  using asset::ID;
55  using asset::Pipe;
56  using asset::Struct;
57 
58  LUMIERA_ERROR_DECLARE (DUPLICATE_MODEL_PORT);
59 
60 
72  {
73 
74  typedef ID<Pipe> PID;
75  typedef ID<Struct> StID;
76 
77  public:
78 
80  class ModelPortDescriptor;
81 
82 
83  static void shutdown ();
84 
85  static ModelPortRegistry*
86  setActiveInstance (ModelPortRegistry& newRegistry);
87 
88  static ModelPortRegistry&
90 
91  static ModelPortDescriptor const&
92  accessDescriptor (PID);
93 
94 
95  ModelPortDescriptor const&
96  definePort (PID pipe, StID element_exposing_this_port);
97 
98  bool contains (PID) const;
99  bool isRegistered (PID) const;
100 
101  ModelPortDescriptor const&
102  get (PID) const;
103 
104 
105  void remove (PID);
106  void clear();
107 
108 
114  void commit();
115 
119  void rollback();
120 
121 
122  private:
124 
125  typedef std::map<PID, ModelPortDescriptor> MPTable;
126 
127  MPTable currentReg_;
128  MPTable transaction_;
129  };
130 
131 
132 
133 
139  {
140  PID id_;
141  StID holder_;
142 
143  protected:
144  ModelPortDescriptor (PID pipe, StID element_exposing_this_port)
145  : id_(pipe)
146  , holder_(element_exposing_this_port)
147  { }
148 
149  friend class ModelPortRegistry;
150 
151  public:
153  : id_(PID::INVALID)
154  , holder_(StID::INVALID)
155  { }
156 
157  // default copy operations permitted
158 
159  bool
160  isValid() const
161  {
162  return bool(id_);
163  }
164 
165  const PID id() const { return id_; }
166  const StID holder() const { return holder_; }
167  };
168 
169 
170 
171 }} // namespace steam::fixture
172 #endif /*STEAM_FIXTURE_MODEL_PORT_REGISTRY_H*/
Organising the output data calculation possibilities.
ModelPortDescriptor const & definePort(PID pipe, StID element_exposing_this_port)
create and register a new model port entry, within the pending transaction
A "processing pipe" represented as Asset.
void clear()
schedule removal of all registry contents.
Optional or switchable link to an existing object.
bool contains(PID) const
does the transaction currently being built already contain a model port registration for the given ID...
void commit()
activate pending model port changes.
a checked, switchable reference.
static lib::OptionalRef< ModelPortRegistry > theGlobalRegistry
storage for the link to the global Registry instance currently in charge
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
static ModelPortDescriptor const & accessDescriptor(PID)
access the globally valid model port for the given pipe.
Steam-Layer implementation namespace root.
structural asset corresponding to the part of the model forming a processing pipe for generating medi...
Definition: pipe.hpp:70
ModelPortDescriptor records are used as actual storage within the model port registration table; they...
static ModelPortRegistry * setActiveInstance(ModelPortRegistry &newRegistry)
switch the implicit link to the global ModelPort registry to point to the given implementation instan...
static void shutdown()
globally deactivate access to model ports
Management facility for tracking model ports.
LUMIERA_ERROR_DECLARE(DUPLICATE_MODEL_PORT)
Attempt to define a new model port with an pipe-ID already denoting an existing port.
static ID INVALID
marker constant denoting a NIL asset
Definition: asset.hpp:107
Lumiera error handling (C++ interface).
static ModelPortRegistry & globalInstance()
access the globally valid registry instance.
key abstraction: structural asset Created automatically as a sideeffect of building the structure of ...
Definition: struct.hpp:104
void rollback()
discard pending changes.
Asset representation of structural elements within the model.
thin wrapper around a size_t hash ID used as primary key for all Asset objects.
Definition: asset.hpp:99