OMKNotAttributeExtension.cpp

Go to the documentation of this file.
00001 /************************************************************************/
00002 /* This file is part of openMask(c) INRIA, CNRS, Universite de Rennes 1 */
00003 /* 1993-2002, thereinafter the Software                                 */
00004 /*                                                                      */
00005 /* The Software has been developped within the Siames Project.          */
00006 /* INRIA, the University of Rennes 1 and CNRS jointly hold intellectual */
00007 /* property rights                                                      */
00008 /*                                                                      */
00009 /* The Software has been registered with the Agence pour la Protection  */
00010 /* des Programmes (APP) under registration number                       */
00011 /* IDDN.FR.001.510008.00.S.P.2001.000.41200                             */
00012 /*                                                                      */
00013 /* This file may be distributed under the terms of the Q Public License */
00014 /* version 1.0 as defined by Trolltech AS of Norway and appearing in    */
00015 /* the file LICENSE.QPL included in the packaging of this file.         */
00016 /*                                                                      */
00017 /* Licensees holding valid specific licenses issued by INRIA, CNRS or   */
00018 /* Universite Rennes 1 for the software may use this file in            */
00019 /* acordance with that specific license                                 */
00020 /************************************************************************/
00021 #include "OMKNotAttributeExtension.h"
00022 #include "OMKParametersAccessor.inl"
00023 
00024 using namespace OMK ;
00025 using namespace OMK::Type ;
00026 
00027 //=============================================================================
00028 REGISTER_EXTENSION_FACTORY( NotAttributeExtension, "NotAttribute" ) ;
00029 //-----------------------------------------------------------------------------
00030 NotAttributeExtension::NotAttributeExtension(
00031   OMK::ExtensibleSimulatedObject* owner,
00032   const Name& id,
00033   bool registerExtension ) 
00034 : ExtensionT< ExtensibleSimulatedObject >( owner, id, registerExtension ),
00035   _attributeAccessor( 0 )
00036 {
00037   bool ok = true ;
00038   const ConfigurationParameterDescriptor* node = 0 ;
00039   ok = ok && ParametersAccessor::get(
00040     owner->getObjectDescriptor().getExtensionsParameters(), id.getString(), node ) ;
00041   Name attributeName ;
00042   ok = ok && ParametersAccessor::get( node, "AttributeId", attributeName ) ;
00043   _attributeAccessor = ok ? _owner->getBaseAttribute< bool >( attributeName ) : 0 ;
00044   ok = _attributeAccessor != 0 ;
00045   bool output = false ;
00046   ParametersAccessor::get( node, "Output", output ) ;
00047   if( !ok )
00048   {
00049     OMFATALERROR( "The attribute \"" << attributeName
00050                   << "\" is not available, maybe you should place this extension after the one which create this attribute" ) ;
00051   }
00052   _not = new AttributeT< bool >( Name( attributeName.getString() + "Not" ),
00053                                  !_attributeAccessor->get() ) ;
00054   owner->addAttribute( *_not, output ) ;
00055 }
00056 //-----------------------------------------------------------------------------
00057 NotAttributeExtension::~NotAttributeExtension()
00058 {
00059   delete _not ;
00060 }
00061 //-----------------------------------------------------------------------------
00062 void NotAttributeExtension::preComputeParameters()
00063 {
00064   if( _attributeAccessor->isUpdated() )
00065     _not->set( !_attributeAccessor->get() ) ;
00066   else if( _not->isUpdated() )
00067     _attributeAccessor->set( !_not->get() ) ;
00068 }
00069 //-----------------------------------------------------------------------------
00070 void NotAttributeExtension::postComputeParameters()
00071 {
00072   _not->set( !_attributeAccessor->get() ) ;
00073 }
00074 //=============================================================================

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007