FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
OnDemandCreator.hpp
1#ifndef __FIBER_FIELD_ONDEMAND_CREATOR_HPP
2#define __FIBER_FIELD_ONDEMAND_CREATOR_HPP
3
4#include "CreativeArray.hpp"
5#include "MemArrayProperties.hpp"
6
7#if defined(__GNUC__) && defined(_GLIBCXX_USE_NOEXCEPT)
8#define USE_NOEXCEPT _GLIBCXX_USE_NOEXCEPT
9#else
10#define USE_NOEXCEPT throw()
11#endif
12namespace Fiber
13{
14
62template <class Computer, Dims_t Rank = Computer::ResultArray_t::Dims,
63 typename result_value_type = typename Computer::ResultArray_t::value_type>
65{
66 typedef typename Computer::ResultArray_t ResultArray_t;
67 typedef typename Computer::Constructor_t Constructor_t;
68
69 Constructor_t MyConstructor;
71
72public:
73 enum Dims_t
74 {
76 RANK = Rank
77 };
78
81
84 {
85 ~Exception() throw()
86 {}
87
88 const char* what() const USE_NOEXCEPT override
89 {
90 return "Unspecified Fiber::OnDemandCreator Exception";
91 }
92 };
93
94
100
106 , MyConstructor(myConstructor)
107 {
108 addMetaInfo( RANK, getFiberType() );
109 }
110
111
112 Creature::ReasonForReleasal release() override
113 {
114 return releasePtr( MyData );
115 }
116
117 bool hasData() const override
118 {
119 if (MyData)
120 return true;
121 else
122 return false;
123 }
124
126 const std::type_info& getType() override
127 {
128 return typeid( value_type );
129 }
130
132 MemCore::CacheablePtr getCacheable() const override
133 {
134 return MyData;
135 }
136
138 RefPtr<MemBase> get() const override
139 {
140 return MyData;
141 }
142
144 RefPtr<MemBase> take() override
145 {
146 RefPtr<MemBase> result = MyData;
147 MyData = MemCore::NullPtr();
148 return result;
149 }
150
165 {
166 if (MyData)
167 return MyData;
168
169 Computer MyComputer( MyConstructor, self() );
170 MyData = MyComputer.result();
171
172 if (MyData)
173 {
174 MyData->setCreator( this->self() );
175 touch();
176 }
177
178 return MyData;
179 }
180
181};
182
183} // namespace Fiber
184
185#endif // __FIBER_FIELD_ONDEMAND_CREATOR_HPP
Base class for multidimensional arrays that employ deferred storage, i.e.
Definition CreativeArrayBase.hpp:75
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Allocating array types through registry of types.
Definition MemBase.hpp:315
A Creator object that allows to create data on demand, when they are used and accessed.
Definition OnDemandCreator.hpp:65
RefPtr< MemBase > produce() override
The data creation: Create an object of type Computer (the template argument), passing the constructor...
Definition OnDemandCreator.hpp:164
OnDemandCreator(const Constructor_t &myConstructor, const MemCore::RefPtr< MemCore::Cache > &theCache)
Construct an OnDemand Creator.
Definition OnDemandCreator.hpp:104
result_value_type value_type
The type of values provided by the associated data set.
Definition OnDemandCreator.hpp:80
static WeakPtr< FiberTypeBase > getFiberType()
The FiberType that is associated with this data set.
Definition OnDemandCreator.hpp:96
Dims_t
Definition OnDemandCreator.hpp:74
@ RANK
The dimensionality of the data set.
Definition OnDemandCreator.hpp:76
ReasonForReleasal releasePtr(RefPtr< RefType > &Data) const
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
std::nullptr_t NullPtr
Associated Exception class.
Definition OnDemandCreator.hpp:84