Free Electron
Recordable.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_Recordable_h__
8 #define __datatool_Recordable_h__
9 
10 FE_ATTRIBUTE("rec:name", "Name of Component");
11 FE_ATTRIBUTE("rec:component", "Instance of Component");
12 
13 namespace fe
14 {
15 namespace ext
16 {
17 
18 /**************************************************************************//**
19  @brief Recordable RecordView
20 
21  @ingroup datatool
22 *//***************************************************************************/
23 class FE_DL_EXPORT Recordable: virtual public RecordView
24 {
25  public:
26  Functor<I32> serial;
27  Functor<String> recordableName;
28  Functor< cp<Component> > component;
29 
30  Recordable(void) { setName("Recordable"); }
31 virtual void addFunctors(void)
32  {
33  add(serial, FE_USE(":SN"));
34  add(recordableName, FE_USE("rec:name"));
35  add(component, FE_USE("rec:component"));
36  }
37 virtual void initializeRecord(void)
38  {
40 
41  component.attribute()->setSerialize(FALSE);
42 
43 // feLog("Recordable::initializeRecord %s\n",name().c_str());
44  }
45 virtual void finalizeRecord(void)
46  {
48 
49 // feLog("Recordable::finalizeRecord %s %s\n",
50 // name().c_str(),recordableName().c_str());
51 
52  if(!recordableName().empty())
53  {
54  component.createAndSetComponent(recordableName());
55  }
56 
57  cp<RecordableI> cpRecordableI=component();
58  if(cpRecordableI.isValid())
59  {
60  Record thisRecord=record();
61  cpRecordableI.writable()->bind(thisRecord);
62  }
63 #if FE_CODEGEN<=FE_DEBUG
64  else
65  {
66  feLog("Recordable::finalizeRecord"
67  " %s isn't RecordableI\n",name().c_str());
68  }
69 #endif
70  }
71 };
72 
73 } /* namespace ext */
74 } /* namespace fe */
75 
76 #endif /* __datatool_Recordable_h__ */
virtual void finalizeRecord(void)
Called right after instantiation to finalize complex attributes.
Definition: Recordable.h:45
kernel
Definition: namespace.dox:3
Bound accessor in a RecordView.
Definition: RecordView.h:147
virtual void addFunctors(void)
Called at instantiation to add functors.
Definition: Recordable.h:31
virtual void initializeRecord(void)
Called at instantiation to initialize attributes.
Definition: Recordable.h:37
sp< Attribute > attribute(void) const
Return the attribute this accessor is for.
Definition: Accessor.cc:151
void createAndSetComponent(String componentName)
Create a named component for the attribute.
Definition: RecordView.h:236
Bindable collection of accessor Functors.
Definition: RecordView.h:106
Reference to an instance of a Layout.
Definition: RecordSB.h:35
virtual void initializeRecord(void)
Called at instantiation to initialize attributes.
Definition: RecordView.h:571
virtual void finalizeRecord(void)
Called right after instantiation to finalize complex attributes.
Definition: RecordView.h:583
Copy-On-Write shared pointer.
Definition: Protectable.h:93
Recordable RecordView.
Definition: Recordable.h:23