]> Creatis software - clitk.git/blob - vv/vvToolCreator.h
Corrected tool mechanism for windows: static data members seem to be initialized...
[clitk.git] / vv / vvToolCreator.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef VVTOOLCREATOR_H
19 #define VVTOOLCREATOR_H
20
21 #include "vvToolCreatorBase.h"
22
23 //------------------------------------------------------------------------------
24 template<class ToolType>
25 class vvToolCreator: public vvToolCreatorBase {
26 public:
27   static vvToolCreator<ToolType> *&GetInstance();
28   virtual void InsertToolInMenu(vvMainWindowBase * m);
29   virtual void MenuSpecificToolSlot() { CreateTool<ToolType>(); }
30 private:
31   vvToolCreator():vvToolCreatorBase(mToolCreatorName) {;}
32   static vvToolCreator<ToolType> * mSingleton;
33   static const QString mToolCreatorName;
34 };
35 //------------------------------------------------------------------------------
36
37
38 //------------------------------------------------------------------------------
39 #define CREATOR(CLASSNAME) vvToolCreator<CLASSNAME>::GetInstance()
40 //------------------------------------------------------------------------------
41
42
43 //------------------------------------------------------------------------------
44 // Initiliazes the static parameters and creates a dummy pointer (required for windows)
45 #define ADD_TOOL(NAME)                                                           \
46   template<> const QString        vvToolCreator<NAME>::mToolCreatorName = #NAME; \
47   template<> vvToolCreator<NAME> *vvToolCreator<NAME>::mSingleton       = NULL;  \
48   const vvToolCreator<NAME> *dummy##NAME = vvToolCreator<NAME>::GetInstance();
49 //------------------------------------------------------------------------------
50
51 #include "vvToolCreator.txx"
52
53 #endif
54