Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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"
48
49#include <map>
50
51namespace steam {
52namespace 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;
76
77 public:
78
81
82
83 static void shutdown ();
84
85 static ModelPortRegistry*
87
88 static ModelPortRegistry&
90
91 static ModelPortDescriptor const&
93
94
96 definePort (PID pipe, StID element_exposing_this_port);
97
98 bool contains (PID) const;
99 bool isRegistered (PID) const;
100
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 using MPTable = std::map<PID, ModelPortDescriptor>;
126
129 };
130
131
132
133
139 {
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*/
Optional or switchable link to an existing object.
thin wrapper around a size_t hash ID used as primary key for all Asset objects.
Definition asset.hpp:98
structural asset corresponding to the part of the model forming a processing pipe for generating medi...
Definition pipe.hpp:72
key abstraction: structural asset Created automatically as a sideeffect of building the structure of ...
Definition struct.hpp:105
ModelPortDescriptor records are used as actual storage within the model port registration table; they...
ModelPortDescriptor(PID pipe, StID element_exposing_this_port)
Management facility for tracking model ports.
ModelPortDescriptor const & definePort(PID pipe, StID element_exposing_this_port)
create and register a new model port entry, within the pending transaction
void rollback()
discard pending changes.
ModelPortDescriptor const & get(PID) const
basic access operation: access the descriptor of a currently valid model port.
void remove(PID)
remove a model port entry from the pending transaction
std::map< PID, ModelPortDescriptor > MPTable
bool contains(PID) const
does the transaction currently being built already contain a model port registration for the given ID...
static ModelPortRegistry & globalInstance()
access the globally valid registry instance.
static void shutdown()
globally deactivate access to model ports
static lib::OptionalRef< ModelPortRegistry > theGlobalRegistry
storage for the link to the global Registry instance currently in charge
static ModelPortDescriptor const & accessDescriptor(PID)
access the globally valid model port for the given pipe.
static ModelPortRegistry * setActiveInstance(ModelPortRegistry &newRegistry)
switch the implicit link to the global ModelPort registry to point to the given implementation instan...
void clear()
schedule removal of all registry contents.
void commit()
activate pending model port changes.
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Definition error.h:62
Lumiera error handling (C++ interface).
Organising the output data calculation possibilities.
Steam-Layer implementation namespace root.
a checked, switchable reference.
A "processing pipe" represented as Asset.
Asset representation of structural elements within the model.