INIInterface.hh 7.09 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2
3
*                                                                            *
*                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
*      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen       *
Jan Möbius's avatar
Jan Möbius committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
*                           www.openflipper.org                              *
*                                                                            *
*--------------------------------------------------------------------------- *
*  This file is part of OpenFlipper.                                         *
*                                                                            *
*  OpenFlipper is free software: you can redistribute it and/or modify       *
*  it under the terms of the GNU Lesser General Public License as            *
*  published by the Free Software Foundation, either version 3 of            *
*  the License, or (at your option) any later version with the               *
*  following exceptions:                                                     *
*                                                                            *
*  If other files instantiate templates or use macros                        *
*  or inline functions from this file, or you compile this file and          *
*  link it with other files to produce an executable, this file does         *
*  not by itself cause the resulting executable to be covered by the         *
*  GNU Lesser General Public License. This exception does not however        *
*  invalidate any other reasons why the executable file might be             *
*  covered by the GNU Lesser General Public License.                         *
*                                                                            *
*  OpenFlipper is distributed in the hope that it will be useful,            *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of            *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
*  GNU Lesser General Public License for more details.                       *
*                                                                            *
*  You should have received a copy of the GNU LesserGeneral Public           *
*  License along with OpenFlipper. If not,                                   *
*  see <http://www.gnu.org/licenses/>.                                       *
*                                                                            *
33
34
35
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
36
37
38
39
40
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
41
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
42
43


Jan Möbius's avatar
 
Jan Möbius committed
44
45
#ifndef INIINTERFACE_HH
#define INIINTERFACE_HH
Jan Möbius's avatar
 
Jan Möbius committed
46

Matthias Möller's avatar
Matthias Möller committed
47
48
49
50
51
52
53
 
#if QT_VERSION >= 0x050000 
  #include <QtWidgets>
#else
  #include <QtGui>
#endif

Jan Möbius's avatar
 
Jan Möbius committed
54
55
 #include <QMenuBar>
 #include <OpenFlipper/common/Types.hh>
Jan Möbius's avatar
 
Jan Möbius committed
56

Jan Möbius's avatar
 
Jan Möbius committed
57
 #include <OpenFlipper/INIFile/INIFile.hh>
Jan Möbius's avatar
 
Jan Möbius committed
58
59
60

 /** \brief Interface class for Plugins which have to store information in ini files
  *
Jan Möbius's avatar
Jan Möbius committed
61
62
63
64
  * Using this interface you can store or load additional information to an ini file on a
  * per object basis or settings for your plugin. After basic information is written to the
  * ini file by the core ( or loaded by the core ) the corresponding functions in this
  * Interface will be executed.
Jan Möbius's avatar
 
Jan Möbius committed
65
66
  * You get the object id for the object which has to be used. For every object the functions
  * will get called and you have to save your data only for the given object!\n
Jan Möbius's avatar
Jan Möbius committed
67
68
69
  * The ini file in the functions is already open. You may not close it!
  * Additionally there are two slots which are called once per plugin when writing a settings
  * file. These slots should be used to store information which is used by your plugin.
70
71
  *
  * See \ref dataFlow for a detailed overview of OpenFlipper's data flow and interface function calls.
Jan Möbius's avatar
 
Jan Möbius committed
72
73
 */
class INIInterface {
Jan Möbius's avatar
 
Jan Möbius committed
74
75
   public :

Jan Möbius's avatar
 
Jan Möbius committed
76
77
      /// Destructor
      virtual ~INIInterface() {};
Jan Möbius's avatar
 
Jan Möbius committed
78

Jan Möbius's avatar
 
Jan Möbius committed
79
   private slots:
Jan Möbius's avatar
Jan Möbius committed
80
81
82
83
84
85
86
87
88
89
90
91

