CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
Adapter.h
Go to the documentation of this file.
1//## begin module%3550CCFF0159.cm preserve=no
2// %X% %Q% %Z% %W%
3//## end module%3550CCFF0159.cm
4
5//## Module: Adapter%3550CCFF0159; Package specification
6// Implementation of the Adapter design pattern.
7//## Subsystem: facilities%3550CC6801AC
8//## Source file: D:\code\glastsim\facilities\Adapter.h
9
10#ifndef Adapter_h
11#define Adapter_h 1
12
13//## begin module%3550CCFF0159.declarations preserve=yes
14#ifdef _MSC_VER
15# pragma warning(disable:4503) //'insert' : decorated name length exceeded, name was truncated
16# pragma warning(disable: 4786)
17#endif
18//## end module%3550CCFF0159.declarations
19
20
21//## Class: Adapter%356C83B90323
22// abstract adapter class, just implements the () operator
23// and sets up a structure for the execute() operation.
24//## Category: facilities%3550CC5302A6
25//## Subsystem: facilities%3550CC6801AC
26//## Persistence: Transient
27//## Cardinality/Multiplicity: n
28
29template <class _Ty>
30class Adapter
31{
32 public:
33 //## Constructors (specified)
34 //## Operation: Adapter%896216810
35 // constructor
37 //## begin Adapter::Adapter%896216810.initialization preserve=yes
38 //## end Adapter::Adapter%896216810.initialization
39 {
40 //## begin Adapter::Adapter%896216810.body preserve=yes
41 //## end Adapter::Adapter%896216810.body
42 }
43
44 virtual ~Adapter() {}
45
46
47 //## Other Operations (specified)
48 //## Operation: operator()%896216811
49 // performs the adaptation
50 virtual _Ty operator () (void) = 0;
51
52 protected:
53 private:
54 private: //## implementation
55};
56
57template <class _Ty, class _Arg>
59{
60public:
61 typedef _Arg ArgType;
62 typedef _Ty RetType;
63
65 virtual _Ty operator () (ArgType&) = 0;
66};
67
68
69//## Class: Action%3550D9BD0145; Parameterized Class
70// Action encapsulates a function call to a member function
71// of a specific class. The function call is carried out on
72// a specific instance of that class in the execute method.
73//## Category: facilities%3550CC5302A6
74//## Subsystem: facilities%3550CC6801AC
75//## Persistence: Transient
76//## Cardinality/Multiplicity: n
77
78template <class Actor, class _Ty = int>
79class Action
80{
81 public:
82 //## Class: ActionFunction%3550DA45030E
83 //## Category: <Top Level>
84 //## Subsystem: facilities%3550CC6801AC
85 //## Persistence: Transient
86 //## Cardinality/Multiplicity: n
87
88 typedef _Ty (Actor::* ActionFunction) ();
89
90 public:
91 //## Constructors (specified)
93 : itsFunction(anAction)
94 {
95 }
96
97
98 //## Other Operations (specified)
99 // executes the action function using anInstance, returning
100 // the value returned by the function.
101 _Ty execute (Actor* anActor)
102 {
103 //## begin Action::execute%894312582.body preserve=yes
104 return (anActor->*itsFunction)();
105 //## end Action::execute%894312582.body
106 }
107
108 protected:
109 private:
110 private: //## implementation
111 // Data Members for Associations
112
113 //## Association: facilities::<unnamed>%3550DD290286
114 //## Role: Action::itsFunction%3550DD2A00E2
115 // function to execute when called.
116 //## begin Action::itsFunction%3550DD2A00E2.role preserve=no public: Action< Actor,_Ty >::ActionFunction { -> VHN}
117 ActionFunction itsFunction;
118 //## end Action::itsFunction%3550DD2A00E2.role
119
120};
121
122//## Class: ActionAdapter%3550CDFE0051; Parameterized Class
123// Adapter template class.
124//
125// Bridges the interface of one class into another while
126// presenting a generic interface to clients. Adapter
127// allows classes to work together without explicit
128// relationships between those classes.
129//## Category: facilities%3550CC5302A6
130//## Subsystem: facilities%3550CC6801AC
131//## Persistence: Transient
132//## Cardinality/Multiplicity: n
133
134template <class Adaptee, class _Ty = int>
135class ActionAdapter : public Adapter<_Ty> //## Inherits: <unnamed>%356C83DF01AB
136{
137 public:
138 //## Constructors (specified)
139 //## Operation: ActionAdapter%894312583
140 // constructor
141 ActionAdapter (Adaptee* anAdaptee, Action<Adaptee,_Ty> anAction)
142 //## begin ActionAdapter::ActionAdapter%894312583.initialization preserve=yes
143 : itsAdaptee(anAdaptee), itsAction(anAction)
144 //## end ActionAdapter::ActionAdapter%894312583.initialization
145 {
146 //## begin ActionAdapter::ActionAdapter%894312583.body preserve=yes
147 //## end ActionAdapter::ActionAdapter%894312583.body
148 }
149
150
151 //## Other Operations (specified)
152 //## Operation: operator()%894312584
153 // performs the adaptation
154 virtual _Ty operator () ()
155 {
156 //## begin ActionAdapter::operator()%894312584.body preserve=yes
157 return itsAction.execute(itsAdaptee);
158 //## end ActionAdapter::operator()%894312584.body
159 }
160
161 protected:
162 private:
163 private: //## implementation
164 // Data Members for Class Attributes
165
166 //## Attribute: itsAdaptee%3550CEC300AF
167 // object for which this adapter provides an interface
168 //## begin ActionAdapter::itsAdaptee%3550CEC300AF.attr preserve=no private: Adaptee* {U}
169 Adaptee* itsAdaptee;
170 //## end ActionAdapter::itsAdaptee%3550CEC300AF.attr
171
172 // Data Members for Associations
173
174 //## Association: facilities::<unnamed>%3550DB4401A2
175 //## Role: ActionAdapter::itsAction%3550DB45006D
176 // action to be performed when the Adapter executes
177 //## begin ActionAdapter::itsAction%3550DB45006D.role preserve=no private: Action { -> VHN}
178 Action<Adaptee, _Ty> itsAction;
179 //## end ActionAdapter::itsAction%3550DB45006D.role
180
181};
182
183#endif
ActionAdapter(Adaptee *anAdaptee, Action< Adaptee, _Ty > anAction)
Definition: Adapter.h:141
virtual _Ty operator()()
Definition: Adapter.h:154
Definition: Adapter.h:80
_Ty(Actor::* ActionFunction)()
Definition: Adapter.h:88
_Ty execute(Actor *anActor)
Definition: Adapter.h:101
Action(ActionFunction anAction)
Definition: Adapter.h:92
virtual ~Adapter()
Definition: Adapter.h:44
Adapter()
Definition: Adapter.h:36
virtual _Ty operator()(void)=0
virtual _Ty operator()(ArgType &)=0
_Arg ArgType
Definition: Adapter.h:61
ArgAdapter()
Definition: Adapter.h:64
_Ty RetType
Definition: Adapter.h:62