BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Calibration/facilities/include/facilities/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
16 // truncated
17# pragma warning( disable : 4786 )
18#endif
19// ## end module%3550CCFF0159.declarations
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> class Adapter {
30public:
31 // ## Constructors (specified)
32 // ## Operation: Adapter%896216810
33 // constructor
35 // ## begin Adapter::Adapter%896216810.initialization preserve=yes
36 // ## end Adapter::Adapter%896216810.initialization
37 {
38 // ## begin Adapter::Adapter%896216810.body preserve=yes
39 // ## end Adapter::Adapter%896216810.body
40 }
41
42 virtual ~Adapter() {}
43
44 // ## Other Operations (specified)
45 // ## Operation: operator()%896216811
46 // performs the adaptation
47 virtual _Ty operator()( void ) = 0;
48
49protected:
50private:
51private: // ## implementation
52};
53
54template <class _Ty, class _Arg> class ArgAdapter {
55public:
56 typedef _Arg ArgType;
57 typedef _Ty RetType;
58
60 virtual _Ty operator()( ArgType& ) = 0;
61};
62
63// ## Class: Action%3550D9BD0145; Parameterized Class
64// Action encapsulates a function call to a member function
65// of a specific class. The function call is carried out on
66// a specific instance of that class in the execute method.
67// ## Category: facilities%3550CC5302A6
68// ## Subsystem: facilities%3550CC6801AC
69// ## Persistence: Transient
70// ## Cardinality/Multiplicity: n
71
72template <class Actor, class _Ty = int> class Action {
73public:
74 // ## Class: ActionFunction%3550DA45030E
75 // ## Category: <Top Level>
76 // ## Subsystem: facilities%3550CC6801AC
77 // ## Persistence: Transient
78 // ## Cardinality/Multiplicity: n
79
80 typedef _Ty ( Actor::*ActionFunction )();
81
82public:
83 // ## Constructors (specified)
84 Action( ActionFunction anAction ) : itsFunction( anAction ) {}
85
86 // ## Other Operations (specified)
87 // executes the action function using anInstance, returning
88 // the value returned by the function.
89 _Ty execute( Actor* anActor ) {
90 // ## begin Action::execute%894312582.body preserve=yes
91 return ( anActor->*itsFunction )();
92 // ## end Action::execute%894312582.body
93 }
94
95protected:
96private:
97private: // ## implementation
98 // Data Members for Associations
99 // ## Association: facilities::<unnamed>%3550DD290286
100 // ## Role: Action::itsFunction%3550DD2A00E2
101 // function to execute when called.
102 // ## begin Action::itsFunction%3550DD2A00E2.role preserve=no public: Action< Actor,_Ty
103 // >::ActionFunction { -> VHN}
104 ActionFunction itsFunction;
105 // ## end Action::itsFunction%3550DD2A00E2.role
106};
107
108// ## Class: ActionAdapter%3550CDFE0051; Parameterized Class
109// Adapter template class.
110//
111// Bridges the interface of one class into another while
112// presenting a generic interface to clients. Adapter
113// allows classes to work together without explicit
114// relationships between those classes.
115// ## Category: facilities%3550CC5302A6
116// ## Subsystem: facilities%3550CC6801AC
117// ## Persistence: Transient
118// ## Cardinality/Multiplicity: n
119
120template <class Adaptee, class _Ty = int>
121class ActionAdapter : public Adapter<_Ty> // ## Inherits: <unnamed>%356C83DF01AB
122{
123public:
124 // ## Constructors (specified)
125 // ## Operation: ActionAdapter%894312583
126 // constructor
127 ActionAdapter( Adaptee* anAdaptee, Action<Adaptee, _Ty> anAction )
128 // ## begin ActionAdapter::ActionAdapter%894312583.initialization preserve=yes
129 : itsAdaptee( anAdaptee )
130 , itsAction( anAction )
131 // ## end ActionAdapter::ActionAdapter%894312583.initialization
132 {
133 // ## begin ActionAdapter::ActionAdapter%894312583.body preserve=yes
134 // ## end ActionAdapter::ActionAdapter%894312583.body
135 }
136
137 // ## Other Operations (specified)
138 // ## Operation: operator()%894312584
139 // performs the adaptation
140 virtual _Ty operator()() {
141 // ## begin ActionAdapter::operator()%894312584.body preserve=yes
142 return itsAction.execute( itsAdaptee );
143 // ## end ActionAdapter::operator()%894312584.body
144 }
145
146protected:
147private:
148private: // ## implementation
149 // Data Members for Class Attributes
150 // ## Attribute: itsAdaptee%3550CEC300AF
151 // object for which this adapter provides an interface
152 // ## begin ActionAdapter::itsAdaptee%3550CEC300AF.attr preserve=no private: Adaptee* {U}
153 Adaptee* itsAdaptee;
154 // ## end ActionAdapter::itsAdaptee%3550CEC300AF.attr
155
156 // Data Members for Associations
157
158 // ## Association: facilities::<unnamed>%3550DB4401A2
159 // ## Role: ActionAdapter::itsAction%3550DB45006D
160 // action to be performed when the Adapter executes
161 // ## begin ActionAdapter::itsAction%3550DB45006D.role preserve=no private: Action { -> VHN}
162 Action<Adaptee, _Ty> itsAction;
163 // ## end ActionAdapter::itsAction%3550DB45006D.role
164};
165
166#endif
ActionAdapter(Adaptee *anAdaptee, Action< Adaptee, _Ty > anAction)
virtual _Ty operator()(void)=0
virtual _Ty operator()(ArgType &)=0