Free Electron
OperatorState.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 __operate_OperatorState_h__
8 #define __operate_OperatorState_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief Operator base class to save and reload state
17 
18  @ingroup operate
19 *//***************************************************************************/
20 class FE_DL_EXPORT OperatorState:
21  public OperatorSurfaceCommon,
22  public Initialize<OperatorState>
23 {
24  public:
25 
26  OperatorState(void) {}
27 virtual ~OperatorState(void) {}
28 
29  void initialize(void);
30 
31  //* As OperatorSurfaceI
32 virtual BWORD saveState(String& rBuffer);
33 virtual BWORD loadState(const String& rBuffer);
34 
35 virtual BWORD undo(String a_change,sp<Counted> a_spCounted);
36 virtual BWORD redo(String a_change,sp<Counted> a_spCounted);
37 
38  protected:
39 
40  class FE_DL_EXPORT Pick
41  {
42  public:
43  Pick(void) {}
44  Pick(I32 a_primitiveId,I32 a_subIndex,Real a_weight):
45  m_elementId(a_primitiveId),
46  m_subIndex(a_subIndex),
47  m_weight(a_weight) {}
48  Pick(I32 a_elementId,Real a_weight):
49  m_elementId(a_elementId),
50  m_subIndex(-1),
51  m_weight(a_weight) {}
52 
53  I32 m_elementId;
54  I32 m_subIndex;
55  Real m_weight;
56  };
57 
58 virtual void setupState(void) {}
59 
60  using OperatorSurfaceCommon::anticipate;
61  using OperatorSurfaceCommon::resolve;
62 
63  //* As OperatorSurfaceCommon
64 virtual BWORD anticipate(String a_change,
65  sp<Counted> a_spCounted);
66 virtual BWORD resolve(String a_change,
67  sp<Counted> a_spCounted);
68 
69  BWORD pickToggle(I32 a_elementId);
70  Real picked(I32 a_elementId);
71  void pick(I32 a_primitiveId,I32 a_subIndex,
72  Real a_weight);
73  void pick(I32 a_elementId,Real a_weight);
74 
75  void updateIds(void);
76  I32 lookupIndex(I32 a_id);
77  I32 lookupId(I32 a_elementIndex);
78 
79  sp<Scope> m_spScope;
80  sp<RecordGroup> m_spState;
81  Accessor<I32> m_aIndex;
82  Array<Pick> m_pickArray;
83 
84  private:
85 
86  sp<SurfaceAccessorI> m_spInputIds;
87  std::map<I32,I32> m_elementIndexMap;
88 
89 };
90 
91 } /* namespace ext */
92 } /* namespace fe */
93 
94 #endif /* __operate_OperatorState_h__ */
Operator base class to save and reload state.
Definition: OperatorState.h:20
kernel
Definition: namespace.dox:3
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
Automatically reference-counted string container.
Definition: String.h:128
Partial Generic SurfaceI Implemention.
Definition: OperatorSurfaceCommon.h:20
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53