00001 #ifndef __FIBER_GRID_FRAGMENT_HPP
00002 #define __FIBER_GRID_FRAGMENT_HPP
00003
00004 #include "Field.hpp"
00005
00006 namespace Fiber
00007 {
00008
00012 typedef std::map<string, RefPtr<CreativeArrayBase> > FragmentMap_t;
00013
00017 typedef map<string, RefPtr<Field> > FieldMap_t;
00018
00019
00020
00027 class FIELD_API Fragment : private FragmentMap_t
00028 {
00029 typedef FragmentMap_t map_t;
00030
00031 public:
00033 Fragment();
00034
00036 ~Fragment();
00037
00038 RefPtr<CreativeArrayBase>&operator[](const string&s);
00039 RefPtr<CreativeArrayBase> operator()(const string&s) const;
00040
00041 struct FIELD_API Iterator
00042 {
00043 virtual ~Iterator();
00044
00045 virtual bool apply(const string&storage_id, const RefPtr<CreativeArrayBase>&Cab) = 0;
00046 };
00047
00048 size_t size() const
00049 {
00050 return FragmentMap_t::size();
00051 }
00052
00053 int iterate(Iterator&It) const;
00054 };
00055
00059 class FIELD_API FieldCollection : private FieldMap_t
00060 {
00061 public:
00062 FieldCollection();
00063 ~FieldCollection();
00064
00065 RefPtr<Field>&operator[](const string&s);
00066 RefPtr<Field> operator()(const string&s) const;
00067
00068 bool FieldsAreOlderThan(const MemCore::Ageable&A) const;
00069
00070 void updateAge(MemCore::Ageable&A) const;
00071
00072 struct FIELD_API Iterator
00073 {
00074 virtual ~Iterator();
00075 virtual bool apply(const string&name, const RefPtr<Field>&F) = 0;
00076 };
00077
00078 int iterate(Iterator&It);
00079 };
00080
00081
00082
00087 class FIELD_API FragmentCluster : public FragmentIterator
00088 {
00089
00090
00091
00092
00094 typedef map<string, Fragment> fragmentsarray_t;
00095
00097 typedef map<int, fragmentsarray_t> fragmentcluster_t;
00098
00099 fragmentcluster_t fragmentcluster;
00100
00101 int refinement_level;
00102 string datafield_name;
00103 override bool apply(const RefPtr<FragmentID>&f, const RefPtr<CreativeArrayBase>&F);
00104
00105 int addField(const RefPtr<Field>&F, int RLevel, const string&internal_name);
00106
00107 public:
00109 FragmentCluster();
00110
00112 ~FragmentCluster();
00113
00117 void clear();
00118
00123 int addFields(FieldCollection&Fields, int RLevel);
00124
00128 struct FIELD_API Iterator
00129 {
00130 virtual ~Iterator() = 0;
00131
00132 virtual bool beginLevel(int RefinementLevel);
00133
00134 virtual bool apply(int RefinementLevel,
00135 const string&fragment_identifier,
00136
00137 const Fragment&FragmentData);
00138
00139 virtual bool endLevel(int RefinementLevel);
00140 };
00141
00152 int iterate(Iterator&RFI,
00153 const RefPtr<FragmentSelector>&FS,
00154 const string&SelectionField = "Positions") const;
00155 };
00156
00157
00158 }
00159
00160 #endif