Skip to content
Snippets Groups Projects
Commit c9302b71 authored by Stéphane Albert's avatar Stéphane Albert
Browse files

ENH: Added template ModelController experiment.

parent a6fdbb96
Branches
Tags
No related merge requests found
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "mvdControllerConnector.h"
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
/*
TRANSLATOR mvd::ControllerConnector
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*******************************************************************************/
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
/*******************************************************************************/
} // end namespace 'mvd'
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __mvdControllerConnector_h
#define __mvdControllerConnector_h
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtGui>
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External classes pre-declaration.
namespace
{
}
namespace mvd
{
//
// Internal classes pre-declaration.
namespace Ui
{
};
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
/**
* \class ControllerConnector
*/
template< typename TController >
class Monteverdi2_EXPORT ControllerConnector :
public TController
{
/*-[ QOBJECT SECTION ]-----------------------------------------------------*/
Q_OBJECT;
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public types.
public:
/** */
typedef TController SuperClass;
/** */
typedef TController Controller;
//
// Public methods.
public:
/** Constructor */
ControllerConnector( QWidget* parent =NULL, Qt::WindowFlags flags =0 );
/** Destructor */
virtual ~ControllerConnector();
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
// Signals.
signals:
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
//
// Protected methods.
protected:
/** */
//
// Protected attributes.
protected:
//
// Private methods.
private:
/** */
virtual void Connect( typename TController::Model* );
/** */
virtual void Disconnect( typename TController::Model* );
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
//
// Private attributes.
private:
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
// Slots.
private slots:
};
} // end namespace 'mvd'.
/*****************************************************************************/
/* INLINE SECTION */
namespace mvd
{
} // end namespace 'mvd'
/*****************************************************************************/
/* TEMPLATE SECTION */
#include "mvdControllerConnector.txx"
#endif // __mvdControllerConnector_h
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
/*******************************************************************************/
template< typename TController >
ControllerConnector< TController >
::ControllerConnector( QWidget* parent, Qt::WindowFlags flags ):
TController( parent, flags )
{
}
/*******************************************************************************/
template< typename TController >
ControllerConnector< TController >
::~ControllerConnector()
{
}
/*******************************************************************************/
template< typename TController >
void
ControllerConnector< TController >
::Connect( typename TController::Model* model )
{
SuperClass::Connect( model );
}
/*******************************************************************************/
template< typename TController >
void
ControllerConnector< TController >
::Disconnect( typename TController::Model* model )
{
SuperClass::Disconnect( model );
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
/*******************************************************************************/
} // end namespace 'mvd'
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "mvdModelController.h"
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
/*
TRANSLATOR mvd::ModelController
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*******************************************************************************/
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
/*******************************************************************************/
} // end namespace 'mvd'
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "mvdMyWidget.h"
#include "ui_mvdMyWidget.h"
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
/*
TRANSLATOR mvd::MyWidget
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*******************************************************************************/
MyWidget
::MyWidget( QWidget* parent, Qt::WindowFlags flags ):
QWidget( parent, flags ),
m_UI( new mvd::Ui::MyWidget() )
{
m_UI->setupUi( this );
}
/*******************************************************************************/
MyWidget
::~MyWidget()
{
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
/*******************************************************************************/
} // end namespace 'mvd'
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __mvdModelController_h
#define __mvdModelController_h
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtGui>
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External classes pre-declaration.
namespace
{
}
namespace mvd
{
//
// Internal classes pre-declaration.
namespace Ui
{
};
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
/**
* \class ModelController
*/
template< typename TWidget, typename TModel >
class Monteverdi2_EXPORT ModelController :
public TWidget
{
/*-[ QOBJECT SECTION ]-----------------------------------------------------*/
Q_OBJECT;
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public types.
public:
/** */
typedef TWidget SuperClass;
/** */
typedef TWidget Widget;
/** */
typedef TModel Model;
//
// Public methods.
public:
/** Constructor */
ModelController( QWidget* parent =NULL, Qt::WindowFlags flags =0 );
/** Destructor */
virtual ~ModelController();
/** */
inline void SetModel( Model* );
/** */
inline const Model* GetModel() const;
/** */
inline Model* GetModel();
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
// Signals.
signals:
/** */
void AboutToDisconnectModel( Model* );
/** */
void ModelDisconnected( Model* );
/** */
void AboutToConnectModel( Model* );
/** */
void ModelConnected( Model* );
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
//
// Protected methods.
protected:
/** */
virtual void Connect( Model* ) =0;
/** */
virtual void Disconnect( Model* ) =0;
//
// Protected attributes.
protected:
//
// Private methods.
private:
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
//
// Private attributes.
private:
/** */
Model* m_Model;
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
// Slots.
private slots:
};
} // end namespace 'mvd'.
/*****************************************************************************/
/* INLINE SECTION */
namespace mvd
{
/*****************************************************************************/
template< typename TWidget, typename TModel >
inline
void
ModelController< TWidget, TModel >
::SetModel( Model* model )
{
// Disconnect previously connected model and signal listeners.
emit AboutToDisconnectModel( m_Model );
Disconnect( m_Model );
emit ModelDisconnected( m_Model );
// Forget previously disconnected model before new model is
// connected. This is done in order to stay in a consistent internal
// state whenever the connection is aborted (e.g. by an exception).
m_Model = NULL;
// Connect new model and signal listeners.
emit AboutToConnectModel( model );
Connect( model );
emit ModelDisconnected( model );
// Remember newly connected model.
m_Model = model;
}
/*****************************************************************************/
template< typename TWidget, typename TModel >
inline
const TModel*
ModelController< TWidget, TModel >
::GetModel() const
{
return m_Model;
}
/*****************************************************************************/
template< typename TWidget, typename TModel >
inline
TModel*
ModelController< TWidget, TModel >
::GetModel()
{
return m_Model;
}
} // end namespace 'mvd'
/*****************************************************************************/
/* TEMPLATE SECTION */
#include "mvdModelController.txx"
#endif // __mvdModelController_h
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __mvdMyWidget_h
#define __mvdMyWidget_h
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QtGui>
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External classes pre-declaration.
namespace
{
}
namespace mvd
{
//
// Internal classes pre-declaration.
namespace Ui
{
class MyWidget;
};
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
/**
* \class MyWidget
*/
class Monteverdi2_EXPORT MyWidget :
public QWidget
{
/*-[ QOBJECT SECTION ]-----------------------------------------------------*/
Q_OBJECT;
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public methods.
public:
/** Constructor */
MyWidget( QWidget* parent =NULL, Qt::WindowFlags flags =0 );
/** Destructor */
virtual ~MyWidget();
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
// Signals.
signals:
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
//
// Protected methods.
protected:
//
// Protected attributes.
protected:
//
// Private methods.
private:
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
//
// Private attributes.
private:
/**
* uic generated.
*/
Ui::MyWidget* m_UI;
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
// Slots.
private slots:
};
/*****************************************************************************/
/* INLINE SECTION */
} // end namespace 'mvd'
#endif // __mvdMyWidget_h
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
/*******************************************************************************/
template< typename TWidget, typename TObject >
ModelController< TWidget, TObject >
::ModelController( QWidget* parent, Qt::WindowFlags flags ):
TWidget( parent, flags ),
m_Model( NULL )
{
}
/*******************************************************************************/
template< typename TWidget, typename TObject >
ModelController< TWidget, TObject >
::~ModelController()
{
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
/*******************************************************************************/
} // end namespace 'mvd'
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "mvdModelController.h"
#include "ui_mvdModelController.h"
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
/*
TRANSLATOR mvd::ModelController
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*******************************************************************************/
ModelController
::ModelController( QWidget* parent, Qt::WindowFlags flags ):
QWidget( parent, flags )
{
m_UI->setupUi( this );
}
/*******************************************************************************/
ModelController
::~ModelController()
{
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
/*******************************************************************************/
} // end namespace 'mvd'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment