Free Electron
RecordView.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __datatool_RecordView_h__
8 #define __datatool_RecordView_h__
9 
10 #define FE_RV_VERBOSE (FE_CODEGEN<=FE_DEBUG)
11 #define FE_RV_CHECK (FE_CODEGEN<=FE_DEBUG)
12 
13 // check that Record exists
14 #define FE_RV_R_CHECK (FE_CODEGEN<=FE_DEBUG)
15 
16 // check that WeakRecord's have serial numbers
17 #define FE_RV_WR_CHECK (FE_CODEGEN<=FE_DEBUG)
18 
19 namespace fe
20 {
21 namespace ext
22 {
23 
24 /**************************************************************************//**
25  @brief Bindable collection of accessor Functors
26 
27  @ingroup datatool
28 
29  RecordView is an enhanced AccessorSet that supports inheritance
30  and default values. Like an AccessorSet, a RecordView instance
31  can be reused for any number of Record instances.
32 
33  For example:
34 
35 @code
36 class FE_DL_EXPORT Point: public RecordView
37 {
38  public:
39  Functor<SpatialVector> location;
40 
41  Point(void) { setName("Point"); }
42 virtual void addFunctors(void)
43  {
44  add(length, "spatial_vector",
45  FE_SPEC("spc:at",
46  "translation from origin"));
47  }
48 virtual void initializeRecord(void)
49  {
50  set(location());
51  }
52 virtual void finalizeRecord(void)
53  {
54  }
55 };
56 @endcode
57 
58  A class that derives from RecordView is expected to provide several things.
59  Added attributes are provided through Functors,
60  an enhancement of the Accessor.
61 
62  Provide a name for the generated Layout by setting the name
63  of the RecordView, using setName().
64 
65  Functors are wired up using add() during addFunctors().
66  The implementation of addFunctors() should call the like-named functions
67  for any direct base classes, much like a manual constructor mechanism.
68  Convention insists that attributes names are provided using
69  FE_USE or FE_SPEC. FE_USE presumes that an FE_SPEC or FE_ATTRIBUTE
70  elsewhere has provided a description for the atrribute.
71 
72  As a RecordFactoryI, a RecordView can be used to instantiate Records
73  by name from file. The method initializeRecord is called before
74  loading data to provide basic defaults. A method finalizeRecord
75  can be used after loading a Record for producing derived values,
76  such as creating a component as named by an attribute.
77  Both initializeRecord and finalizeRecord may be omitted if
78  nothing needs to be done for that stage.
79  As with addFunctors, both initializeRecord and finalizeRecord should
80  call the like-named functions for any direct base classes.
81 
82  To be available as a RecordFactoryI, each RecordView-derived type
83  should be added to a library during CreateLibrary()
84  like any other Component.
85 
86 @code
87 pLibrary->add<Point>("RecordFactoryI.Point.fe");
88 @endcode
89 
90  File-based defaults can be provided as a template in a record group file.
91 
92 @code
93 TEMPLATE Point ""
94  spc:at "0 0 0"
95 @endcode
96 
97  Attributes not represented by a template retain settings from
98  initializeRecord or their type's constructor.
99  Derived templates can provide new defaults that override prior values.
100  In the basic case, templates will parallel provided Factories,
101  including multiple inheritance (the second argument to TEMPLATE).
102  However, new templates can be provided purely on multiple inheritance
103  where no new attributes are added.
104 
105 *//***************************************************************************/
107  public AccessorSet,
108  virtual public RecordFactoryI
109 {
110  protected:
111 
112  /// @brief Untyped Functor base
114  {
115  public:
116 #if FE_RV_CHECK
117  RecordHolder(void):
118  m_pWeakRecord(NULL) {}
119 #endif
120  /// NOP: RecordView will handle copying
121  RecordHolder& operator=(const RecordHolder& rRecordHolder)
122  { return *this; }
123 
124  void bind(WeakRecord& rWeakRecord)
125  { m_pWeakRecord=&rWeakRecord; }
126  protected:
127 
128  WeakRecord& weakRecord(void) const
129  {
130 #if FE_RV_R_CHECK
131  if(!m_pWeakRecord)
132  {
133  feX("RecordView::RecordHolder"
134  "::weakRecord",
135  "m_pWeakRecord NULL");
136  }
137 #endif
138  return *m_pWeakRecord;
139  }
140 
141  WeakRecord* m_pWeakRecord;
142  };
143 
144  /// @brief Bound accessor in a RecordView
145  /// @ingroup datatool
146  template<typename T>
147  class Functor: public RecordHolder, public Accessor<T>
148  {
149  public:
150  Functor(void) {}
151  T& operator()(void);
152  const T operator()(void) const;
153  T& operator()(const Record& r)
154  { return Accessor<T>::operator()(r); }
155 const T operator()(const Record& r) const
156  { return Accessor<T>::operator()(r); }
157  T& operator()(const WeakRecord& r)
158  { checkWeakRecord(r);
159  return Accessor<T>::operator()(r); }
160 const T operator()(const WeakRecord& r) const
161  { checkWeakRecord(r);
162  return Accessor<T>::operator()(r); }
163  T& operator()(sp<RecordArray>& rspRA, FE_UWORD index)
164  { return Accessor<T>::operator()(rspRA,index); }
165 const T& operator()(sp<RecordArray>& rspRA, FE_UWORD index) const
166  { return Accessor<T>::operator()(rspRA,index); }
167 
168  BWORD check(void) const
169  {
170  FEASSERT(m_pWeakRecord);
171  return Accessor<T>::check(*m_pWeakRecord);
172  }
173  BWORD check(sp<RecordArray>& rspRA) const
174  { return Accessor<T>::check(rspRA); }
175  BWORD check(const Record& r) const
176  { return Accessor<T>::check(r); }
177 
178  /** @brief Get the value, checking first
179 
180  If the bound Record does not support the
181  attribute, zero is returned, cast to the
182  attribute type. */
183  T safeGet(void)
184  {
185  T* pValue=NULL;
186  if(weakRecord().isValid() &&
188  weakRecord())))
189  {
190  return *pValue;
191  }
192  return T(0);
193  }
194 
195  /** @brief Set the value, checking first
196 
197  If the bound Record does not support the
198  attribute, nothing occurs. */
199  void safeSet(T value)
200  {
201  T* pValue=NULL;
202  if(weakRecord().isValid() &&
204  weakRecord())))
205  {
206  *pValue=value;
207  }
208  }
209 
210  /** @brief Call the attribute as a method
211 
212  If the attribute cannot be cast to HandlerI,
213  nothing occurs.
214  If the cast is successful, the currently indexed
215  Record is passed to the HandlerI using handle().
216 
217  Trying to call an attribute whose content is not
218  derived from Counted or similar may cause a
219  compiler error. */
220  void call(void)
221  {
222  sp<HandlerI> spHandlerI=safeGet();
223  if(spHandlerI.isValid())
224  {
225  Record record=weakRecord();
226 
227  spHandlerI->handle(record);
228  }
229  }
230 
231  /** @brief Create a named component for the attribute
232 
233  The created component is placed in the attribute.
234  If the attribute is not a component,
235  a compile error should occur. */
236  void createAndSetComponent(String componentName)
237  {
238  sp<Scope> spScope=Accessor<T>::scope();
239  FEASSERT(spScope.isValid());
240  sp<Component> spComponent=
241  spScope->registry()->create(componentName);
242  if(!spComponent.isValid())
243  {
244  feX("Functor<>::createAndSetComponent",
245  "\"%s\" failed to create \"%s\"\n",
246  name().c_str(),
247  componentName.c_str());
248  }
249  spComponent->setName(componentName+" "+name());
250  operator()()=spComponent;
251  }
252 
253  /** @brief Create a RecordGroup for the attribute
254 
255  The RecordGroup is placed in the attribute.
256  If the attribute is not a RecordGroup,
257  a compile error should occur. */
259  {
260  FEASSERT(m_pWeakRecord);
261  sp<RecordGroup> spRecordGroup(new RecordGroup());
262  FEASSERT(spRecordGroup.isValid());
263 #if FE_COUNTED_TRACK
264  spRecordGroup->setName(name());
265 #endif
266  operator()()=spRecordGroup;
267  }
268 
269 const String& name(void) const
270  { return BaseAccessor::attribute()->name(); }
271  private:
272  void checkRecordExists(void) const
273  {
274 #if FE_RV_R_CHECK
275  if(!weakRecord().isValid())
276  {
277  feX("RecordView::checkRecordExists",
278  "WeakRecord invalid");
279  }
280 #endif
281  }
282 
283  void checkWeakRecord(const WeakRecord& r) const
284  {
285 #if FE_RV_WR_CHECK
286  r.demandSerialNumber();
287 #endif
288  }
289  };
290 
291  public:
292  RecordView(void) {}
293 
294 virtual ~RecordView(void)
295  {
296 #if FE_COUNTED_TRACK
297  deregisterRegion(fe_cast<Counted>(this));
298 #endif
299  }
300 
301  void setName(const String& name)
302  {
303  Component::setName(name);
304 #if FE_COUNTED_TRACK
305  registerRegion(fe_cast<Counted>(this),
306  sizeof(RecordView));
307 #endif
308  }
309 
310 const String verboseName(void) const
311  { return "RecordView " + name(); }
312 
313  /** @brief Associate with a Scope
314 
315  This can happen automatically by binding
316  to a Record, but may be neccessary
317  if you need to use the Functors before an
318  appropriate Layout exists. */
319  void bind(sp<Scope>& rspScope)
320  {
321  FEASSERT(rspScope.isValid());
322 
323  if(!m_hpScope.isValid())
324  {
325  AccessorSet::bind(rspScope);
326  addFunctors();
327  }
328 #if FE_RV_CHECK
329  else if(m_hpScope!=rspScope)
330  {
331  feX("RecordView::bind(sp<Scope>&) \"%s\"",
332  "changed scope",name().c_str());
333  }
334 #endif
335  }
336 
337  /// @brief Associate with a Scope by Handle
338  void bind(hp<Scope>& rhpScope)
339  {
340  FEASSERT(rhpScope.isValid());
341 
342  if(!m_hpScope.isValid())
343  {
344  AccessorSet::bind(rhpScope);
345  addFunctors();
346  }
347 #if FE_RV_CHECK
348  else if(m_hpScope!=rhpScope)
349  {
350  feX("RecordView::bind(hp<Scope>&) \"%s\"",
351  "changed scope",name().c_str());
352  }
353 #endif
354  }
355 
356  /// @brief Return associated Scope
357  hp<Scope>& scope(void) { return m_hpScope; }
358 
359  /** @brief Disassociate with any Record
360 
361  This should free all references. */
362  void unbind(void)
363  {
364  m_record=Record();
365  m_weakRecord=WeakRecord();
366  }
367 
368  /** @brief Associate with a specific Record
369 
370  The Record will persist while bound.
371  Use unbind() to release the binding.
372 
373  Passing Record objects is not thread-safe.
374 
375  This may use the Record's scope to
376  initialize the functors. */
377  void bind(const Record record,BWORD weak=FALSE)
378  {
379  m_record=record;
380  m_weakRecord=m_record;
381 
382  if(!record.isValid())
383  {
384  return;
385  }
386 
387 #if !FE_RV_CHECK
388  if(!m_hpScope.isValid())
389 #endif
390  {
391  bind(record.layout()->scope());
392  }
393  }
394 
395  /** @brief Associate with a specific WeakRecord
396 
397  The RecordView will not ensure that the WeakRecord
398  continues to persist.
399 
400  This may use the Record's scope to
401  initialize the functors. */
402  void bind(const WeakRecord weakRecord,BWORD weak=FALSE)
403  {
404  m_record=Record();
405  m_weakRecord=weakRecord;
406 
407 #if !FE_RV_CHECK
408  if(!m_hpScope.isValid())
409 #endif
410  {
411  if(weakRecord.isValid())
412  {
413  bind(weakRecord.layout()->scope());
414  }
415  }
416  }
417 
418  /** @brief Associate with a specific WeakRecord
419 
420  The RecordView will not ensure that the WeakRecord
421  continues to persist.
422 
423  This method is faster than bind(WeakRecord) as it
424  will never check the Scope and initialize the functors.
425  Using bind(sp<Scope>) before this method can
426  ensure that the functors are initialized. */
427  void setWeakRecord(const WeakRecord weakRecord)
428  {
429  m_record=Record();
430  m_weakRecord=weakRecord;
431  }
432 
433  /** @brief Produce a Record using all the attributes
434 
435  The Record is unbound after initialization. */
436 virtual void produce(Record& rRecord)
437  {
438  if(rRecord.isValid())
439  {
440  bind(rRecord);
442  }
443  else
444  {
445  rRecord=createRecord();
446  }
447  unbind();
448  }
449 
450  /** @brief Finalize a Record using all the attributes
451 
452  This step follows after the record is fully
453  initialized and potentially serialized in.
454 
455  The Record is unbound after initialization. */
456 virtual void finalize(Record& rRecord)
457  {
458  if(rRecord.isValid())
459  {
460  bind(rRecord);
461  finalizeRecord();
462  }
463  unbind();
464  }
465 
466  /** @brief Create a Record using all the attributes
467 
468  The Record is automatically bound. */
470  {
471  if(!m_hpScope.isValid())
472  {
473  feX("RecordView::createRecord",
474  "\"%s\" has invalid scope\n",
475  name().c_str());
476  }
477 
478  Record record=m_hpScope->createRecord(layout());
479  if(!m_hpLayout.isValid())
480  {
481  feX("RecordView::createRecord",
482  "\"%s\" failed to create layout\n",
483  name().c_str());
484  }
485  if(!record.isValid())
486  {
487  feX("RecordView::createRecord",
488  "\"%s\" failed to create record\n",
489  name().c_str());
490  }
491 
492  bind(record);
494  return record;
495  }
496 
497  /// @brief Access the record by weak (fast) reference
498  WeakRecord record(void) const
499  {
500  return m_weakRecord;
501  }
502 
503  /// @brief Access a Layout of all the attributes
505  {
506  if(!m_hpScope.isValid())
507  {
508  feLog("RecordView::layout \"%s\" invalid scope\n",
509  name().c_str());
510  return sp<Layout>(NULL);
511  }
512  if(!m_hpLayout.isValid())
513  {
514  m_hpLayout=createLayout();
515  }
516  return m_hpLayout;
517  }
518 
519  /// @brief Spew attributes and state for the bound Record
520  void dump(void)
521  {
522  U32 number=size();
523  for(U32 m=0;m<number;m++)
524  {
525  FEASSERT((*this)[m]);
526  if(!record().isValid())
527  {
528  feLog("%2d %-16s %-16s <invalid record>\n",m,
529  nameOf(*(*this)[m]).c_str(),
530  typeOf(*(*this)[m]).c_str());
531  }
532 // valid record should always be locked anyway
533 #if 0
534  else if(!record().layout()->locked())
535  {
536  feLog("%2d %-16s %-16s <not locked>\n",m,
537  nameOf(*(*this)[m]).c_str(),
538  typeOf(*(*this)[m]).c_str());
539  }
540 #endif
541  else
542  {
543  feLog("%2d %-16s %-16s %s\n",m,
544  nameOf(*(*this)[m]).c_str(),
545  typeOf(*(*this)[m]).c_str(),
546  printOf(*(*this)[m]).c_str());
547  }
548  }
549  }
550 
551  /** @brief Called at instantiation to add functors
552 
553  In addition to using add() to explicitly adding all
554  the functors for a particular class,
555  the implementation of this function should first call
556  addFunctors() for all directly inherited classes
557  that are indirectly or directly derived from
558  RecordView(). */
559 virtual void addFunctors(void) =0;
560 
561  /** @brief Called at instantiation to initialize
562  attributes
563 
564  In addition to setting any attributes, the
565  implementation of this function should first call
566  initializeRecord() for all directly inherited classes
567  that are indirectly or directly derived from
568  RecordView().
569 
570  Functors can be used as accessors at this point. */
571 virtual void initializeRecord(void) {}
572 
573  /** @brief Called right after instantiation to finalize
574  complex attributes
575 
576  In addition to adjusting any attributes, the
577  implementation of this function should first call
578  finalizeRecord() for all directly inherited classes
579  that are indirectly or directly derived from
580  RecordView().
581 
582  Functors can be used as accessors at this point. */
583 virtual void finalizeRecord(void) {}
584 
585  /** @brief Indicate a RecordFactoryI for a Scope
586 
587  The template type is presumably a RecordView.
588  This function extracts the relevant arguments
589  to pass to the Scope.
590 
591  It is usually preferable to add the RecordView
592  as a Scope-generic RecordFactoryI using the
593  general registry mechanism.
594 
595  This is a convenience that doesn't really relate
596  to RecordView. */
597  template <typename T>
598 static void registerFactory(sp<Scope> spScope)
599  {
600  T* pRV=new T();
601  sp<RecordFactoryI> spRecordFactoryI(pRV);
602  spScope->registerFactory(pRV->name(),spRecordFactoryI);
603  }
604 
605  /** @brief Load a RecordGroup from a file
606 
607  This is a convenience that doesn't really relate
608  to RecordView. */
610  String filename,BWORD a_binary=FALSE)
611  {
612  std::ifstream inFile(filename.c_str());
613  if(!inFile)
614  {
615 #if FE_RV_VERBOSE
616  feLog("RecordView::loadRecordGroup"
617  " could not open\n \"%s\"\n",
618  filename.c_str());
619 #endif
620  return sp<RecordGroup>();
621  }
622 
623  sp<data::StreamI> spStream(a_binary?
625  new data::BinaryStream(spScope)):
627  new data::AsciiStream(spScope)));
628  sp<RecordGroup> spRecordGroup=spStream->input(inFile);
629  inFile.close();
630 
631  return spRecordGroup;
632  }
633 
634  /** @brief Serialize a RecordGroup from a string
635 
636  This is a convenience that doesn't really relate
637  to RecordView. */
639  String buffer,BWORD a_binary=FALSE)
640  {
641  std::istringstream inString(buffer.c_str());
642  if(!inString)
643  {
644 #if FE_RV_VERBOSE
645  feLog("RecordView::loadRecordGroupFromBuffer"
646  " could not open string buffer\n");
647 #endif
648  return sp<RecordGroup>();
649  }
650 
651  sp<data::StreamI> spStream=a_binary?
653  new data::BinaryStream(spScope)):
655  new data::AsciiStream(spScope));
656  sp<RecordGroup> spRecordGroup=spStream->input(inString);
657 
658  return spRecordGroup;
659  }
660 
661  /** @brief Save a RecordGroup to a file
662 
663  This is a convenience that doesn't really relate
664  to RecordView. */
665 static void saveRecordGroup(sp<Scope> spScope,
666  sp<RecordGroup>& rspRecordGroup,
667  String filename,BWORD a_binary=FALSE)
668  {
669  std::ofstream outfile(filename.c_str());
670  if(!outfile)
671  {
672  feLog("RecordView::saveRecordGroup"
673  " could not open test output file\n");
674  }
675  else
676  {
677  sp<data::StreamI> spStream=a_binary?
679  new data::BinaryStream(spScope)):
681  new data::AsciiStream(spScope));
682  spStream->output(outfile, rspRecordGroup);
683  outfile.close();
684  }
685  }
686 
687  protected:
688  /** @brief Add an attribute Functor
689 
690  The functor should be a member variable.
691  The name can be arbitrary, but conventions
692  may be wise. */
693  void add(BaseAccessor& rFunctor,const char* name)
694  {
695  rFunctor.setup(m_hpScope,name);
696 // m_hpScope->support(name,type);
697  AccessorSet::add(rFunctor,name);
698  RecordHolder* pHolder=
699  static_cast<RecordHolder*>(
700  static_cast<Functor<int>*>(&rFunctor));
701  pHolder->bind(m_weakRecord);
702  }
703 
704  RecordView(const RecordView& rRecordView):
705 //* TODO check gcc, clang (warning on VS)
706 // Castable(),
707 // Component(),
708  AccessorSet() {}
709 
710  private:
711  sp<Layout> createLayout(void)
712  {
713  if(!m_hpScope.isValid())
714  {
715  feX("AccessorArray::createLayout",
716  "\"%s\" has invalid scope\n",
717  name().c_str());
718  }
719 
720  sp<Layout> spLayout=m_hpScope->declare(name());
721  if(!spLayout.isValid())
722  {
723  feX("AccessorArray::createLayout",
724  "\"%s\" failed to create layout\n",
725  name().c_str());
726  }
727 
728  populate(spLayout);
729  return spLayout;
730  }
731 
732  String nameOf(BaseAccessor& accessor) const
733  { return accessor.attribute()->name(); }
734 
735  String typeOf(BaseAccessor& accessor) const
736  {
737  std::list<String> nameList;
738  m_hpScope->registry()->master()->typeMaster()
739  ->reverseLookup(baseTypeOf(accessor),nameList);
740  return nameList.front();
741  }
742 
743  String printOf(BaseAccessor& accessor)
744  {
745  void* pVoid=record().rawAttribute(accessor.index());
746 
747  sp<BaseType::Info> spInfo=helpOf(accessor);
748  return spInfo->print(pVoid);
749  }
750 
751  sp<BaseType::Info> helpOf(BaseAccessor& accessor) const
752  {
753  sp<BaseType::Info> spInfo=
754  baseTypeOf(accessor)->getInfo();
755  FEASSERT(spInfo.isValid());
756  return spInfo;
757  }
758 
759  sp<BaseType> baseTypeOf(BaseAccessor& accessor) const
760  {
761  sp<Attribute> spAttribute=accessor.attribute();
762  return spAttribute->type();
763  }
764 
765  hp<Layout> m_hpLayout;
766 
767  Record m_record;
768  WeakRecord m_weakRecord;
769 };
770 
771 template<typename T>
773 {
774 #if FE_RV_R_CHECK
775  checkRecordExists();
776 #endif
777  return Accessor<T>::operator()(weakRecord());
778 }
779 
780 template<typename T>
781 inline const T RecordView::Functor<T>::operator()(void) const
782 {
783 #if FE_RV_R_CHECK
784  checkRecordExists();
785 #endif
786  return Accessor<T>::operator()(weakRecord());
787 }
788 
789 template<>
791 {
792 #if FE_RV_R_CHECK
793  checkRecordExists();
794 #endif
795 
796 #if FE_RV_WR_CHECK
797  checkWeakRecord(Accessor<WeakRecord>::operator()(weakRecord()));
798 #endif
799  return Accessor<WeakRecord>::operator()(weakRecord());
800 }
801 
802 template<>
804 {
805 #if FE_RV_R_CHECK
806  checkRecordExists();
807 #endif
808 
809 #if FE_RV_WR_CHECK
810  checkWeakRecord(Accessor<WeakRecord>::operator()(weakRecord()));
811 #endif
812  return Accessor<WeakRecord>::operator()(weakRecord());
813 }
814 
815 inline BWORD operator==(const RecordView& rRecordView1,
816  const RecordView& rRecordView2)
817 {
818  return rRecordView1.record()==rRecordView2.record();
819 }
820 
821 inline BWORD operator!=(const RecordView& rRecordView1,
822  const RecordView& rRecordView2)
823 {
824  return rRecordView1.record()!=rRecordView2.record();
825 }
826 
827 } /* namespace ext */
828 } /* namespace fe */
829 
830 #endif /* __datatool_RecordView_h__ */
A heterogenous collection of records.
Definition: RecordGroup.h:35
Set of accessors.
Definition: AccessorSet.h:18
void createAndSetRecordGroup(void)
Create a RecordGroup for the attribute.
Definition: RecordView.h:258
const FESTRING_I8 * c_str(void) const
Return the contents of the 8-bit buffer cast as signed bytes.
Definition: String.h:352
bool isValid(void) const
Return true if the Record points to a valid state block.
Definition: RecordSB.h:184
void add(BaseAccessor &rFunctor, const char *name)
Add an attribute Functor.
Definition: RecordView.h:693
void bind(sp< Scope > &rspScope)
Associate with a Scope.
Definition: RecordView.h:319
kernel
Definition: namespace.dox:3
Bound accessor in a RecordView.
Definition: RecordView.h:147
void demandSerialNumber(void) const
throw if the record doesn&#39;t have a serial number
Definition: WeakRecordSB.cc:14
const sp< LayoutSB > & layout(void) const
Return the Layout.
Definition: WeakRecordSB.h:251
RecordHolder & operator=(const RecordHolder &rRecordHolder)
NOP: RecordView will handle copying.
Definition: RecordView.h:121
hp< Registry > registry(void) const
Get the Registry that created this component.
Definition: Component.cc:219
The main data access class for the data system.
Definition: Accessor.h:128
static void registerFactory(sp< Scope > spScope)
Indicate a RecordFactoryI for a Scope.
Definition: RecordView.h:598
sp< Layout > layout(void) const
Return the Layout.
Definition: RecordSB.h:189
hp< Scope > & scope(void)
Return associated Scope.
Definition: RecordView.h:357
BWORD operator!=(const DualString &s1, const DualString &s2)
Compare two DualString&#39;s (reverse logic)
Definition: DualString.h:229
static sp< RecordGroup > loadRecordGroup(sp< Scope > spScope, String filename, BWORD a_binary=FALSE)
Load a RecordGroup from a file.
Definition: RecordView.h:609
Component to create and initialize a Record.
Definition: RecordFactoryI.h:18
void call(void)
Call the attribute as a method.
Definition: RecordView.h:220
Type inspecific Accessor.
Definition: Accessor.h:26
virtual void finalize(Record &rRecord)
Finalize a Record using all the attributes.
Definition: RecordView.h:456
sp< Component > create(const String &a_pattern, BWORD quiet=FALSE) const
Instantiate a Component of the given named implementation.
Definition: Registry.cc:628
Untyped Functor base.
Definition: RecordView.h:113
Safe handle for shared pointer.
Definition: Handled.h:61
void safeSet(T value)
Set the value, checking first.
Definition: RecordView.h:199
sp< Attribute > attribute(void) const
Return the attribute this accessor is for.
Definition: Accessor.cc:151
WeakRecord record(void) const
Access the record by weak (fast) reference.
Definition: RecordView.h:498
void dump(void)
Spew attributes and state for the bound Record.
Definition: RecordView.h:520
void unbind(void)
Disassociate with any Record.
Definition: RecordView.h:362
Automatically reference-counted string container.
Definition: String.h:128
void bind(hp< Scope > &rhpScope)
Associate with a Scope by Handle.
Definition: RecordView.h:338
bool check(const RecordSB &r) const
Return true if record has attribute.
Definition: Accessor.h:314
void createAndSetComponent(String componentName)
Create a named component for the attribute.
Definition: RecordView.h:236
virtual void addFunctors(void)=0
Called at instantiation to add functors.
Record createRecord(void)
Create a Record using all the attributes.
Definition: RecordView.h:469
Bindable collection of accessor Functors.
Definition: RecordView.h:106
void bind(const WeakRecord weakRecord, BWORD weak=FALSE)
Associate with a specific WeakRecord.
Definition: RecordView.h:402
Reference to an instance of a Layout.
Definition: RecordSB.h:35
U32 index(void)
Return the current index into the RecordArray.
Definition: RecordView_spRA.h:592
static void saveRecordGroup(sp< Scope > spScope, sp< RecordGroup > &rspRecordGroup, String filename, BWORD a_binary=FALSE)
Save a RecordGroup to a file.
Definition: RecordView.h:665
virtual void initializeRecord(void)
Called at instantiation to initialize attributes.
Definition: RecordView.h:571
void setWeakRecord(const WeakRecord weakRecord)
Associate with a specific WeakRecord.
Definition: RecordView.h:427
bool isValid(void) const
Return true if the record points to the original valid state block.
Definition: WeakRecordSB.h:181
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
const String & name(void) const
Return the components chosen name.
Definition: Component.h:77
static sp< RecordGroup > loadRecordGroupFromBuffer(sp< Scope > spScope, String buffer, BWORD a_binary=FALSE)
Serialize a RecordGroup from a string.
Definition: RecordView.h:638
virtual void finalizeRecord(void)
Called right after instantiation to finalize complex attributes.
Definition: RecordView.h:583
T safeGet(void)
Get the value, checking first.
Definition: RecordView.h:183
virtual void produce(Record &rRecord)
Produce a Record using all the attributes.
Definition: RecordView.h:436
void setName(const String &name)
Rename the component to anything you want.
Definition: Component.h:84
BWORD isValid(void) const
Returns true if the pointer is set.
Definition: Handled.h:179
void bind(const Record record, BWORD weak=FALSE)
Associate with a specific Record.
Definition: RecordView.h:377
T & operator()(const RecordSB &r)
Return the attribute.
Definition: Accessor.h:489
void registerFactory(String name, sp< RecordFactoryI > spRecordFactoryI)
Specify who can produce a named layout.
Definition: Scope.cc:524
void setup(sp< Scope > spScope, const String &attribute)
setup functions setup the accessor and also setup the Scope.
Definition: Accessor.cc:113
sp< Layout > layout(void)
Access a Layout of all the attributes.
Definition: RecordView.h:504
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordSB.h:17