Free Electron
FunctionI.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 __evaluator_FunctionI_h__
8 #define __evaluator_FunctionI_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /// A bundling of src/data type into a concrete notion
16 class FE_DL_EXPORT Aggregate : public Counted, CastableAs<Aggregate>
17 {
18  public:
19  Aggregate(void);
20 virtual ~Aggregate(void);
21 
22  void bakeTypes(sp< AccessorSet > a_as, sp< Layout > a_layout)
23  {
24  m_spLayout = a_layout;
25  m_spAS = a_as;
26  m_spAS->populate(a_layout);
27  bakeTypes();
28  }
29  void bakeTypes(void)
30  {
31  unsigned int i_as = m_spAS->size();
32  m_types.resize(i_as);
33  m_BAs.resize(i_as);
34  for(unsigned int i_a = 0; i_a < i_as ; i_a++)
35  {
36  m_BAs[i_a] = (*(m_spAS))[i_a];
37  m_types[i_a] = m_BAs[i_a]->attribute()->type();
38  }
39  }
40 
41  void assign(Record &r_dst, const Record &r_src)
42  {
43  unsigned int i_as = m_types.size();
44  for(unsigned int i_a = 0; i_a < i_as ; i_a++)
45  {
46  BaseAccessor *pBA = m_BAs[i_a];
47  void *dst = r_dst.rawAttribute(pBA->index());
48  void *src = r_src.rawAttribute(pBA->index());
49  m_types[i_a]->assign(dst, src);
50  }
51  }
52 
53  void asUnion(sp< Aggregate > a_other)
54  {
55  m_types.clear();
56  m_BAs.clear();
57 
58  unsigned int i_as = a_other->m_spAS->size();
59  for(unsigned int i_a = 0; i_a < i_as ; i_a++)
60  {
61  BaseAccessor *pBA = a_other->m_BAs[i_a];
62  if( m_spLayout->checkAttribute(pBA->index()) )
63  {
64  m_BAs.push_back(pBA);
65  m_types.push_back(pBA->attribute()->type());
66  }
67  }
68  }
69 
70  sp< Layout > m_spLayout;
71 
72  private:
73  sp< AccessorSet > m_spAS;
74  t_stdvector< sp<BaseType> > m_types;
75  t_stdvector< BaseAccessor * > m_BAs;
76 };
77 
78 
79 /// Interface to add functions to an Evaluator
80 class FE_DL_EXPORT FunctionI: virtual public Component,
81  public CastableAs<FunctionI>
82 {
83  public:
84 virtual bool compile(sp<RecordGroup>, Record &,
85  t_stdvector<WeakRecord> &, t_stdstring &) = 0;
86 virtual void eval(Record &, t_stdvector<WeakRecord> &) = 0;
87 virtual sp<Aggregate> &returnType(void) = 0;
88 };
89 
90 } /* namespace ext */
91 } /* namespace fe */
92 
93 #endif
94 
Heap-based support for classes participating in fe::ptr <>
Definition: Counted.h:35
Interface to add functions to an Evaluator.
Definition: FunctionI.h:80
kernel
Definition: namespace.dox:3
Type inspecific Accessor.
Definition: Accessor.h:26
A bundling of src/data type into a concrete notion.
Definition: FunctionI.h:16
sp< Attribute > attribute(void) const
Return the attribute this accessor is for.
Definition: Accessor.cc:151
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Base for all interfacable components.
Definition: Component.h:20
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192