00001 #ifndef __FIBER_FIELDSELECTOR_HPP
00002 #define __FIBER_FIELDSELECTOR_HPP
00003
00004 #include "BundleAPI.h"
00005 #include <grid/Grid.hpp>
00006 #include "GridSelector.hpp"
00007 #include "FieldSelection.hpp"
00008
00009 namespace Fiber
00010 {
00011
00017 class BUNDLE_API FieldSelector : public GridSelector
00018 {
00023 RefPtr<FieldSelection> MySelectedFields;
00024
00025 public:
00026
00034 Info<Grid> FieldSource;
00035
00039 FieldSelection&Selection();
00040
00042 FieldSelector();
00043
00047 FieldSelector(const GridSelector&GS, const Info<Grid>&FieldSource);
00048
00054 FieldSelector(const FieldSelector&FS);
00055
00056 FieldSelector(const BundlePtr&bpP, const double timeP, const string& gridNameP, const string& fieldNameP);
00057
00063 FieldSelector(double&time, const BundlePtr&BP, const string& gridName, const string&fieldName);
00064
00066 ~FieldSelector();
00067
00075 bool requires(const type_info&what) const
00076 {
00077 if (!MySelectedFields)
00078 return true;
00079
00080 return MySelectedFields->requires(what);
00081 }
00082
00084 unsigned NumberOfAvailableFields() const;
00085
00087 TypeList_t&FieldTypes()
00088 {
00089 return Selection().FieldTypes();
00090 }
00091
00100 template <class T>
00101 void accept()
00102 {
00103 AcceptType<T>::accept( FieldTypes() );
00104
00105
00106
00107
00108 }
00109
00111 friend BUNDLE_API bool operator==(const FieldSelector&L, const FieldSelector&R);
00112
00114 friend bool operator!=(const FieldSelector&L, const FieldSelector&R)
00115 {
00116 return !(L==R);
00117 }
00118
00126 void selectField(const string&fieldname, const TypeList_t&FT = TypeList_t() );
00127
00133 void selectField(const BundlePtr&BP, const double time, const string& gridName, const string&fieldName,
00134 const RefPtr<Grid>&G, const RefPtr<Slice>&S)
00135 {
00136 selectField( fieldName );
00137 FieldSource = Info<Grid>( time, S, G);
00138 selectGrid(gridName);
00139 theSourceBundle = BP;
00140 }
00141
00145 void clearSelection();
00146
00147 RefPtr<Fiber::FieldID> createFieldID(Fiber::Representation&Rep) const
00148 {
00149 return Rep.createFieldID( getFieldName() );
00150 }
00151
00152 bool setFieldSource(double time, const string&theFieldname);
00153
00158 bool findFieldSource(double time, const string&Fieldname);
00159
00164 bool findFieldSource(const BundlePtr&bpP, double timeP, const string& gridNameP, const string&fieldNameP);
00165
00167 string getFieldName() const;
00168
00170 string getFieldname() const
00171 {
00172 return getFieldName();
00173 }
00174
00176 string operator()() const
00177 {
00178 return getFieldName();
00179 }
00180
00181 typedef std::pair<Fiber::Bundle::GridInfo_t, RefPtr<Fiber::Field> > FieldInfo_t;
00182
00189 const RefPtr<Fiber::Grid>&GridSource() const
00190 {
00191 return FieldSource.getGrid();
00192 }
00193
00200 const RefPtr<Fiber::Grid>&getGrid() const
00201 {
00202 return FieldSource.getGrid();
00203 }
00204
00208 const RefPtr<Fiber::Slice>&getSlice() const
00209 {
00210 return FieldSource.getSlice();
00211 }
00212
00214 double getTime() const
00215 {
00216 return FieldSource.getTime();
00217 }
00218
00227 RefPtr<Field> getField(const string&theName) const;
00228
00234 RefPtr<Fiber::Field> getField() const
00235 {
00236 return getField( getFieldName() );
00237 }
00238
00243 RefPtr<Field> getCartesianPositions() const;
00244
00249 RefPtr<Representation> getCartesianRepresentation() const;
00250 };
00251
00252
00253
00254 }
00255
00256 #endif
00257