Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYNameManager.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 /*
17  *
18  */
19 
20 #ifndef __TYNAMEMANAGER__
21 #define __TYNAMEMANAGER__
22 
23 #include "Tympan/core/smartptr.h"
24 #include <map>
25 #include <string>
26 #include <utility>
27 
28 // Smart pointer sur TYNameManager.
29 class TYNameManager;
31 
40 class TYNameManager : public IRefCount
41 {
42 public:
47 
52  static TYNameManager* get();
53 
58  QString generateName(const char* classname);
59 
64  void enable(bool enable)
65  {
66  _enable = enable;
67  }
68 
73  bool isEnable() const
74  {
75  return _enable;
76  }
77 
78 private:
79  // Instance unique.
81 
82  // Map contenant le nom de la classe et l'id genere
83  typedef std::pair<std::string, unsigned int> IDCounter;
84  typedef std::map<std::string, IDCounter> IDMap;
86 
87  // Flag d'activation
88  bool _enable;
89 
93  TYNameManager();
94 
95  // Copy prohibited
98 };
99 
100 #endif // __TYNAMEMANAGER__
SmartPtr< TYNameManager > LPTYNameManager
Definition: TYNameManager.h:29
Generateur de nom unique.
Definition: TYNameManager.h:41
bool isEnable() const
Retourne si vrai si la generation de nom est active, faux sinon.
Definition: TYNameManager.h:73
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
void enable(bool enable)
Active la generation de nom.
Definition: TYNameManager.h:64
TYNameManager & operator=(const TYNameManager &)
static TYNameManager * get()
Retourne l'instance singleton.
std::map< std::string, IDCounter > IDMap
Definition: TYNameManager.h:84
std::pair< std::string, unsigned int > IDCounter
Definition: TYNameManager.h:83
static LPTYNameManager _pInstance
Definition: TYNameManager.h:80
TYNameManager(const TYNameManager &)