Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
buildertool.hpp
Go to the documentation of this file.
1/*
2 BUILDERTOOL.hpp - Interface, (visiting) tool for processing MObjects
3
4 Copyright (C)
5 2008, 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
43#ifndef MOBJECT_BUILDER_TOOL_H
44#define MOBJECT_BUILDER_TOOL_H
45
46#include "lib/visitor.hpp"
47#include "lib/wrapperptr.hpp"
48
49#include "lib/p.hpp"
52
53
54namespace steam {
55namespace mobject {
56
57 class Buildable;
58
59 namespace builder {
60
61
67 template<class RET>
69 {
70 protected:
72 public:
73 virtual RET onUnknown (Buildable& target) = 0;
74 };
75
76
77
98 : public lib::visitor::Tool<void, InvokeCatchAllFunction>
100
101 public:
102
103 template<template<class> class WRA, class TAR>
104 void rememberWrapper (WRA<TAR>* ptr_toWrappedTarget)
105 {
106 currentWrapper_ = ptr_toWrappedTarget;
107 }
108 template<template<class,class> class Placement, class TAR, class B>
109 void rememberWrapper (Placement<TAR,B>* ptr_toWrappedTarget)
110 {
111 currentWrapper_ = ptr_toWrappedTarget;
112 }
113
115 {
117 }
118
119
120 protected: /* == interface for accessing the wrapper from within tool application == */
121
122 template<class TAR>
125 {
127 ENSURE (pPlacement, "wrong target type when invoking %s", __PRETTY_FUNCTION__);
128 return *pPlacement;
129 }
130
133 {
134 return getPlacement<MObject>().resolve();
135 }
136
137 template<class TAR>
140 {
142 ENSURE (pP, "wrong target type when invoking %s", __PRETTY_FUNCTION__);
143 return *pP;
144 }
145 };
146
147
148
153 template
154 < class TOOLImpl, // concrete BuilderTool implementation
155 class TYPELIST // list of all concrete Buildables to be treated
156 >
158 : public lib::visitor::Applicable<TOOLImpl, TYPELIST, BuilderTool>
159 { }
160 ;
161
162 using lib::meta::Types; // convenience for the users of "Applicable"
163
164 }// namespace mobject::builder
165
166
167
168
169
173 class Buildable : public lib::visitor::Visitable<builder::BuilderTool>
174 { };
175
176
177
178
179 namespace builder {
180
188 template<typename WRA>
190 apply (BuilderTool& tool, WRA& wrappedTargetObj)
191 {
192 tool.rememberWrapper(&wrappedTargetObj);
193 wrappedTargetObj->apply (tool); // dispatch to suitable treat() function
194 tool.forgetWrapper();
195 }
196
197
198}}} // namespace steam::mobject::builder
199#endif
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition p.hpp:77
TAR get()
retrieve current content of the variant, trying to cast or convert it to the given type.
Marker template to declare that some "visiting tool" wants to treat a set of concrete Visitable class...
Definition visitor.hpp:135
Marker interface / base class for all "visiting tools".
Definition visitor.hpp:99
Marker interface or base class for all "Visitables".
Definition visitor.hpp:189
Marker Interface for classes visitable by Builder tools.
Special kind of Placement, where the location of the MObject has been nailed down to a fixed position...
virtual ExplicitPlacement resolve() const
no need to resolve any further, as this ExplicitPlacement already is the result of a resolve()-call.
A refcounting Handle to an MObject of type MO, used to constrain or explicitly specify the location w...
declare the concrete types a BuilderTool may receive and treat.
Base class of all BuilderTools, used according to the visitor pattern: each Tool contains the concret...
void rememberWrapper(Placement< TAR, B > *ptr_toWrappedTarget)
void rememberWrapper(WRA< TAR > *ptr_toWrappedTarget)
Policy invoking an catch-all function for processing an unknown tool / target pair,...
virtual RET onUnknown(Buildable &target)=0
Core abstraction: completely resolved placement of an MObject Within the session model,...
variadic sequence of types
Definition typelist.hpp:102
Buildable::ReturnType apply(BuilderTool &tool, WRA &wrappedTargetObj)
to be picked up by ADL: redirect tool invocation for double dispatch.
Steam-Layer implementation namespace root.
Customised refcounting smart pointer.
Core abstraction: placement of a media object into session context.
A library implementation of the Visitor Pattern tailored specifically to Lumiera's needs within the S...
Wrapper to treat several flavours of smart-pointers uniformly.