Lumiera  0.pre.03
»edit your freedom«
buffhandle-attach.hpp
Go to the documentation of this file.
1 /*
2  BUFFHANDLE-ATTACH.hpp - Buffer handle extension to attach objects into the buffer
3 
4  Copyright (C) Lumiera.org
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
44 #ifndef ENGINE_BUFFHANDLE_ATTACH_H
45 #define ENGINE_BUFFHANDLE_ATTACH_H
46 
47 
48 #include "lib/error.hpp"
51 
52 
53 namespace steam {
54 namespace engine {
55 
56 
57 
58 
59  /* === BuffHandle Implementation === */
60 
61 
62 #define _EXCEPTION_SAFE_INVOKE(_CTOR_) \
63  try \
64  { \
65  return *new(pBuffer_) _CTOR_; \
66  } \
67  catch(...) \
68  { \
69  emergencyCleanup(); /* EX_FREE */ \
70  pBuffer_ = 0; \
71  throw; \
72  }
73 
83  template<typename BU>
84  inline BU&
86  {
87  takeOwnershipFor<BU>();
88  _EXCEPTION_SAFE_INVOKE (BU());
89  }
90 
91 #undef _EXCEPTION_SAFE_INVOKE
92 
93 
94 
102  template<typename BU>
103  inline void
105  {
106  BufferDescriptor howto_attach_object_automatically
107  = descriptor_.provider_->getDescriptor<BU>();
108  takeOwnershipFor (howto_attach_object_automatically); // EX_STRONG
109  }
110 
111 
117  template<typename BU>
118  inline BU&
120  {
121  if (!pBuffer_)
122  throw error::Logic ("buffer not (yet) locked for access by clients"
123  , LERR_(LIFECYCLE));
124  return *reinterpret_cast<BU*> (pBuffer_);
125  }
126 
127 
128 
129 }} // namespace steam::engine
130 #endif
Steam-Layer implementation namespace root.
BU & accessAs()
convenience shortcut: access the buffer contents casted to a specific type.
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:199
BU & create()
convenience shortcut: place and maintain an object within the buffer.
An opaque descriptor to identify the type and further properties of a data buffer.
Definition: buffhandle.hpp:85
A front-end to support the buffer management within the render nodes.
Lumiera error handling (C++ interface).
Abstraction to represent buffer management and lifecycle within the render engine.
BufferDescriptor getDescriptor()
define a "buffer type" for automatically creating an instance of the template type embedded into the ...