OMKInteractorOutputT.inl

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 _INTERACTOROUTPUTS_INL_
00024 #define _INTERACTOROUTPUTS_INL_
00025 
00026 #include "OMKInteractorOutputT.h"
00027 #include "OMKAttribute.h"
00028 #include "OMKInteractorExtension.h"
00029 #include "OMKSessionPrm.h"
00030 namespace OMK  
00031 {
00032 namespace Iii 
00033 {
00034 //=============================================================================
00035 template< typename PrmType, typename ModelType >
00036 InteractorOutputT< PrmType, ModelType >::InteractorOutputT( const Name& id, const Name& attributeId, 
00037                                                             InteractorExtension *interactor, const Name& category, 
00038                                                             bool setByEvent ) 
00039 : InteractorOutput( id, interactor, category, typeid( PrmType ).name() ),
00040   _attribute( interactor->getOwner()->getBaseAttribute< PrmType >( attributeId ) ),
00041   _listener( 0 )
00042 {
00043   OMASSERTM( _attribute, "The attribute \"" << attributeId << "\" cannot be found, wrong type or wrong id!" ) ;
00044   if( setByEvent )
00045   {
00046     _listener = new IdAndValueEventListener
00047         ( *_interactor->getOwner(), this, 
00048         ( typename IdAndValueEventListener::CallBackFct)&InteractorOutputT< PrmType, ModelType >::processSetValue,
00049         EventId::CURRENT_VALUE ) ;
00050   }
00051 }
00052 //-----------------------------------------------------------------------------
00053 template< typename PrmType, typename ModelType >
00054 InteractorOutputT< PrmType, ModelType >::~InteractorOutputT()
00055 {
00056   delete _listener ;
00057 }
00058 //-----------------------------------------------------------------------------
00059 template< typename PrmType, typename ModelType >
00060 bool InteractorOutputT< PrmType, ModelType >::processSetValue( IdAndValueEvent *e ) 
00061 {
00062   bool ok = false ;
00063   const IdAndValuePrm& prm = e->value.getValue() ;
00064   SessionPrm* session = _interactor->getSessionWith( e->sender ) ;
00065   if( session 
00066    && session->getOutputId( prm.first ) == _attribute->getId() ) 
00067   {
00068     _attribute->set( prm.second ) ;
00069     _interactor->getOwner()->sendValuedEvent( e->sender, 
00070                                               EventId::NEW_VALUE_AVAILABLE, 
00071                                               Type::NewValueAvailableType( Type::NewValueAvailablePrm( prm.first, _attribute->getId() ) ) ) ;
00072     ok = true ;
00073   }
00074   return ok ;
00075 }
00076 
00077 //=============================================================================
00078 
00079 }// namespace Iii
00080 }// namespace OMK
00081 
00082 #endif // defined _INTERACTOROUTPUTS_INL_

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007