FishGrid.hpp

00001 #ifndef __FISH_BONE_GRID_HPP
00002 #define __FISH_BONE_GRID_HPP
00003 
00004 #include "Fish.hpp"
00005 #include <ocean/shrimp/VStringList.hpp>
00006 #include <bundle/GridSelector.hpp>
00007 
00008 namespace Wizt
00009 {
00010         using Fiber::GridSelector;
00011 
00012         typedef Fiber::Bundle::GridInfo_t GridInfo;
00013 
00017 template <>
00018 class fishbone_API VValueTrait<GridSelector>
00019 {
00020 public:
00021 
00022 static  bool setValueFromText(GridSelector&i, const string&s)
00023         {
00024                 return i.selectGrid( s );
00025         }
00026 
00027 static  string Text(const GridSelector&GS)
00028         {
00029                 return GS.Gridname();
00030         }
00031 };
00032 
00033 //extern        fishbone_API TypedSlot<Fiber::BundlePtr> getSpacetimeSlot(const TypedSlot<GridSelector>&GS);
00034 
00041 template <>
00042 struct  fishbone_API TypedSlot<Fiber::Grid> : public TypedSlot<GridSelector>
00043 {
00044         TypedSlot<Fiber::Grid>(VObject*that, const string&s, const GridSelector&GS = GridSelector(), int prior=0)
00045         : TypedSlot<GridSelector>(that,s, GS, prior)
00046         {}
00047 };
00048 
00049 
00054 template <>
00055 class   fishbone_API VOutput<Fiber::Grid> : public VOutput<GridSelector>
00056 {
00057 public:
00058         VOutput(const WeakPtr<VObject>&Source,
00059                 const string&initial_name,
00060                 const GridSelector&GridNames = GridSelector(),
00061                 const RefPtr<VCreationPreferences>&CP = NullPtr() );
00062 };
00063 
00064 
00065 
00066 
00067 
00071 template <>
00072 struct  fishbone_API Fish<Fiber::GridContainer>
00073 {
00074         virtual const Fish<Fiber::Grid>&GridContainer() const = 0;
00075         virtual ~Fish<Fiber::GridContainer>() = 0;
00076 };
00077 
00083 template <>
00084 struct  fishbone_API Fish<Fiber::Grid> : virtual Fish<double>
00085 {
00086         TypedSlot<Fiber::Grid>  MyGrid;
00087 
00092         Fish<Fiber::Grid>(const string&s = "grid", int prior=2);
00093 
00095         virtual ~Fish(); 
00096 
00098         void registerGridAsOutput()
00099         {
00100                 assert(myself);
00101                 myself->registerOutput( MyGrid );
00102         }
00103 
00130         Fiber::Bundle::GridInfo_t
00131                 findMostRecentGrid(GridSelector&GS, const RefPtr<ValuePool>&VP, const Fiber::BundlePtr&SpaceTime = Fiber::BundlePtr(NullPtr() )) const;
00132 
00136         Fiber::Bundle::GridInfo_t
00137                 findMostRecentGrid(const RefPtr<ValuePool>&VP, const Fiber::BundlePtr&SpaceTime = Fiber::BundlePtr( NullPtr() ) ) const
00138         {
00139         GridSelector    GS;
00140                 return findMostRecentGrid(GS, VP, SpaceTime);
00141         }
00142 
00143         GridSelector getGridSelector(const RefPtr<ValuePool>&VP) const
00144         {
00145         GridSelector    GS;
00146                 MyGrid << VP >> GS;
00147                 return GS;
00148         }
00149 
00150         Fiber::Info<Fiber::Skeleton>
00151                 getRefinementLevel(int Level, 
00152                                    const RefPtr<ValuePool>&VP,
00153                                    int IndexDepth = 0,
00154                                    const Fiber::BundlePtr&SpaceTime = Fiber::BundlePtr(NullPtr() ) ) const;
00155 
00156         Fiber::Info<Fiber::Skeleton>
00157                 getRefinementLevel(int Level, 
00158                                    const RefPtr<ValuePool>&VP,
00159                                    int IndexDepth = 0,
00160                                    const Fiber::BundlePtr&SpaceTime = Fiber::BundlePtr(NullPtr() ) )
00161         {
00162                 return const_cast<const Fish<Fiber::Grid>*>(this)->getRefinementLevel(Level, VP, IndexDepth, SpaceTime);
00163         }
00164 
00165         using Fish<double>::IterateLevels; 
00166 
00186         bool    IterateLevels(LevelIterator&LI, const RefPtr<ValuePool>&Context,
00187                               const Fiber::BundlePtr&SpaceTime = Fiber::BundlePtr( NullPtr() ) )
00188         {
00189                 return Fish<double>::IterateLevels(LI, findMostRecentGrid(Context, SpaceTime), Context);
00190         }
00191 
00192 
00193 #if 0
00194 /*
00195         override const Fish<Fiber::Grid>&GridContainer() const
00196         {
00197                 return *this;
00198         }
00199 */
00203         string  getGridname(const RefPtr<ValuePool>&VP) const; 
00204 
00205         typedef Fiber::Bundle::GridInfo_t pair_t;
00206 
00207         typedef pair<double, RefPtr<Fiber::Grid> > gridpair_t; 
00208 
00209         BundleSlot findGridSpacetimeSlot() const;
00210 
00211         BundleSlot GridSpacetimeSlot() const;
00212 
00213 private:
00214         Fiber::Bundle::GridInfo_t getGridSlice(const BundleSlot&SpaceTime, const RefPtr<ValuePool>&VP) const;
00215 
00216 public:
00217 #endif
00218 
00219 #if 0
00220         pair_t getGridSlice(const RefPtr<ValuePool>&VP) const
00221         {
00222                 return getGridSlice( GridSpacetimeSlot(), VP);
00223         }
00224 
00225         gridpair_t getGrid(const RefPtr<ValuePool>&VP) const
00226         {
00227                 return getGrid( GridSpacetimeSlot(), VP);
00228         }
00229 #endif
00230 #if 0
00231 
00237         pair<double, RefPtr<Fiber::Skeleton> > getRefinementLevel(//const BundleSlot&SpaceTime, 
00238                                                                   const RefPtr<ValuePool>&VP, 
00239                                                                   int L, int IndexDepth = 0) const;
00240 #endif
00241 #if 0
00242 private:
00243         bool    updateGridSelection(const BundleSlot&SpaceTime,
00244                                     const RefPtr<ValuePool>&VP) const;
00245 
00246 
00247         bool    updateFieldSelection(const TypedSlot<VStringList>&FieldSelection,
00248                                      const Fiber::TypeList_t*TypeList,
00249                                      const BundleSlot&SpaceTime,
00250                                      const RefPtr<ValuePool>&VP) const;
00251 public:
00252 
00253         bool    updateGridSelection(const RefPtr<ValuePool>&VP) const
00254         {
00255                 return updateGridSelection(GridSpacetimeSlot(), VP);
00256         }
00257 
00258 
00259         bool    updateFieldSelection(const TypedSlot<VStringList>&FieldSelection,
00260                                      const Fiber::TypeList_t*TypeList,
00261                                      const RefPtr<ValuePool>&VP) const
00262         {
00263                 return updateFieldSelection(FieldSelection,
00264                                             TypeList,
00265                                             GridSpacetimeSlot(), VP);
00266         }
00267 
00272         struct  fishbone_API GridInspector
00273         {
00274                 virtual bool operator()(const Fiber::GridID&id, const Fiber::Grid&G) const = 0;
00275                 virtual ~GridInspector();
00276         };
00277 
00278         virtual bool provides(const GridInspector&GI) const;
00279 
00296 static  RefPtr<VAcceptInfo> acceptGrid(const RefPtr<VObject>&vobj, const GridInspector&GI);
00297 #endif
00298 
00299 };
00300 
00301 } // namespace Wizt
00302 
00303 #endif /* __FISH_BONE_GRID_HPP */
00304