1 //                                               -*- C++ -*-
2 /**
3  *  @brief The class IdFactory builds unique Ids for all Objects
4  *
5  *  Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca
6  *
7  *  This library is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU Lesser General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with this library.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 #include <cstdlib>
22 #include "openturns/IdFactory.hxx"
23 #include "openturns/OSS.hxx"
24 #include "openturns/OTthread.hxx"
25 #include "openturns/MutexLock.hxx"
26 
27 BEGIN_NAMESPACE_OPENTURNS
28 
29 
30 /* Id accessor */
BuildId()31 Id IdFactory::BuildId()
32 {
33   static AtomicInt IdFactory_NextId = 1;
34   return IdFactory_NextId.fetchAndAdd(1);
35 }
36 
37 END_NAMESPACE_OPENTURNS
38