/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Calibration/facilities/facilities-00-00-04/facilities/Adapter.h

Go to the documentation of this file.
00001 //## begin module%3550CCFF0159.cm preserve=no
00002 //        %X% %Q% %Z% %W%
00003 //## end module%3550CCFF0159.cm
00004 
00005 //## Module: Adapter%3550CCFF0159; Package specification
00006 //      Implementation of the Adapter design pattern.
00007 //## Subsystem: facilities%3550CC6801AC
00008 //## Source file: D:\code\glastsim\facilities\Adapter.h
00009 
00010 #ifndef Adapter_h
00011 #define Adapter_h 1
00012 
00013 //## begin module%3550CCFF0159.declarations preserve=yes
00014 #ifdef _MSC_VER
00015 # pragma warning(disable:4503) //'insert' : decorated name length exceeded, name was truncated
00016 # pragma warning(disable: 4786)
00017 #endif
00018 //## end module%3550CCFF0159.declarations
00019 
00020 
00021 //## Class: Adapter%356C83B90323
00022 //      abstract adapter class, just implements the () operator
00023 //      and sets up a structure for the execute() operation.
00024 //## Category: facilities%3550CC5302A6
00025 //## Subsystem: facilities%3550CC6801AC
00026 //## Persistence: Transient
00027 //## Cardinality/Multiplicity: n
00028 
00029 template <class _Ty>
00030 class Adapter 
00031 {
00032   public:
00033     //## Constructors (specified)
00034       //## Operation: Adapter%896216810
00035       //        constructor
00036       Adapter ()
00037         //## begin Adapter::Adapter%896216810.initialization preserve=yes
00038         //## end Adapter::Adapter%896216810.initialization
00039       {
00040         //## begin Adapter::Adapter%896216810.body preserve=yes
00041         //## end Adapter::Adapter%896216810.body
00042       }
00043 
00044       virtual ~Adapter() {}
00045 
00046 
00047     //## Other Operations (specified)
00048       //## Operation: operator()%896216811
00049       //        performs the adaptation
00050       virtual _Ty operator () (void) = 0;
00051 
00052   protected:
00053   private:
00054   private:  //## implementation
00055 };
00056 
00057 template <class _Ty, class _Arg>
00058 class ArgAdapter
00059 {
00060 public:
00061     typedef     _Arg ArgType;
00062     typedef _Ty RetType;
00063     
00064     ArgAdapter() {}
00065     virtual _Ty operator () (ArgType&) = 0;
00066 };
00067 
00068 
00069 //## Class: Action%3550D9BD0145; Parameterized Class
00070 //      Action encapsulates a function call to a member function
00071 //      of a specific class. The function call is carried out on
00072 //      a specific instance of that class in the execute method.
00073 //## Category: facilities%3550CC5302A6
00074 //## Subsystem: facilities%3550CC6801AC
00075 //## Persistence: Transient
00076 //## Cardinality/Multiplicity: n
00077 
00078 template <class Actor, class _Ty = int>
00079 class Action 
00080 {
00081   public:
00082     //## Class: ActionFunction%3550DA45030E
00083     //## Category: <Top Level>
00084     //## Subsystem: facilities%3550CC6801AC
00085     //## Persistence: Transient
00086     //## Cardinality/Multiplicity: n
00087 
00088     typedef _Ty  (Actor::* ActionFunction) ();
00089 
00090   public:
00091     //## Constructors (specified)
00092       Action (ActionFunction anAction)
00093         : itsFunction(anAction)
00094       {
00095       }
00096 
00097 
00098     //## Other Operations (specified)
00099       //        executes the action function using anInstance, returning
00100       //        the value returned by the function.
00101       _Ty execute (Actor* anActor)
00102       {
00103         //## begin Action::execute%894312582.body preserve=yes
00104           return (anActor->*itsFunction)();
00105         //## end Action::execute%894312582.body
00106       }
00107 
00108   protected:
00109   private:
00110   private:  //## implementation
00111     // Data Members for Associations
00112 
00113       //## Association: facilities::<unnamed>%3550DD290286
00114       //## Role: Action::itsFunction%3550DD2A00E2
00115       //        function to execute when called.
00116       //## begin Action::itsFunction%3550DD2A00E2.role preserve=no  public: Action< Actor,_Ty >::ActionFunction { -> VHN}
00117       ActionFunction itsFunction;
00118       //## end Action::itsFunction%3550DD2A00E2.role
00119 
00120 };
00121 
00122 //## Class: ActionAdapter%3550CDFE0051; Parameterized Class
00123 //      Adapter template class.
00124 //
00125 //      Bridges the interface of one class into another while
00126 //      presenting a generic interface to clients. Adapter
00127 //      allows classes to work together without explicit
00128 //      relationships between those classes.
00129 //## Category: facilities%3550CC5302A6
00130 //## Subsystem: facilities%3550CC6801AC
00131 //## Persistence: Transient
00132 //## Cardinality/Multiplicity: n
00133 
00134 template <class Adaptee, class _Ty = int>
00135 class ActionAdapter : public Adapter<_Ty>  //## Inherits: <unnamed>%356C83DF01AB
00136 {
00137   public:
00138     //## Constructors (specified)
00139       //## Operation: ActionAdapter%894312583
00140       //        constructor
00141       ActionAdapter (Adaptee* anAdaptee, Action<Adaptee,_Ty> anAction)
00142         //## begin ActionAdapter::ActionAdapter%894312583.initialization preserve=yes
00143         : itsAdaptee(anAdaptee), itsAction(anAction)
00144         //## end ActionAdapter::ActionAdapter%894312583.initialization
00145       {
00146         //## begin ActionAdapter::ActionAdapter%894312583.body preserve=yes
00147         //## end ActionAdapter::ActionAdapter%894312583.body
00148       }
00149 
00150 
00151     //## Other Operations (specified)
00152       //## Operation: operator()%894312584
00153       //        performs the adaptation
00154       virtual _Ty operator () ()
00155       {
00156         //## begin ActionAdapter::operator()%894312584.body preserve=yes
00157         return itsAction.execute(itsAdaptee);
00158         //## end ActionAdapter::operator()%894312584.body
00159       }
00160 
00161   protected:
00162   private:
00163   private:  //## implementation
00164     // Data Members for Class Attributes
00165 
00166       //## Attribute: itsAdaptee%3550CEC300AF
00167       //        object for which this adapter provides an interface
00168       //## begin ActionAdapter::itsAdaptee%3550CEC300AF.attr preserve=no  private: Adaptee* {U} 
00169       Adaptee* itsAdaptee;
00170       //## end ActionAdapter::itsAdaptee%3550CEC300AF.attr
00171 
00172     // Data Members for Associations
00173 
00174       //## Association: facilities::<unnamed>%3550DB4401A2
00175       //## Role: ActionAdapter::itsAction%3550DB45006D
00176       //        action to be performed when the Adapter executes
00177       //## begin ActionAdapter::itsAction%3550DB45006D.role preserve=no  private: Action { -> VHN}
00178       Action<Adaptee, _Ty> itsAction;
00179       //## end ActionAdapter::itsAction%3550DB45006D.role
00180 
00181 };
00182 
00183 #endif

Generated on Tue Nov 29 22:57:55 2016 for BOSS_7.0.2 by  doxygen 1.4.7