FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Field.hpp
1#ifndef __FIBER_FIELD_HPP
2#define __FIBER_FIELD_HPP "Created 27.02.2001 21:42:27 by werner"
3
4#include <memcore/defines.hpp>
5
6#include "FieldAPI.h"
7#include <memcore/RefPtr.hpp>
8#include <memcore/RefMap.hpp>
9#include <memcore/Creator.hpp>
10#include <memcore/Interface.hpp>
11#include <memcore/Ageable.hpp>
12#include <memcore/Attributes.hpp>
13
14#include <string>
15#include <memcore/shared_mutex.hpp>
16
17#if __has_include(<flat_map>)
18#include <flat_map>
19#endif
20
21#include "MemArray.hpp"
22#include "CreativeArrayBase.hpp"
23
24#include "FragmentSelector.hpp"
25#include "FragmentID.hpp"
26#include "MemArrayProperties.hpp"
27#include "FragmentIDCollection.hpp"
28#include "Iterator.hpp"
29#include "FunctionalCreator.hpp"
30
31namespace Fiber
32{
38 using std::string;
40
41
42template <typename Key, typename Value>
44{
47
48public:
50 using iterator = typename Container::iterator;
51 using const_iterator = typename Container::const_iterator;
52 using value_type = Pair;
53
54 // Inline comparison function
55static inline bool compare(const Pair& a, const Pair& b)
56 {
57 return a.first < b.first;
58 }
59
60 // Insert a key-value pair
62 insert(const Pair& pair)
63 {
64 // Perform a binary search to find the appropriate position
65 auto it = std::lower_bound(data.begin(), data.end(), pair, compare);
66 // Check if the key already exists
67 if (it == data.end() || it->first != pair.first)
68 {
69 // update the iterator because insertion will invalidate all iterators
70 it = data.insert(it, pair); // Insert the new pair
71 return { it, true }; // Indicate successful insertion
72 }
73
74 // Key exists; update the value
75 it->second = pair.second;
76 return { it, false }; // Indicate that the key was already present
77 }
78
79 // Erase a key-value pair by key
80 bool erase(const Key& key)
81 {
82 auto it = std::lower_bound(data.begin(), data.end(), Pair{key, Value{}}, compare);
83 if (it != data.end() && it->first == key)
84 {
85 data.erase(it); // Remove the element
86 return true; // Indicate successful removal
87 }
88 return false; // Indicate key not found
89 }
90
91 // Find a value by key
92 const_iterator find(const Key& key) const
93 {
94 auto it = std::lower_bound(data.begin(), data.end(), Pair{key, Value{}}, compare);
95 if (it != data.end() && it->first == key)
96 return it;
97
98 return data.end();
99 }
100
101 // Find a value by key
102 iterator find(const Key& key)
103 {
104 auto it = std::lower_bound(data.begin(), data.end(), Pair{key, Value{}}, compare);
105 if (it != data.end() && it->first == key)
106 return it;
107
108 return data.end();
109 }
110
111 // Iterator support for ranged-for loops
112 iterator begin() { return data.begin(); }
113 iterator end() { return data.end(); }
114 const_iterator begin() const { return data.begin(); }
115 const_iterator end() const { return data.end(); }
116 const_iterator cbegin() const { return data.cbegin(); }
117 const_iterator cend() const { return data.cend(); }
118
119 void reserve(std::size_t size)
120 {
121 data.reserve(size);
122 }
123
124 auto size() const
125 {
126 return data.size();
127 }
128
129 void clear()
130 {
131 data.clear();
132 }
133
134 bool empty() const
135 {
136 return data.empty();
137 }
138};
139
140
141
142
173{
174public:
176 virtual ~FragmentIndexIterator();
177
179 virtual bool apply(int FragmentIndex, const RefPtr<CreativeArrayBase>&) = 0;
180};
181
239class FIELD_API Field : public OwnerOf<CreativeArrayBase, CreativeArrayBaseContainerBase>
240 , public Ownable<Field>
241 , public Intercube
243 , public MemCore::Ageable
244 , public SaveableAttributes
245{
246 RefPtr<FragmentIDCollection> myFragmentIDCollection;
247
248 bool processOwnership(MemCore::Intercube&Output,
249 const MemCore::Intercube&Input) const override
250 {
252 }
253
254public:
255
256#if __has_include(<flat_map>)
257 using fragment_map_t = std::flat_map<FragmentIndex_t, MemCore::RefPtr<CreativeArrayBase> >;
259
260static constexpr bool use_std__flat_map_for_fragments = true;
261#else
262// using fragments_t = MemCore::RefMap<FragmentIndex_t, CreativeArrayBase>;
263
265
266static constexpr bool use_std__flat_map_for_fragments = false;
267#endif
268
270
271protected:
272
273 mutable MemCore::shared_mutex fragment_mutex;
274 fragments_t fragments;
275
276 const RefPtr<CreativeArrayBase>&setCreatorViaFragmentIndex(FragmentIndex_t FI, const RefPtr<CreativeArrayBase>&CAB);
277
278public:
279 void reserve_fragments(size_t N);
280
281 void extremeUnction() override;
282
284
286
287static const CAB_t&CreativeArrayNullPtr();
288
289
293 void clear();
294
296 FragmentIndex_t getNumericalID(const RefPtr<FragmentID>&fid);
297
299 FragmentIndex_t findNumericalID(const RefPtr<FragmentID>&fid) const;
300
302 FragmentIndex_t findNumericalIDByName(const string&FragmentName) const;
303
307 RefPtr<FragmentID>&makeFragmentID( const string&fragmentname );
308
310 {
311 return makeFragmentID( fragmentname );
312 }
313
314 RefPtr<FragmentIDCollection> getFragmentIDCollection() const override;
315
316 DynamicSize getFragmentLayout() const
317 {
318 if (RefPtr<FragmentIDCollection> FIC = getFragmentIDCollection() )
319 return FIC->getFragmentLayout();
320
321 return {};
322 }
323
327 const FragmentIDCollection::FragmentIDs_t&getFragmentIDs() const;
328
333 bool validate(FragmentIndex_t FragmentNumber) const;
334
335
336#ifdef __NO_FIBER_FIELD_DEFAULT_CONSTRUCTOR
337private:
338#endif
339
341 Field();
342
343public:
344
350
352
353 explicit Field(const WeakPtr<Field>&SimilarField);
354
356
359
362
365
368
371
374
375
379
383 template <Dims_t DIMS>
384 Field(const MultiIndex<DIMS>&NumberOfFragments, const string&FragmentNamePrefix)
385 : myFragmentIDCollection( new FragmentIDCollection( NumberOfFragments, FragmentNamePrefix) )
386 {
387 reserve_fragments( NumberOfFragments.size() );
388 }
389
393 template <Dims_t DIMS>
394 bool setFragmentLayout(const MultiIndex<DIMS>&NumberOfFragments, const string&FragmentNamePrefix)
395 {
396 reserve_fragments( NumberOfFragments.size() );
397
398 if (!myFragmentIDCollection)
399 {
400 myFragmentIDCollection = new FragmentIDCollection( NumberOfFragments, FragmentNamePrefix);
401 return true;
402 }
403
404 return myFragmentIDCollection -> setFragmentLayout( NumberOfFragments, FragmentNamePrefix);
405 }
406
410 RefPtr<MemBase> newFragmentationArray() const;
411
415 template <class T, Dims_t N>
423
427 template <class T, Dims_t N>
435
439 template <class T, Dims_t N>
447
452 template <class T, Dims_t N>
456
461 template <class T, Dims_t N>
465
466 void own(CreativeArrayBase&CAB)
467 {
468 CAB.addOwner( this, *this );
469 Ageable::update(CAB);
470 }
471
472 void own(const RefPtr<CreativeArrayBase>&CAB)
473 {
474 if (CAB) own(*CAB);
475 }
476
483 setDiscardableData(const RefPtr<MemBase>&Mb,
485 const RefPtr<FragmentID>& = nullptr );
486
487
491 bool hasData(const RefPtr<FragmentID>&FID = nullptr ) const
492 {
493 RefPtr<CreativeArrayBase> CA = getCreator(FID);
494 if (!CA)
495 return false;
496
497 return CA->hasData();
498 }
499
500
510 const CAB_t&setPersistentData( const RefPtr<MemBase>&Mb, const RefPtr<FragmentID>& = nullptr ,
512 const string&ProvenanceInfo = {});
513
514 const CAB_t&setPersistentData( const RefPtr<MemBase>&Mb, const RefPtr<FragmentID>&fID,
515 const string&ProvenanceInfo)
516 {
517 return setPersistentData(Mb, fID, MemCore::Cache::MemCache(), ProvenanceInfo);
518 }
519
520 const CAB_t&setPersistentDataByName( const RefPtr<MemBase>&Mb, const string&FragmentName,
522 {
523 RefPtr<FragmentID> Fid = makeFragmentID( FragmentName );
524 return setPersistentData( Mb, Fid, Cache );
525 }
526
532 template <class T, Dims_t N>
535 const RefPtr<FragmentID>&FragID = nullptr,
537 {
538 return setPersistentData( new MemArray<N,T>(Mb, Dimensions), FragID, Cache);
539 }
540
546 template <class T, Dims_t N>
548 const RefPtr<FragmentID>&FragID = nullptr,
550 {
551 return setPersistentData( new MemArray<N,T>(Mb, Dimensions), FragID, Cache);
552 }
553
554
567 template <class T>
569 const RefPtr<FragmentID>&FragID = nullptr,
571 {
572 if (!data)
573 return CreativeArrayNullPtr();
574
575 return setPersistentData( data, MIndex(data->size() ), FragID, Cache);
576 }
577
578protected:
580 ~Field();
581
582public:
591 RefPtr<MemArrayProperties> getProperties() const;
592
602 const type_info&getFieldStorageType() const;
603
609 const type_info&getElementType() const;
610
616 MemCore::WeakPtr<FiberTypeBase> getElementFiberType() const;
617
618 [[deprecated("Old version, use getElementFiberType() instead.")]]
619 MemCore::WeakPtr<FiberTypeBase> getFiberType() const
620 {
621 return getElementFiberType();
622 }
623
631 int getMemoryUsage(memsize_t&UsedMemory, memsize_t&WantedMemory) const;
632
637 bool isType(const TypeList_t&TL) const
638 {
639 return containsType(TL, getElementType() );
640 }
641
642 FiberTypeIndex getFiberTypeIndex() const
643 {
644 if (RefPtr<FiberTypeBase> FTB = getElementFiberType())
645 return FTB->getFiberTypeIndex();
646
647 return {};
648 }
649
663 {
664 if (RefPtr<MemArrayProperties> MP = getProperties() )
665 {
666 TypeList.insert( MP->getFiberType() );
667 return true;
668 }
669 return false;
670 }
671
680 const RefPtr<CreativeArrayBase>&setCreator(const RefPtr<CreativeArrayBase>&FFC, const RefPtr<FragmentID>& = nullptr );
681
682 const RefPtr<CreativeArrayBase>&setCreatorByName(const RefPtr<CreativeArrayBase>&FFC, const string&FragmentName)
683 {
684 RefPtr<FragmentID>&Fid = makeFragmentID( FragmentName );
685
686 return setCreator( FFC, Fid );
687 }
688
694 {
695 if (fid)
696 {
697 RefPtr<FragmentID>&Fid = makeFragmentID( fid->Name() );
698 return setCreator( CAB, Fid );
699 }
700 return setCreator(CAB);
701 }
702
703
719 FunctionalCreator&setLambda(const FunctionalCreator::Functor&F, const RefPtr<FragmentID>&fid=nullptr )
720 {
722 setCreator( FC, fid);
723 return *FC;
724 }
725
726 FunctionalCreator&setLambda(const RefPtr<FragmentID>&fid, const FunctionalCreator::Functor&F)
727 {
729 setCreator( FC, fid);
730 return *FC;
731 }
732
733 FunctionalCreator&setCompatibleLambda(const FunctionalCreator::Functor&F, const RefPtr<FragmentID>&fid=nullptr )
734 {
735 RefPtr<FunctionalCreator> FC = new FunctionalCreator(F);
736 setCompatibleCreator( FC, fid);
737 return *FC;
738 }
739
740 const RefPtr<CreativeArrayBase>&setFunctionalCreator(const FunctionalCreator::Functor&F, const RefPtr<FragmentID>&fid=nullptr )
741 {
742 RefPtr<FunctionalCreator> FC = newFunctionalCreator(F);
743 return setCreator( FC, fid);
744 }
745
746
750 template <class Functor>
751// FunctionalCreator<Functor>&setFunctor(const Functor&F, const RefPtr<FragmentID>&fid= nullptr )
753 {
754 return setLambda( F, fid);
755 }
756
760 template <class Functor>
761// FunctionalCreator<Functor>&setFunctor(const RefPtr<FragmentID>&fid, const Functor&F)
763 {
764 return setLambda( F, fid);
765 }
766
767
768
770 size_t nFragments() const
771 {
772 return fragments.size();
773 }
774
776 size_t NumberOfFragments() const
777 {
778 return fragments.size();
779 }
780
781 bool isUnfragmented() const;
782
783 bool isFragmented() const
784 {
785 return !isUnfragmented();
786 }
787
788 RefPtr<FragmentID> getFragmentID(const string&FragmentName) const;
789
790 RefPtr<FragmentID> operator()(const string&FragmentName) const
791 {
792 return getFragmentID( FragmentName );
793 }
794
800 RefPtr<CreativeArrayBase> getCreator(const RefPtr<FragmentID>& = nullptr ) const;
801
802
803 RefPtr<CreativeArrayBase> operator()(const RefPtr<FragmentID>&FID = nullptr ) const
804 {
805 return getCreator( FID );
806 }
807
812 RefPtr<CreativeArrayBase> getCreatorByName(const string&FragmentName) const;
813
815
816 NamedFragment getCreatorByNameF(const string&FragmentName) const;
817
818 RefPtr<CreativeArrayBase> getCreatorByNumericalID(FragmentIndex_t NumericalID) const;
819 RefPtr<CreativeArrayBase>&getCreatorReferenceViaFragmentIndex(FragmentIndex_t NumericalID);
820
821 [[deprecated("Use function getCreatorNumericalID() instead")]]
822 RefPtr<CreativeArrayBase> getCreator(FragmentIndex_t NumericalID) const
823 {
824 return getCreatorByNumericalID(NumericalID);
825 }
826
832 {
833 if (!F) return getCreator();
834 RefPtr<CreativeArrayBase> CAB = getCreator(F);
835 if (CAB) return CAB;
836 return getCreatorByName( F->Name() );
837 }
838
843 NamedFragment getCompatibleCreatorF(const RefPtr<FragmentID>&F = nullptr ) const;
844
851 RefPtr<MemBase> getData(const RefPtr<FragmentID>&FID = nullptr ) const;
852
853
854
866 RefPtr<MemBase> getDataByNumericalID(FragmentIndex_t NumericalID) const;
867
868 DEPRECATED("Use function getDataByNumericalID() instead",
869 RefPtr<MemBase> getData(FragmentIndex_t NumericalID) const)
870 {
871 return getDataByNumericalID(NumericalID);
872 }
873
879 [[deprecated("Avoid using this function because of its random results; use with care.")]]
880 RefPtr<MemBase> getFirstData() const;
881
887 [[deprecated("Avoid using this function because of its random results; use with care.")]]
888 RefPtr<CreativeArrayBase> getFirstCreator() const;
889
898 [[deprecated("Avoid using this function because of its random results; use with care.")]]
899 RefPtr<FragmentID> getFirstFragmentID() const;
900
906 {
907 if (RefPtr<MemBase> Mb = getData( FID ) )
908 return Mb->getChunk();
909
910 return nullptr;
911 }
912
918 {
919 RefPtr<CreativeArrayBase> CA = getCompatibleCreator(F);
920 if (!CA)
921 return nullptr;
922
923 return CA->create();
924 }
925
927
928 [[deprecated("Use iterate() via std::function instead")]]
929 unsigned iterate(FragmentIterator&, const MemCore::WeakPtr<FragmentSelector>&FS = nullptr ) const;
930
931
932 template <class T>
933 [[deprecated("Use iterate() via std::function instead")]]
934 unsigned Iterate(const T&t, const MemCore::WeakPtr<FragmentSelector>&FS = nullptr ) const
935 {
936 FragmentFunctor<T> myFunctor(t);
937 return iterate(myFunctor, FS);
938 }
939
940 template <class T>
941 [[deprecated("Use iterate() via std::function instead")]]
942 unsigned iterate_fragments(const T&t, const MemCore::WeakPtr<FragmentSelector>&FS = nullptr ) const
943 {
944 FragmentFunctor<T> myFunctor(t);
945 return iterate(myFunctor, FS);
946 }
947
952
953 Ageable getMostRecentCreatorAge() const;
954 Ageable getMostRecentAttributeAge() const;
955
956 bool hasFragmentsNewerThan(const Ageable&A) const;
957
958
971 unsigned iterate(const FragmentIterator_t&FI, bool parallel = false, bool copy_map_internally = false ) const;
972
977 unsigned iterate(bool parallel, const FragmentIterator_t&FI, bool copy_map_internally = false ) const
978 {
979 return iterate(FI, parallel, copy_map_internally);
980 }
981
986 unsigned iterate_parallel(const FragmentIterator_t&FI, bool copy_map_internally = false) const
987 {
988 return iterate(FI, true, copy_map_internally);
989 }
990
991
995 unsigned iterate(FragmentIndexIterator&FFI, const WeakPtr<FragmentSelector>&FS = nullptr, bool copy_map_internally = false ) const;
996
1002 Dims_t Dims() const;
1003
1011 RefPtr<SizeInterface> getSize() const;
1012
1013
1014 bool isCompatible(const Field&F);
1015
1020 void Speak(int indent=0, int maxindent=-1) const;
1021
1022 string xml() const;
1023
1024
1027 enum class CreationFailAlternative
1028 {
1029 Fail,
1030 Persistent,
1031 Discardable
1032 };
1033
1034
1039 const RefPtr<FragmentID>& = nullptr,
1040 CreationFailAlternative = CreationFailAlternative::Persistent,
1042
1044 const string&FragmentName,
1045 CreationFailAlternative = CreationFailAlternative::Persistent,
1047
1059 template <Dims_t N, class T>
1062 const RefPtr<FragmentID>&fid = nullptr,
1063 Field::CreationFailAlternative FailMode = Field::CreationFailAlternative::Persistent,
1065 {
1066 RefPtr<MemArray<N,T>> myMemArray = new MemArray<N,T>( Size);
1067
1068 return { myMemArray, createCreator(myMemArray, fid, FailMode, theCache) };
1069 }
1070
1071
1083 template <Dims_t N, class T>
1086 const string&fragmentname,
1087 Field::CreationFailAlternative FailMode = Field::CreationFailAlternative::Persistent,
1089 {
1090 RefPtr<MemArray<N,T>> myMemArray = new MemArray<N,T>( Size);
1091
1092 return { myMemArray, createCreator(myMemArray, fragmentname, FailMode, theCache) };
1093 }
1094
1095
1099 template <Dims_t Dims>
1100 MultiIndex<Dims>&setFragmentOffset(const string&FragmentName, const MultiIndex<Dims>&Offset)
1101 {
1102 RefPtr<FragmentID>&FID = makeFragmentID( FragmentName );
1103
1104 return ::Fiber::setFragmentOffset( *FID, Offset);
1105 }
1106
1107static const RefPtr<Field>&NullPtrField();
1108
1109};
1110
1111
1112using FieldFragment = std::pair<RefPtr<Field>, RefPtr<FragmentID>>;
1113
1114inline FieldFragment operator<<(const RefPtr<Field>&F, const RefPtr<FragmentID>&Fid)
1115{
1116 return { F, Fid };
1117}
1118
1119
1120inline FieldFragment operator<<(const RefPtr<Field>&F, const string&FragmentName)
1121{
1122 if (!F)
1123 return {nullptr, nullptr};
1124
1125 return { F, F->makeFragmentID(FragmentName) };
1126}
1127
1138{
1139 if ( FF.first )
1140 return FF.first->setPersistentData(Mb, FF.second );
1141
1142 return nullptr;
1143}
1144
1155{
1156 if (FF.first)
1157 return Result = FF.first->getCreator( FF.second );
1158
1159 Result = nullptr;
1160 return nullptr;
1161}
1162
1163inline RefPtr<CreativeArrayBase> operator<<(const FieldFragment&&FF, const Field::CAB_t&theCreator)
1164{
1165 if (FF.first)
1166 return FF.first->setCreator(theCreator, FF.second );
1167
1168 return nullptr;
1169}
1170
1171
1172
1173using FieldFragmentRef = std::pair<Field&, RefPtr<FragmentID>>;
1174
1175inline FieldFragmentRef operator<<(Field&F, const RefPtr<FragmentID>&Fid)
1176{
1177 return { F, Fid };
1178}
1179
1180inline FieldFragmentRef operator<<(Field&F, const string&FragmentName)
1181{
1182 return { F, F.makeFragmentID(FragmentName) };
1183}
1184
1195{
1196 return FF.first.setPersistentData(Mb, FF.second );
1197}
1198
1208inline RefPtr<CreativeArrayBase> operator<<(const FieldFragmentRef&&FF, const Field::CAB_t&theCreator)
1209{
1210 return FF.first.setCreator(theCreator, FF.second );
1211}
1212
1222{
1223 return Result = FF.first.getCreator( FF.second );
1224}
1225
1226
1227
1228
1229
1230template <>
1232{
1233};
1234
1235
1236template <class Functor>
1238 const Functor&Lambda)
1239{
1240 return FieldFragment.first.setFunctor( Lambda, FieldFragment.second);
1241}
1242
1243template <class Functor>
1244inline FunctionalCreator&operator+=(const Field&F, const Functor&Lambda)
1245{
1246 return F.setFunctor( Lambda );
1247}
1248
1249
1250inline RefPtr<CreativeArrayBase> operator<<(const FieldFragment&FF,
1251 const FunctionalCreator::Functor&F)
1252{
1253 if (FF.first)
1254 return FF.first->setFunctionalCreator(F, FF.second );
1255
1256 return nullptr;
1257}
1258
1259inline RefPtr<CreativeArrayBase> operator<<(const FieldFragmentRef&FF,
1260 const FunctionalCreator::Functor&F)
1261{
1262 return FF.first.setFunctionalCreator(F, FF.second );
1263}
1264
1265
1266template <class T>
1267inline int operator<<=(const Field&F, const T&t)
1268{
1269 return F.iterate_fragments(t);
1270}
1271
1272template <class T>
1273inline int operator<<=(const RefPtr<Field>&F, const T&t)
1274{
1275 if (!F) return 0;
1276 return F->iterate_fragments(t);
1277}
1278
1279
1280} /* namespace Fiber */
1281
1282#endif /* __FIBER_FIELD_HPP */
constexpr complex< _Tp > & operator+=(const complex< _Up > &)
gslice_array< _Tp > operator[](const gslice &__s)
valarray< size_t > size() const
constexpr _InputIterator find(_InputIterator __first, _InputIterator __last, const _Tp &__val)
constexpr _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val)
basic_string< char > string
constexpr auto cend(const _Container &__cont) noexcept(noexcept(std::end(__cont))) -> decltype(std::end(__cont))
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
constexpr auto begin(_Container &__cont) -> decltype(__cont.begin())
constexpr auto end(_Container &__cont) -> decltype(__cont.end())
constexpr auto cbegin(const _Container &__cont) noexcept(noexcept(std::begin(__cont))) -> decltype(std::begin(__cont))
void insert(_InputIterator __first, _InputIterator __last)
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
A class describing an n-dimensional space at runtime.
Definition field/DynamicSize.hpp:29
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
bool isType(const TypeList_t &TL) const
Check if the type of this field is contained in the given type list.
Definition Field.hpp:637
Field(const MultiIndex< DIMS > &NumberOfFragments, const string &FragmentNamePrefix)
Create a field with a multi-dimensional regular layout for the fragments.
Definition Field.hpp:384
bool addFiberType(TypeList_t &TypeList) const
Add the type used by this field to the given TypeList.
Definition Field.hpp:662
Field(const MemCore::MemVector< T > &Data, const MultiIndex< N > &Size, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
Construct an unfragmented field from a MemVector and a MultiIndex.
Definition Field.hpp:453
MultiIndex< Dims > & setFragmentOffset(const string &FragmentName, const MultiIndex< Dims > &Offset)
Set a fragment's index offset.
Definition Field.hpp:1100
const CAB_t & setPersistentData1D(const MemCore::RefPtr< Chunk< T > > &data, const RefPtr< FragmentID > &FragID=nullptr, const RefPtr< MemCore::Cache > &Cache=MemCore::Cache::MemCache())
A convenience function to set a field's data from a Chunk of data, interpreting them as one-dimension...
Definition Field.hpp:568
FunctionalCreator & setLambda(const FunctionalCreator::Functor &F, const RefPtr< FragmentID > &fid=nullptr)
Definition Field.hpp:719
unsigned iterate_parallel(const FragmentIterator_t &FI, bool copy_map_internally=false) const
Iterate over all fragments in parallel.
Definition Field.hpp:986
size_t nFragments() const
The number of fragments in this field.
Definition Field.hpp:770
RefPtr< CreativeArrayBase > operator<<(const FieldFragmentRef &FF, const RefPtr< MemBase > &Mb)
Set a data set to a Field fragment:
Definition Field.hpp:1194
RefPtr< CreativeArrayBase > getCompatibleCreator(const RefPtr< FragmentID > &F=nullptr) const
Get a creator from a fragment ID that is NAMED similar to one fragment here.
Definition Field.hpp:831
bool hasData(const RefPtr< FragmentID > &FID=nullptr) const
Check if there are data on this field fragment.
Definition Field.hpp:491
unsigned iterate(bool parallel, const FragmentIterator_t &FI, bool copy_map_internally=false) const
Same as iterate(const FragmentIterator_t&, bool), just other order of arguments for convenience.
Definition Field.hpp:977
size_t NumberOfFragments() const
The number of fragments in this field.
Definition Field.hpp:776
Field(const MemCore::RefPtr< MemArray< N, T > > &MemRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
Convenience function initializing from a RefPtr<> to some MemArray.
Definition Field.hpp:428
Field(const MemCore::RefPtr< MemCore::TypedChunk< T > > &Data, const MultiIndex< N > &Size, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
Construct an unfragmented field from a Chunk of data and multidimensional index.
Definition Field.hpp:462
RefPtr< CreativeArrayBase > operator>>(const FieldFragmentRef &FF, Field::CAB_t &Result)
Get a creator:
Definition Field.hpp:1221
std::pair< RefPtr< MemArray< N, T > >, RefPtr< CreativeArrayBase > > createData(const MultiIndex< N > &Size, const RefPtr< FragmentID > &fid=nullptr, Field::CreationFailAlternative FailMode=Field::CreationFailAlternative::Persistent, const WeakPtr< MemCore::Cache > &theCache=MemCore::Cache::MemCache())
Create a mem array and insert it as a fragment to the Field.
Definition Field.hpp:1061
std::function< bool(const RefPtr< FragmentID > &, const RefPtr< CreativeArrayBase > &)> FragmentIterator_t
Callback type for functions iterating over Field fragments.
Definition Field.hpp:951
const CAB_t & setPersistentData(Chunk< T > *Mb, const MultiIndex< N > &Dimensions, const RefPtr< FragmentID > &FragID=nullptr, const RefPtr< MemCore::Cache > &Cache=MemCore::Cache::MemCache())
A convenience function to set a field's data from a Chunk of data.
Definition Field.hpp:547
RefPtr< CreativeArrayBase > operator<<(const FieldFragment &FF, const RefPtr< MemBase > &Mb)
Set a data set to a Field fragment:
Definition Field.hpp:1137
const CAB_t & setPersistentData(const MemCore::RefPtr< Chunk< T > > &Mb, const MultiIndex< N > &Dimensions, const RefPtr< FragmentID > &FragID=nullptr, const RefPtr< MemCore::Cache > &Cache=MemCore::Cache::MemCache())
A convenience function to set a field's data from a Chunk of data.
Definition Field.hpp:533
bool setFragmentLayout(const MultiIndex< DIMS > &NumberOfFragments, const string &FragmentNamePrefix)
Add a multi-dimensional regular layout for the fragments if it had no layout yet.
Definition Field.hpp:394
FunctionalCreator & setFunctor(const Functor &F, const RefPtr< FragmentID > &fid=nullptr)
Alias for setLambda().
Definition Field.hpp:752
RefPtr< MemBase > getCompatibleData(const RefPtr< FragmentID > &F=nullptr) const
Get data from a fragment ID that is NAMED similar to one fragment here.
Definition Field.hpp:917
RefPtr< CreativeArrayBase > operator>>(const FieldFragment &FF, Field::CAB_t &Result)
Set a data creator to a Field fragment:
Definition Field.hpp:1154
const RefPtr< CreativeArrayBase > & setCompatibleCreator(const RefPtr< CreativeArrayBase > &CAB, const RefPtr< FragmentID > &fid=nullptr)
Set the creator for a fragment ID on a different Skeleton such that the fragment IDs are different,...
Definition Field.hpp:693
Field(const MemCore::WeakPtr< MemArray< N, T > > &MemRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
Convenience function initializing from a RefPtr<> to some MemArray.
Definition Field.hpp:440
std::pair< RefPtr< MemArray< N, T > >, RefPtr< CreativeArrayBase > > createData(const MultiIndex< N > &Size, const string &fragmentname, Field::CreationFailAlternative FailMode=Field::CreationFailAlternative::Persistent, const WeakPtr< MemCore::Cache > &theCache=MemCore::Cache::MemCache())
Create a mem array and insert it as a fragment to the Field under the given fragmentname:
Definition Field.hpp:1085
RefPtr< MemCore::ChunkBase > getChunk(const RefPtr< FragmentID > &FID=nullptr) const
Return the stored memory chunk associated with this array.
Definition Field.hpp:905
FunctionalCreator & setFunctor(const RefPtr< FragmentID > &fid, const Functor &F)
Alias for setLambda().
Definition Field.hpp:762
Field(const MemCore::Ref< MemArray< N, T > > &MemRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
Convenience function initializing from a Ref<> to some MemArray.
Definition Field.hpp:416
Definition Field.hpp:44
Convenience base class.
Definition FragmentIDCollection.hpp:153
A collection of fragment identifiers with bijective mapping to an integer fragment number.
Definition FragmentIDCollection.hpp:19
Identification information about a field's fragment.
Definition FragmentID.hpp:42
Definition Field.hpp:173
virtual bool apply(int FragmentIndex, const RefPtr< CreativeArrayBase > &)=0
Iteration callback function.
Base class for iterators over the fragments of a field.
Definition FragmentID.hpp:249
Definition FunctionalCreator.hpp:52
Implementation of an Iterator to a sequence of elements, which might be contiguous or a projection of...
Definition vector/Iterator.hpp:525
Class for N-dimensional MultiArrays with MemCore memory management.
Definition MemArray.hpp:34
Domain-specific class of objects that can be owned.
Definition Ownable.hpp:81
void addOwner(const Container &theOwner, const MemCore::Ageable &theNewAge)
Add some owner and broadcast a new age to all Ownerrs.
Definition Ownable.hpp:163
Attributes with an age that allows to keep track when the attributes had been saved last.
Definition CreativeArrayBase.hpp:32
static RefPtr< Cache, CacheBase > & MemCache()
MemSizeConfig< sizeof(void *)>::memsize_t memsize_t
Anemone_Context_t operator<<(Anemone &A, VRenderContext &VC)
MemCore::WeakPtr< VRenderContext::RenderParameter > operator<<=(const Anemone_Context_String_t &ACS, const Value &V)
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
bool containsType(const TypeList_t &TL, const type_info &what)
Investigate if a certain type is contained in a given type list.
Definition FiberType.cpp:228
gridop_API RefPtr< Grid > DEPRECATED("Use grid/types/RegularGrid3D.hpp:UniformGrid3D instead", createUniformGrid(const string &InputGridname, const Info< Skeleton > &Level, const string &OutputGridname, const MultiIndex< 3 > &Resolution, const RefPtr< Eagle::BoundingBox > &SubBox=NullPtr()))
Create a uniform Grid from a given Grid.
typename Ownable< OwnedObjectType, ContainerBase >::Container OwnerOf
Shortcut to find the owning type.
Definition Ownable.hpp:265
Definition fs/init.hpp:20
Definition FiberTypeIndex.hpp:12
A set of types.
Definition FiberType.hpp:213