    //=======================================
    /** @name Per object settings
    * @{ */
    //=======================================
      /** \brief Load per object settings
       *
       *  Every time the core opens a settings file containing objects
       *  the core will call this slot for each object it finds.
       *  The object itself is loaded before the slot is called. Therefore
       *  the object is available from within your plugin.
       *
Jan Möbius's avatar
 
Jan Möbius committed
92
93
94
       *  @param _ini ini file
       *  @param _id Id of the object to load data for
       */
Jan Möbius's avatar
Jan Möbius committed
95
      virtual void loadIniFile( INIFile& _ini ,int _id ) {};
Jan Möbius's avatar
 
Jan Möbius committed
96

Jan Möbius's avatar
Jan Möbius committed
97
98
99
100
101
102
      /** \brief Save per object settings
       *
       * Every time a settings file is created this slot is called
       * once per object. Here you can write additional information
       * handled by your plugin which is attached to the object.
       *
Jan Möbius's avatar
 
Jan Möbius committed
103
       * @param _ini ini file
Jan Möbius's avatar
Jan Möbius committed
104
       * @param _id Identifier of the object to save
Jan Möbius's avatar
 
Jan Möbius committed
105
       */
Jan Möbius's avatar
Jan Möbius committed
106
      virtual void saveIniFile( INIFile& _ini ,int _id) {};
Jan Möbius's avatar
 
Jan Möbius committed
107

Jan Möbius's avatar
Jan Möbius committed
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
    /** @} */


    //=======================================
    /** @name Plugin Options and Settings
    * @{ */
    //=======================================

    private slots:

      /** \brief Load per Plugin settings
       *
       *  When the core loads an ini file and it contains settings for
       *  Plugin or the core itself this slot will be
       *  called once per Plugin.
       *  This Slot will be called after loading the core settings and
       *  before objects are loaded
       *
Jan Möbius's avatar
 
Jan Möbius committed
126
127
       * @param _ini  ini file
       */
Jan Möbius's avatar
Jan Möbius committed
128
      virtual void loadIniFileOptions( INIFile& _ini ) {};
Jan Möbius's avatar
 
Jan Möbius committed
129

Jan Möbius's avatar
Jan Möbius committed
130
131
132
133
134
135
136
137
138
      /** \brief Load per Plugin settings after objects are loaded
       *
       *  When the core loads an ini file and it contains settings for
       *  Plugin or the core itself this slot will be
       *  called once per Plugin. In contrast to loadIniFileOptions
       *  this slot will be called after all objects are loaded
       *
       * @param _ini  ini file
       */
Jan Möbius's avatar
Jan Möbius committed
139
      virtual void loadIniFileOptionsLast( INIFile& _ini ) {};
Jan Möbius's avatar
Jan Möbius committed
140
141

      /** \brief Save Plugin Options
142
       *  When the core is about to save an ini file this slot will be
Jan Möbius's avatar
Jan Möbius committed
143
144
145
146
       *  called once per Plugin.
       *  This Slot will be called after saving the core settings and
       *  before objects are saved to the file
       *
Jan Möbius's avatar
 
Jan Möbius committed
147
148
       * @param _ini ini file
       */
Jan Möbius's avatar
Jan Möbius committed
149
      virtual void saveIniFileOptions( INIFile& _ini ) {};
Jan Möbius's avatar
 
Jan Möbius committed
150

151
152
153
154
155
156
157
      /** \brief Save per Plugin settings when application is about to quit
       *
       * Before the Core is closed, this slot will be called per plugin to
       * save per plugin settings.
       *
       * @param _ini ini file
       */
Jan Möbius's avatar
Jan Möbius committed
158
      virtual void saveOnExit( INIFile& _ini ) {};
159
160


Jan Möbius's avatar
Jan Möbius committed
161
162
163
   /** @} */


Jan Möbius's avatar
 
Jan Möbius committed
164
165
166
};

Q_DECLARE_INTERFACE(INIInterface,"OpenFlipper.INIInterface/1.2")
Jan Möbius's avatar
 
Jan Möbius committed
167

Jan Möbius's avatar
 
Jan Möbius committed
168
#endif // INIINTERFACE_HH