7 #ifndef __data_RecordGroup_h__ 8 #define __data_RecordGroup_h__ 13 class RecordOperation;
19 typedef std::map< hp<Layout>, sp<RecordArray> > t_layout_ra;
21 typedef std::map< BaseAccessor,
22 sp<WatcherI> > t_attribute_watcher;
24 typedef std::set< sp<WatcherI> > t_watchers;
47 virtual void add(
const Record &record);
55 virtual bool remove(
const Record &record);
59 virtual void clear(
void);
61 virtual FE_UWORD size(
void);
63 virtual FE_UWORD count(
void);
72 std::set< sp<RecordGroup> > m_rgs;
73 std::set<Record> m_rs;
79 void enableDuplicates(
bool a_bool);
86 void maintainOrder(
bool a_bool);
89 virtual void removeReferences(
const Record &record,
90 bool recurse=
false, Info *info=NULL);
97 virtual bool find(
const Record &record);
115 void setWeak(BWORD weak);
118 BWORD
isWeak(
void)
const {
return m_weak; }
140 t_layout_ra::iterator m_raMapIt;
143 t_layout_ra::iterator m_endIt;
151 void watcherAdd(
const Record &record);
153 void watcherRemove(
const Record &record);
156 virtual void removeReferencesFromRecord(
Record &from,
158 bool recurse=
false, Info *info=NULL);
159 void rebuildArrays(
void);
162 t_attribute_watcher m_indices;
163 t_watchers m_watchers;
167 bool m_maintainOrder;
171 const String verboseName(
void)
const 172 {
return "RecordGroup " +
173 String(m_weak?
"(weak) ":
"") + name(); }
177 class FE_DL_EXPORT PtrRecordGroupInfo :
public BaseType::Info
180 virtual String print(
void *instance);
181 virtual IWORD output(std::ostream &ostrm,
void *instance, t_serialMode mode);
182 virtual void input(std::istream &istrm,
void *instance, t_serialMode mode);
183 virtual IWORD iosize(
void);
184 virtual bool getConstruct(
void);
185 virtual void construct(
void *instance);
186 virtual void destruct(
void *instance);
194 t_attribute_watcher::iterator it = m_indices.find(accessor);
195 if(it == m_indices.end())
197 spRI =
new RecordMap<T>(accessor);
198 m_indices[accessor] = spRI;
199 m_watchers.insert(spRI);
202 rg_it != this->end(); rg_it++)
205 if(accessor.
check(spRA))
207 for(
int i = 0; i < spRA->length(); i++)
209 spRI->add(spRA->getRecord(i));
226 FEASSERT(spMap.isValid());
228 return spMap.isValid()? spMap->lookup(value):
Record();
231 inline RecordGroup::RecordGroup(
void)
235 m_duplicates = FALSE;
236 m_maintainOrder = FALSE;
239 inline RecordGroup::RecordGroup(
const RecordGroup &other):
244 m_raMap = other.m_raMap;
245 m_weak = other.m_weak;
246 m_locking = other.m_locking;
247 m_duplicates = other.m_duplicates;
248 m_maintainOrder = other.m_maintainOrder;
254 feX(
"RecordGroup",
"uncertain about desired assignment semantics");
257 m_raMap = other.m_raMap;
258 m_weak = other.m_weak;
259 m_locking = other.m_locking;
260 m_duplicates = other.m_duplicates;
261 m_maintainOrder = other.m_maintainOrder;
277 if(m_duplicates!=a_bool)
279 m_duplicates = a_bool;
286 if(m_maintainOrder!=a_bool)
288 m_maintainOrder = a_bool;
295 SAFEGUARDCLASS_IF(m_locking);
296 return m_raMap.size();
301 SAFEGUARDCLASS_IF(m_locking);
303 t_layout_ra::iterator it = m_raMap.find(record.
layout());
304 if(it == m_raMap.end())
308 return it->second->find(record);
313 SAFEGUARDCLASS_IF(m_locking);
322 SAFEGUARDCLASS_IF(m_locking);
325 for(t_attribute_watcher::iterator tw_it = m_indices.begin();
326 tw_it != m_indices.end(); tw_it++)
328 tw_it->second->clear();
330 for(t_watchers::iterator tw_it = m_watchers.begin();
331 tw_it != m_watchers.end(); tw_it++)
340 it.m_raMapIt = m_raMap.begin();
341 it.m_endIt = m_raMap.end();
349 it.m_raMapIt = m_raMap.end();
350 it.m_endIt = m_raMap.end();
357 m_raMapIt=it.m_raMapIt;
360 m_filters=it.m_filters;
365 return m_raMapIt->second;
370 return &(m_raMapIt->second);
373 inline bool RecordGroup::iterator::check(
void)
375 if(m_raMapIt == m_endIt) {
return false; }
376 for(
unsigned int i = 0; i < m_filters.size(); i++)
378 if(!m_filters[i].check(m_raMapIt->second))
391 while(!check() && m_raMapIt != m_endIt);
402 while(!check() && m_raMapIt != m_endIt);
406 inline bool RecordGroup::iterator::operator==(
409 return (m_raMapIt==other.m_raMapIt);
412 inline bool RecordGroup::iterator::operator!=(
415 return (m_raMapIt!=other.m_raMapIt);
A heterogenous collection of records.
Definition: RecordGroup.h:35
Class level locking for thread safety.
Definition: Safe.h:213
Base participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:93
kernel
Definition: namespace.dox:3
BWORD isWeak(void) const
Return TRUE if using weak referencing.
Definition: RecordGroup.h:118
The main data access class for the data system.
Definition: Accessor.h:128
virtual FE_UWORD size(void)
Return the number of RecordArray (Layouts).
Definition: RecordGroup.h:293
sp< Layout > layout(void) const
Return the Layout.
Definition: RecordSB.h:189
BWORD operator!=(const DualString &s1, const DualString &s2)
Compare two DualString's (reverse logic)
Definition: DualString.h:229
virtual bool find(const Record &record)
Return true if record is in the record group.
Definition: RecordGroup.h:299
void enableDuplicates(bool a_bool)
Don't retain a mappping from Record to array index.
Definition: RecordGroup.h:275
An operation on a record.
Definition: RecordOperation.h:24
BWORD operator==(const DualString &s1, const DualString &s2)
Compare two DualString's.
Definition: DualString.h:208
Automatically reference-counted string container.
Definition: String.h:128
void setWeak(BWORD weak)
Choose weak referencing.
Definition: RecordGroup.h:266
bool check(const RecordSB &r) const
Return true if record has attribute.
Definition: Accessor.h:314
STL style iterator.
Definition: RecordGroup.h:124
Wrapper for std::vector.
Definition: Array.h:21
virtual void clear(void)
Clear the collection.
Definition: RecordGroup.h:320
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Base class providing an fe::Handle to the derived class.
Definition: Handled.h:209
void maintainOrder(bool a_bool)
Try not to reorder entries in each array.
Definition: RecordGroup.h:284
void prune(void)
Remove any invalid weak references.
Definition: RecordGroup.h:311