FieldSelection.hpp

00001 #ifndef __FIBER_FIELDSELECTION_HPP
00002 #define __FIBER_FIELDSELECTION_HPP
00003 
00004 #include "BundleAPI.h"
00005 #include <field/FiberType.hpp>
00006 #include <grid/Grid.hpp>
00007 
00008 namespace Fiber
00009 {
00010 
00022 class   BUNDLE_API FieldSelection : public ReferenceBase<FieldSelection>
00023 {
00028         typedef std::map<string, TypeList_t> FieldSelection_t; 
00029 
00038         FieldSelection_t Selection;
00039 
00043         TypeList_t      MyFieldTypes; 
00044 
00045 public:
00047         FieldSelection();
00048 
00057         bool    requires(const type_info&what); 
00058 
00070         TypeList_t&FieldTypes()
00071         {
00072                 return MyFieldTypes;
00073         } 
00074 
00078         const TypeList_t&FieldTypes() const
00079         {
00080                 return MyFieldTypes;
00081         }
00082 
00084         ~FieldSelection();
00085 
00087         friend bool operator==(const FieldSelection&L, const FieldSelection&R);
00088 
00090         friend bool operator!=(const FieldSelection&L, const FieldSelection&R)
00091         {
00092                 return  !(L==R);
00093         } 
00094 
00096         void    setUniqueField(const string&fieldname, const  TypeList_t&FT);
00097 
00103         string  getFieldName() const;
00104 
00108         unsigned getNumberOfFields() const;
00109 
00117         bool setFieldType(const string&Fieldname, const FiberTypeBase&, bool append); 
00118 
00122         bool setFieldType(const string&Fieldname, const TypeList_t&FieldSelection);
00123 
00124         TypeList_t getFieldType(const string&Fieldname) const;
00125         TypeList_t getFieldType() const;
00126 
00130         template <class T>
00131         bool    setType(bool append=true)
00132         {
00133                 return setFieldType(getFieldName(), FiberType<T>::getFiberType(), append );
00134         }
00135 
00136 
00140         template <class T>
00141         void setType(const string&name, bool append=true)
00142         {
00143                 setFieldType(name, FiberType<T>::getFiberType(), append );
00144         }
00145 
00152         RefPtr<Representation> getFields(const Representation&R) const;
00153 
00164         RefPtr<Representation> getCartesianVertexFields(const Grid&G) const;
00165 };
00166 
00167 
00168 
00169 } /* namespace Fiber */ 
00170 
00171 #endif /* __FIBER_FIELDSELECTION_HPP */
00172