Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYNameManager.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
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 &)