FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
FieldInputCreator.hpp
1#ifndef __FISH_BONE_FIELDINPUTCREATOR_HPP
2#define __FISH_BONE_FIELDINPUTCREATOR_HPP
3
4#include "FishGrid.hpp"
5
6#include <ocean/shrimp/VStringList.hpp>
7#include <ocean/plankton/VObject.hpp>
8#include <ocean/plankton/VPipeline.hpp>
9
10#include <bundle/FieldSelector.hpp>
11
12#include <meta/LIST.hpp>
13#include <meta/NativeTypeList.hpp>
14
15#include <any>
16
17namespace Wizt
18{
19 using namespace META;
20 using any = std::any;
21
27template <class FieldVObject, class OutputType>
34
35template <class FieldVObject>
40
41
42
48{
51
53 bool Yess;
55 string QualificationInfo;
56
59 : FS(fs)
60 , Yess(false)
61 {}
62
63 template <typename T>
64 struct exec
65 {
66 // return true if the traversal of the list
67 // should be stopped
68 static inline bool Break(TypeInspector&TI)
69 {
70#ifdef VERBOSE
71 printf(" TypeInspector<%s>: ", typeid(T).name() );
72 TI.FS.FieldTypes().speak(); puts("");
73#endif
74 if (TI.FS.requiresType( typeid(T) ) )
75 {
76#ifdef VERBOSE
77 printf(" ...... FIELD requires %s (%d fields available)\n", typeid(T).name(), TI.FS.NumberOfAvailableFields() );
78#endif
79 TI.QualificationInfo = "Field qualifies to be of type " + Typename( typeid(T) );
80 TI.Yess = true;
81 return true;
82 }
83#ifdef VERBOSE
84 printf("Field requirement %s is NOT available\n", typeid(T).name() );
85#endif
86 return false; // continue traversal
87 }
88 };
89};
90
91
92template <class TypeList>
94{
95static auto allowType(const Fiber::FieldSelector&FS)
96 {
99 return std::make_tuple(TI.Yess, TI.QualificationInfo);
100 }
101};
102
103
104template <>
106{
107static auto allowType(const Fiber::FieldSelector&FS)
108 {
109 return std::make_tuple(true, "");
110 }
111};
112
113
114
115
142template <class FieldVObject, class TypeList = LIST<META::NIL>,
143 class GridInspector = typename FieldVObject::GridInspector,
144 int NumberOfInputFields = FieldVObject::NumberOfInputFields,
145 class OutputType = void>
146struct FieldInputCreator : FieldInputCreatorBaseTrait<FieldVObject, OutputType>::Creator_t
147{
149
156 {
157// if (this->Arguments().length()<1)
158// this->Arguments() = TypeString();
159 }
160
169 {
170 if (this->Arguments().length()<1)
171 this->Arguments() = TypeString();
172 }
173
190 template <unsigned ID>
193 {
194 if (this->Arguments().length()<1)
195 this->Arguments() = TypeString();
196 }
197
198// allow to override verbosity domain in application code
199#ifndef FieldInputCreatorVerbose
200#define FieldInputCreatorVerbose(X) AppVerbose("FieldInput", X)
201#endif
202
209 {
210 if (!vobj)
211 {
212 FieldInputCreatorVerbose(20) << "FieldInputCreator(): NO INPUT FOUND!";
213 return {};
214 }
215
216 FieldInputCreatorVerbose(30) <<
217 "RefPtr<VAcceptInfo> " << this->Name() << "::accept(const RefPtr<VObject>&"<< vobj->Name()<<" ) const override";
218
219// Should iterate over all exported FieldSelectors, not only one
220// VAcceptInfoList_t FieldAcceptions = getAcceptInfoList( typeid(Fiber::FieldSelector) );
221
222// getting just one for now
223 RefPtr<VParameter> FieldParam = vobj->getImplementation( typeid(Fiber::FieldSelector) );
224// TODO: Make this a function...
225 if (!FieldParam)
226 {
227 FieldInputCreatorVerbose(30) << "FieldInputCreator(): NO INPUT FIELD FOUND at " << vobj->Name();
228 return {};
229 }
230
231 FieldInputCreatorVerbose(30) << "Getting Fieldselector for " << this->Name()
232 << " from " << vobj->Name()
233 << " found " << FieldParam->Name();
234
236 if (!FieldParam->getValue( FS, NullPtr(), "" ) )
237 {
238 FieldInputCreatorVerbose(30) << "FieldInputCreator(): Could not get fieldselector for " << vobj->Name();
239 return {};
240 }
241
242 // No bundle here
243 if (!FS.getBundle() )
244 {
245 FieldInputCreatorVerbose(30) << "FieldInputCreator(): No BUNDLE available at " << vobj->Name();
246
247 //
248 // Thus allow any field connection since the providing object
249 // could yet create a bundle with possibly fitting fields once
250 // it is requested later.
251 //
253
254 return ( VAIL & "Unitialized generic Field provider, "
255 "might be suitable to provide the requested type, we don't know yet.") * 0.5;
256/*
257 if (RefPtr<VAcceptInfo> VAI = VCreator<FieldVObject, AcceptList<Fiber::Field> >::accept(vobj) )
258 {
259 return ( VAI & "Unitialized generic Field provider, "
260 "might be suitable to provide the requested type, we don't know yet.") * 0.5;
261 }
262
263 return NullPtr();
264*/
265 }
266
267 //
268 // Fields are available on input, but not enough. FAIL.
269 //
270 if (FS.NumberOfAvailableFields()>0
271 &&
272 FS.NumberOfAvailableFields()<NumberOfInputFields)
273 {
274 FieldInputCreatorVerbose(30) <<
275 "FieldInputCreator(): Input object provides a number of available fields, "
276 "but FS.NumberOfAvailableFields() ("
277 <<FS.NumberOfAvailableFields()
278 <<") < NumberOfInputFields ("<<NumberOfInputFields<<")\n";
279
280 return {};
281 }
282
283 //
284 // Check the type of the grid on which the input field resides.
285 //
286 GridSelector&GS = FS;
287 if (!GS.hasProperty(GridInspector::InspectionProperty() ) )
288 {
289 FieldInputCreatorVerbose(30) << "The Grid as exported by " << vobj->Name() << " does not qualify as input.";
290
291 return {};
292 }
293
294 FieldInputCreatorVerbose(30) << "FieldInputCreator(): INSPECT FIELD AS EXPORTED BY "
295 << vobj->Name() <<" (" << FS.FieldTypes().size() << " types) "
296 << FS.FieldTypes().str();
297
298
299 //
300 // Investigate if the given Field Selector,
301 // as exported by a given object, provides the
302 // correct type as requested by the current creator.
303 //
306
308 if (!allowType)
309 {
310 FieldInputCreatorVerbose(30) << "NOPE, don't want this field type";
311 // no such match, return empty list.
312 return {};
313 }
314
316 FieldInputCreatorVerbose(30) << "YESSS, accepted this field type";
317
318 return VAIL & Info;
319 }
320
321
322
323
325 {
326 string theTypeString;
327
328 template <typename T>
329 struct exec
330 {
331 // return true if the traversal of the list
332 // should be stopped
333 static inline bool Break(MakeString&MS)
334 {
335 if (MS.theTypeString.length()<1)
336 MS.theTypeString += "|";
337
338 MS.theTypeString += Typename( typeid(T) );
339 return false;
340 }
341 };
342 };
343
344static string TypeString()
345 {
348 return MS.theTypeString;
349 }
350
351
352};
353
354
367template <class FieldVObject, class GridInspector = typename FieldVObject::GridInspector, class OutputType = void>
398
399
400
401
402
403
408template <class FunctionObject>
409struct VSource<FunctionObject, Fiber::Field> : Ref<VInputCreator<Fiber::Field, VCreator<FunctionObject> > >
410{
412
413 VSource(const string&name, int p = ObjectQuality::EXPERIMENTAL, const RefPtr<VCreationPreferences>&Prep = NullPtr() )
414 : Base_t(name, p, Prep)
415 {}
416
417 template <unsigned ID>
419 : Base_t(VP, p, Prep)
420 {}
421};
422
423
428template <class FunctionObject, class OutputType>
429struct VFilter<Fiber::Field,FunctionObject, OutputType> : Ref<TypedFieldInputCreator<FunctionObject, typename FunctionObject::GridInspector, OutputType> >
430{
432
433 VFilter(const string&name, int p = ObjectQuality::EXPERIMENTAL, const RefPtr<VCreationPreferences>&Prep = NullPtr() )
434 : VFilterFieldBase_t(name, p, Prep)
435 {}
436
437 template <unsigned ID>
440 {}
441};
442
443
448template <class FunctionObject>
449struct VSink<Fiber::Field,FunctionObject> : Ref<TypedFieldInputCreator<FunctionObject> >
450{
451 VSink(const string&name, int p = ObjectQuality::EXPERIMENTAL, const RefPtr<VCreationPreferences>&Prep = NullPtr() )
453 {}
454
455 template <unsigned ID>
458 {}
459};
460
461
462
467template <class FunctionObject>
468struct VPipeline<void, FunctionObject, Fiber::Field> : VSource<FunctionObject, Fiber::Field>
469{
472 {}
473
474 template <unsigned ID>
477 {}
478};
479
480
481
482
487template <class FunctionObject, class OutputType>
488struct VPipeline<Fiber::Field, FunctionObject, OutputType> : VFilter<Fiber::Field,FunctionObject,OutputType>
489{
492 {}
493
494 template <unsigned ID>
497 {}
498};
499
504template <class FunctionObject>
505struct VPipeline<Fiber::Field, FunctionObject, void> : VSink<Fiber::Field,FunctionObject>
506{
509 {}
510
511 template <unsigned ID>
514 {}
515};
516
517
518} // namespace Wizt
519
520#endif /* __FISH_BONE_FIELDINPUTCREATOR_HPP */
constexpr tuple< typename __decay_and_strip< _Elements >::__type... > make_tuple(_Elements &&... __args)
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
index_t length
The length (number of elements) of the data array.
Definition HyperslabParameters.hpp:37
An internal class that stores a couple of textual names.
Definition FieldSelector.hpp:18
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
Context information to select a grid from within a bundle.
Definition GridSelector.hpp:26
bool hasProperty(const BundleProperty &theProperty) const
Check this GridSelector for a certain property.
Definition GridSelector.hpp:251
const T & getValue(index_t i) const
Get the value, readonly.
Definition vector/Iterator.hpp:718
const std::string & Name() const
MEMCORE_API std::string Typename(const std::type_info &t)
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
std::nullptr_t NullPtr
note: cannot derive from FloatingSkeletonRenderer as long as independent base class TriangleRenderer ...
STL namespace.
Definition fs/init.hpp:20
Generic template namespace class for results of find() functions throughout the Bundle.
Definition Info.hpp:17
Template meta-program to compute the right base class for FieldInputCreators (objects that take Field...
Definition FieldInputCreator.hpp:29
Definition FieldInputCreator.hpp:330
Definition FieldInputCreator.hpp:325
Creator class for objects that require fields as input.
Definition FieldInputCreator.hpp:147
FieldInputCreator(const string &name, int quality, const RefPtr< VCreationPreferences > &Prep=NullPtr())
Constructor.
Definition FieldInputCreator.hpp:154
FieldInputCreator(const VCreatorProperty< ID > &CreatorProperties, int quality, const RefPtr< VCreationPreferences > &Prep=NullPtr())
Constructor.
Definition FieldInputCreator.hpp:191
VAcceptInfoList_t accept(const RefPtr< VObject > &vobj) const override
Object acceptance function.
Definition FieldInputCreator.hpp:208
FieldInputCreator(const VCreatorProperties &CreatorProperties, int quality, const RefPtr< VCreationPreferences > &Prep=NullPtr())
Constructor.
Definition FieldInputCreator.hpp:167
Definition FieldInputCreator.hpp:94
Definition FieldInputCreator.hpp:65
Helper class for FieldInputCreator .
Definition FieldInputCreator.hpp:48
A FieldInputCreator that retrieves the types of possible input fields from a TypeList type as exporte...
Definition FieldInputCreator.hpp:369
TypedFieldInputCreator(const VCreatorProperty< ID > &CreatorProperties, int quality, const RefPtr< VCreationPreferences > &Prep=NullPtr())
Constructor.
Definition FieldInputCreator.hpp:394
TypedFieldInputCreator(const VCreatorProperties &CreatorProperties, int quality, const RefPtr< VCreationPreferences > &Prep=NullPtr())
Constructor, give a creator properties here, and a object quality.
Definition FieldInputCreator.hpp:383
TypedFieldInputCreator(const string &name, int quality, const RefPtr< VCreationPreferences > &Prep=NullPtr())
Constructor, give a name here, and a object quality.
Definition FieldInputCreator.hpp:376