Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

at_twin_basic.h

Go to the documentation of this file.
00001 //
00002 // The Austria library is copyright (c) Gianni Mariani 2004.
00003 // 
00004 // Grant Of License.  Grants to LICENSEE the non-exclusive right to use the Austria
00005 // library subject to the terms of the LGPL.
00006 // 
00007 // A copy of the license is available in this directory or one may be found at this URL:
00008 //      http://www.gnu.org/copyleft/lesser.txt
00009 // 
00015 #ifndef x_at_twin_basic_h_x
00016 #define x_at_twin_basic_h_x 1
00017 
00018 #include "at_exports.h"
00019 #include "at_twin.h"
00020 #include "at_assert.h"
00021 
00022 // Austria namespace
00023 namespace at
00024 {
00025 
00045 // ======== AppLeadTwin_EmptyTraits =====================================
00052 template<
00053         typename        w_aide_twin_interface,
00054         typename        w_lead_interface
00055 >
00056 class AppLeadTwin_EmptyTraits
00057 {
00058         public:
00059 
00060         typedef LeadTwin< w_aide_twin_interface, w_lead_interface >     t_LeadTwinInterface;
00061 
00062 
00063         // ======== AppLeadCompletedNotify ================================
00071         static inline void AppLeadCompletedNotify( t_LeadTwinInterface * i_lead )
00072         {
00073                 //
00074                 // DO NOTHING HERE : the EmptyTraits version does not
00075                 // inform an application.
00076                 //
00077 
00078                 return;
00079                 
00080         } // end AppLeadCompletedNotify 
00081 
00082 };
00083 
00084 
00085 // ======== AppLeadTwin_ForwardTraits =====================================
00092 template<
00093         typename        w_aide_twin_interface,
00094         typename        w_lead_interface
00095 >
00096 class AppLeadTwin_ForwardTraits
00097 {
00098         public:
00099 
00100         // ======== t_LeadTwinInterface ===================================
00107         class t_LeadTwinInterface
00108           : public LeadTwin< w_aide_twin_interface, w_lead_interface >
00109         {
00110                 public:
00111 
00112                 // ======== AppLeadCompleted ==================================
00126                 virtual void AppLeadCompleted( TwinTraits::TwinCode i_competion_code )
00127         {
00128             
00129         }
00130 
00131         };
00132 
00133         // ======== AppLeadCompletedNotify ================================
00142         static inline void AppLeadCompletedNotify(
00143                 t_LeadTwinInterface                                                       * i_lead,
00144                 TwinTraits::TwinCode                                                    i_competion_code
00145         ) {
00146 
00147                 i_lead->AppLeadCompleted( i_competion_code );
00148 
00149                 return;
00150 
00151         } // end AppLeadCompletedNotify 
00152 
00153 };
00154 
00155 
00156 
00157 // ======== LeadTwin_Basic =========================================
00164 template<
00165         typename        w_aide_twin_interface,
00166         typename        w_lead_interface,
00167         typename        w_app_lead_twin_interface = AppLeadTwin_ForwardTraits< w_aide_twin_interface, w_lead_interface >
00168 >
00169 class LeadTwin_Basic
00170   : public w_app_lead_twin_interface::t_LeadTwinInterface
00171 {
00172 public:
00173         typedef w_aide_twin_interface                           * t_AidePointer;
00174         
00175 private:
00176         // ======== LeadBasicCancel =======================================
00184         inline void LeadBasicCancel()
00185         {
00186                 w_aide_twin_interface                                   * l_aide( m_aide );
00187 
00188                 if ( l_aide != 0 )
00189                 {
00190                         //
00191                         // Before cacellation is done, the aide pointer
00192                         // must be removed.
00193                         //
00194                         m_aide = 0;
00195 
00196                         l_aide->AideCancel();
00197                 }
00198 
00199                 return;
00200                 
00201         } // end LeadBasicCancel
00202 
00203         public:
00204 
00205         //
00206         // described in LeadTwin
00207         //
00208         virtual bool LeadAssociate( w_aide_twin_interface * i_aide )
00209         {
00210                 LeadBasicCancel();
00211 
00212                 AT_Assert( m_aide == 0 );
00213 
00214                 m_aide = i_aide;
00215 
00216                 return true;
00217         }
00218 
00219         //
00220         // described in LeadTwin - to be called ONLY from
00221         // Aide when completed.
00222         //
00223         virtual void LeadCompleted( TwinTraits::TwinCode i_competion_code )
00224         {
00225                 //
00226                 // 
00227                 m_aide = 0;
00228 
00229                 //
00230                 // perform application specific notification
00231                 w_app_lead_twin_interface::AppLeadCompletedNotify( this, i_competion_code );
00232         }
00233 
00234 
00235         //
00236         // described in LeadTwin
00237         //
00238         virtual void LeadCancel()
00239         {
00240                 LeadBasicCancel();
00241         }
00242 
00243 
00248         LeadTwin_Basic()
00249           : m_aide( 0 )
00250         {
00251         }
00252 
00257         ~LeadTwin_Basic()
00258         {
00259         // calling LeadBasicCancel here is the same as
00260         // calling LeadCancel.
00261         LeadBasicCancel();
00262         }
00263 
00264 
00265         // ======== GetAide ===============================================
00274         inline void GetAide( t_AidePointer & o_aide_ptr )
00275         {
00276                 o_aide_ptr = m_aide;
00277 
00278         } // end GetAide
00279 
00280         protected:
00281         t_AidePointer                                                             m_aide;
00282 
00283 };
00284 
00285 
00286 
00287 // ======== AppAideTwinTraits_EmptyTraits ==========================
00293 template<
00294         typename        w_aide_twin_interface
00295 >
00296 class AppAideTwinTraits_EmptyTraits
00297 {
00298         public:
00299 
00300         typedef w_aide_twin_interface                                   t_AideTwinInterface;
00301 
00302 
00303 
00304         // ======== AppAideCloseNotify_Internal ==============================
00313         inline static void AppAideCloseNotify_Internal(
00314                 t_AideTwinInterface             * i_aide_ptr,
00315                 TwinTraits::TwinCode              i_competion_code
00316         ) {
00317 
00318                 //
00319                 // EmptyTraits does no notifications
00320                 //
00321 
00322                 return;
00323 
00324         } // end AppAideCloseNotify
00325 
00326         
00327 
00328 };
00329 
00330 
00331 // ======== AppAideTwinTraits_ForwardTraits ==========================
00337 template<
00338         typename        w_aide_twin_interface
00339 >
00340 class AppAideTwinTraits_ForwardTraits
00341 {
00342         public:
00343 
00344 
00345     // ======== t_AideTwinInterface ===================================
00352     class t_AideTwinInterface
00353       : public w_aide_twin_interface
00354     {
00355         public:
00356         
00357         // ======== AppAideCloseNotify ======================================
00366         virtual void    AppAideCloseNotify(
00367             TwinTraits::TwinCode              i_competion_code
00368         ) {
00369         }
00370 
00371     };
00372 
00373         // ======== AppAideCloseNotify_Internal =============================
00383         inline static void AppAideCloseNotify_Internal(
00384                 t_AideTwinInterface             * i_aide_ptr,
00385                 TwinTraits::TwinCode              i_competion_code
00386         ) {
00387 
00388         i_aide_ptr->AppAideCloseNotify( i_competion_code );
00389 
00390                 return;
00391 
00392         } // end AppAideCloseNotify
00393 
00394         
00395 
00396 };
00397 
00398 
00399 // ======== AideTwin_Basic =========================================
00406 template<
00407         typename        w_aide_interface,
00408         typename        w_lead_interface,
00409         typename        w_app_aide_twin_traits = AppAideTwinTraits_ForwardTraits< AideTwin<w_aide_interface> >,
00410         typename        w_lead_twin_interface = LeadTwin<
00411                 AideTwin<w_aide_interface>,
00412                 w_lead_interface
00413         >
00414 >
00415 class AideTwin_Basic
00416   : public w_app_aide_twin_traits::t_AideTwinInterface
00417 {
00418         public:
00419 
00420         typedef w_lead_twin_interface                                      * t_LeadPointer;
00421 
00422         ~AideTwin_Basic()
00423         {
00424                 AideClose( TwinTraits::AideDelete );
00425         }
00426 
00427 
00428         // ======== AideAssociate =========================================
00437         void    AideAssociate(
00438                 t_LeadPointer                                                                     i_lead
00439         )
00440         {
00441                 AideClose( TwinTraits::AideGrabbed );
00442 
00443                 m_lead = i_lead;
00444 
00445                 WrapLeadAssociate( i_lead );
00446 
00447                 return;
00448 
00449         } // end AideAssociate
00450 
00451         
00452 
00453         // ======== AideClose =============================================
00461         void    AideClose(
00462                 TwinTraits::TwinCode i_competion_code
00463         )
00464         {
00465                 t_LeadPointer                   l_lead = m_lead;
00466 
00467                 if ( l_lead != 0 )
00468                 {
00469                         m_lead = 0;
00470                         w_app_aide_twin_traits::AppAideCloseNotify_Internal( this, i_competion_code );
00471                         
00472                         WrapLeadCompleted( l_lead, i_competion_code );
00473                 }
00474 
00475                 return;
00476 
00477         } // end AideClose
00478         
00479         //
00480         // defined in AideTwin
00481         // 
00482         virtual void AideCancel()
00483         {
00484 
00485                 AideClose( TwinTraits::CancelRequested );
00486         }
00487 
00488         inline void GetLead( t_LeadPointer & o_lead_ptr )
00489         {
00490                 o_lead_ptr = m_lead;
00491         }
00492 
00493         AideTwin_Basic()
00494           : m_lead( 0 )
00495         {
00496         }
00497 
00498         protected:
00499 
00500         t_LeadPointer                                                                           m_lead;
00501 
00502 };
00503 
00504 
00505 
00506 // ======== NotifyLeadInterface ====================================
00514 class NotifyLeadInterface
00515 {
00516         protected:
00517 
00518         virtual ~NotifyLeadInterface() {}
00519         
00520         public:
00521 
00522 
00523         // ======== Notify ================================================
00531         virtual void Notify( int i_code ) = 0;
00532 };
00533 
00534 
00535 
00536 // ======== NullTwinInterface ======================================
00542 class NullTwinInterface
00543 {
00544         protected:
00545 
00546         virtual ~NullTwinInterface() {}
00547 
00548 };
00549 
00550 }; // namespace
00551 
00552 #endif // x_at_twin_basic_h_x
00553 
00554 

Generated for Austria by doxygen and MakeXS at Sun Oct 24 17:35:34 PDT 2004