OMKSessionPrm.h

Go to the documentation of this file.
00001 
00002 /************************************************************************/
00003 /* This file is part of openMask(c) INRIA, CNRS, Universite de Rennes 1 */
00004 /* 1993-2002, thereinafter the Software                                 */
00005 /*                                                                      */
00006 /* The Software has been developped within the Siames Project.          */
00007 /* INRIA, the University of Rennes 1 and CNRS jointly hold intellectual */
00008 /* property rights                                                      */
00009 /*                                                                      */
00010 /* The Software has been registered with the Agence pour la Protection  */
00011 /* des Programmes (APP) under registration number                       */
00012 /* IDDN.FR.001.510008.00.S.P.2001.000.41200                             */
00013 /*                                                                      */
00014 /* This file may be distributed under the terms of the Q Public License */
00015 /* version 1.0 as defined by Trolltech AS of Norway and appearing in    */
00016 /* the file LICENSE.QPL included in the packaging of this file.         */
00017 /*                                                                      */
00018 /* Licensees holding valid specific licenses issued by INRIA, CNRS or   */
00019 /* Universite Rennes 1 for the software may use this file in            */
00020 /* acordance with that specific license                                 */
00021 /************************************************************************/
00022                 
00023 #if !defined _SESSIONPRM_H_
00024 #define _SESSIONPRM_H_
00025 
00026 #include "OMKInteractiveEventId.h"
00027 #include "OMKTracer.h"
00028 #include <map>
00029 #include <vector>
00030 #include "OMKName.h"
00031 namespace OMK  
00032 {
00033   namespace Iii 
00034   {
00035 // Predefined classes
00036     class InteractorExtension ;
00037 
00038 //-----------------------------------------------------------------
00076 class OMKIII_API SessionPrm
00077 {
00078 protected:
00081   SessionPrm( InteractorExtension* owner, const Name& interactiveObject ) ;
00082 public:
00090   static SessionPrm* create( InteractorExtension* owner, const Name& interactiveObject ) ;
00092   virtual ~SessionPrm() ;
00098   virtual bool isInitialized() const { return !_links.empty() ; }
00104   virtual void init( const InteractorOutputsMap& interactorOutputsMap, const Type::AccessibleParametersListPrm& connectors ) ;
00107   const Name& getInteractiveObject() const { return _interactiveObject ; }
00109 
00110 
00111   SessionPrm& c( SessionPrm& (*f)( SessionPrm& ) ) 
00112   {
00113     return (*f)( *this ); 
00114   }
00116   class Functor
00117   {
00118   public:
00119     Functor() {}
00120     virtual ~Functor() {}
00121   protected:
00122     friend class SessionPrm ;
00123     virtual SessionPrm& func( SessionPrm& ) const = 0 ;
00124   } ;
00126   template< class TheFunctor >
00127   SessionPrm& c( const TheFunctor& theFunctor )
00128   {
00129     return theFunctor.func( *this ); 
00130   }
00132   virtual SessionPrm& c( const Name& interactiveObjectId ) 
00133   { 
00134     _ids.push_back( interactiveObjectId ) ;
00135     return *this; 
00136   }
00138 public:
00140 
00141 
00142   enum OutputStates {
00143     EUnknow,           
00144     EIsNotControlled,  
00145     EWaitingForAnswer, 
00146 
00147     EIsUnderControl    
00148   } ;
00153   virtual void addControlledConnector( const Type::ControlTakenOfParameterPrm& prm ) ;
00158   virtual void removeControlledConnector( const Name& id ) ;
00164   std::list< Name > getActiveOutputs() const ;
00167   OutputStates outputState( const Name& id ) const ;
00171   bool isActiveOutput( const Name& id ) const ;
00173 
00174 
00175 
00176   Name getOutputId( const Name& connectorId ) const ;
00177 protected:
00179   struct Link
00180   {
00182     Link( const Name& connectorId, InteractorOutput* output ) 
00183     : _connector( connectorId ), 
00184       _output( output ),
00185       _state( EIsNotControlled )
00186     {
00187       OMASSERTM( output, "Must be a valid pointer" ) ;
00188     }
00190     Name _connector ;
00192     InteractorOutput* _output ;
00194     OutputStates _state;
00195   } ;
00198   std::map< Name, Link > _links ;
00200   Name _interactiveObject ;
00202   InteractorExtension *_owner ;
00204 
00205 
00206 
00207 
00208   std::vector< Name > _ids ;
00211   virtual void selfGetAccessibleParameters() ;
00214   virtual void selfControlTakeOverAndGetCurrentValues() ;
00217   virtual void selfControlRelease() ;
00220   virtual void selfControlFreeze() ;
00223   virtual void selfControlUnfreeze() ;
00225 
00226 
00227 
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00236   inline friend SessionPrm& getAccessibleParameters( SessionPrm & s ) ;
00244   inline friend SessionPrm& controlTakeOverAndGetCurrentValues( SessionPrm & s ) ;
00252   inline friend SessionPrm& controlRelease( SessionPrm & s ) ;
00260   inline friend SessionPrm& controlFreeze( SessionPrm & s ) ;
00268   inline friend SessionPrm& controlUnfreeze( SessionPrm & s ) ;
00270 } ;
00271 //-----------------------------------------------------------------
00272 inline SessionPrm& getAccessibleParameters( SessionPrm & s )
00273 {
00274   s.selfGetAccessibleParameters() ;
00275   return s ;
00276 }
00277 //-----------------------------------------------------------------
00278 inline SessionPrm& controlTakeOverAndGetCurrentValues( SessionPrm & s )
00279 {
00280   s.selfControlTakeOverAndGetCurrentValues() ;
00281   return s ;
00282 }
00283 //-----------------------------------------------------------------
00284 inline SessionPrm& controlRelease( SessionPrm & s )
00285 {
00286   s.selfControlRelease() ;
00287   return s ;
00288 }
00289 //-----------------------------------------------------------------
00290 inline SessionPrm& controlFreeze( SessionPrm & s )
00291 {
00292   s.selfControlFreeze() ;
00293   return s ;
00294 }
00295 //-----------------------------------------------------------------
00296 inline SessionPrm& controlUnfreeze( SessionPrm & s )
00297 {
00298   s.selfControlUnfreeze() ;
00299   return s ;
00300 }
00302 
00303   }// namespace Iii
00304 }// namespace OMK
00305 
00306 #endif // defined _SESSIONPRM_H_

logo OpenMask

Documentation generated on Mon Jun 9 11:45:57 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007