Free Electron
SurfaceAccessorBase.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 __surface_SurfaceAccessorBase_h__
8 #define __surface_SurfaceAccessorBase_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief Common Functionality for Accessor Surface
17 
18  @ingroup surface
19 *//***************************************************************************/
20 class FE_DL_EXPORT SurfaceAccessorBase:
21  virtual public SurfaceAccessorI,
22  public CastableAs<SurfaceAccessorBase>
23 {
24  public:
25  SurfaceAccessorBase(void);
26 virtual ~SurfaceAccessorBase(void);
27 
28  //* as SurfaceAccessorI
29 virtual BWORD writable(void) const { return m_writable; }
30 virtual void setWritable(BWORD a_writable)
31  { m_writable=a_writable; }
32 
33 virtual U32 count(void) const =0;
34 
35 virtual String type(void) const { return m_attrType; }
36 
37 virtual void set(U32 a_index,U32 a_subIndex,String a_string) {}
38 virtual void set(U32 a_index,String a_string)
39  { set(a_index,U32(0),a_string); }
40 
41 virtual void set(U32 a_index,U32 a_subIndex,I32 a_integer) {}
42 virtual void set(U32 a_index,I32 a_integer)
43  { set(a_index,U32(0),a_integer); }
44 
45 virtual I32 duplicate(U32 a_index,U32 a_subIndex=0) { return -1; }
46 
47 virtual I32 append(void)
48  { return append(SurfaceAccessibleI::e_closed); }
49 virtual I32 append(SurfaceAccessibleI::Form a_form) { return -1; }
50 virtual I32 append(I32 a_integer)
51  { return append(a_integer,
52  SurfaceAccessibleI::e_closed); }
53 virtual I32 append(I32 a_integer,SurfaceAccessibleI::Form a_form);
54 virtual void append(U32 index,I32 a_integer) {}
55 virtual void append(Array< Array<I32> >& a_rPrimVerts);
56 
57 virtual void remove(U32 a_index,I32 a_integer=0) {}
58 
59 virtual void set(U32 a_index,U32 a_subIndex,Real a_real) {}
60 virtual void set(U32 a_index,Real a_real)
61  { set(a_index,U32(0),a_real); }
62 
63 virtual void set(U32 a_index,U32 a_subIndex,
64  const SpatialVector& a_vector) {}
65 virtual void set(U32 a_index,const SpatialVector& a_vector)
66  { set(a_index,U32(0),a_vector); }
67 virtual SpatialVector spatialVector(U32 index,U32 subIndex=0)
68  { return SpatialVector(0.0,0.0,0.0); }
69 virtual BWORD spatialVector(SpatialVector* a_pVectorArray,
70  const Vector2i* a_pIndexArray,I32 a_arrayCount);
71 
72 virtual void fragmentWith(SurfaceAccessibleI::Element a_element,
73  String a_attributeName,String a_groupName);
74 virtual U32 fragmentCount(void) const
75  { return m_fragmentMap.size(); }
76 virtual String fragment(U32 a_index) const
77  {
78  return (a_index<m_fragmentList.size())?
79  m_fragmentList[a_index]: "";
80  }
81 virtual BWORD filterWith(String a_filterString,
82  sp<SurfaceAccessibleI::FilterI>& a_rspFilter) const;
83 
84  void setSurfaceAccessible(
85  sp<SurfaceAccessibleI> a_spSurfaceAccessibleI)
86  { m_spSurfaceAccessibleI=a_spSurfaceAccessibleI; }
87 
88 virtual SurfaceAccessibleI::Element element(void) { return m_element; }
89 virtual SurfaceAccessibleI::Attribute attribute(void) { return m_attribute; }
90 
91 virtual String attributeName(void) { return m_attrName; }
92 
93 virtual void appendGroupSpans(
94  SpannedRange::MultiSpan& a_rMultiSpan);
95 
96  protected:
97 
98  BWORD m_writable;
99  SurfaceAccessibleI::Element m_element;
100  SurfaceAccessibleI::Attribute m_attribute;
101  String m_attrName;
102  String m_attrType;
103  sp<SurfaceAccessibleI> m_spSurfaceAccessibleI;
104 
105  private:
106 
107  class Fragment
108  {
109  public:
110  Array<U32> m_indexArray;
111  };
112  class FragmentFilter:
113  virtual public SurfaceAccessibleI::FilterI,
114  public CastableAs<FragmentFilter>
115  {
116  public:
117  FragmentFilter(void) {}
118  virtual ~FragmentFilter(void) {}
119 
120  virtual I32 filterCount(void) const
121  {
122  return m_pFragment?
123  m_pFragment->m_indexArray.size(): -1;
124  }
125  virtual I32 filter(I32 a_filterIndex) const
126  {
127  if(!m_pFragment)
128  {
129  return -1;
130  }
131  const Array<U32>& rIndexArray=
132  m_pFragment->m_indexArray;
133  if(a_filterIndex>=I32(rIndexArray.size()))
134  {
135  return -1;
136  }
137  return rIndexArray[a_filterIndex];
138  }
139 
140  /// @internal
141  void setFragment(const Fragment* a_pFragment)
142  { m_pFragment=a_pFragment; }
143 
144  private:
145  const Fragment* m_pFragment;
146  };
147 
148  AutoHashMap<String,Fragment> m_fragmentMap;
149  Array<String> m_fragmentList;
150 };
151 
152 } /* namespace ext */
153 } /* namespace fe */
154 
155 #endif /* __surface_SurfaceAccessorBase_h__ */
kernel
Definition: namespace.dox:3
Common Functionality for Accessor Surface.
Definition: SurfaceAccessorBase.h:20
view to a reduced set in indices
Definition: SurfaceAccessibleI.h:96
Automatically reference-counted string container.
Definition: String.h:128
Wrapper for std::vector.
Definition: Array.h:21
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Surface Element Handle.
Definition: SurfaceAccessorI.h:27
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192