Lumiera  0.pre.03
»edit your freedom«
genfunc.cpp
Go to the documentation of this file.
1 /*
2  GenFunc - generic identification functions (raw)
3 
4  Copyright (C) Lumiera.org
5  2015, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program 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 General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
29 #include "lib/idi/genfunc.hpp"
30 #include "lib/format-string.hpp"
31 #include "lib/format-obj.hpp"
32 #include "lib/util.hpp"
33 
34 #include <string>
35 #include <boost/functional/hash.hpp>
36 
37 
38 using util::_Fmt;
39 using std::string;
40 
41 
42 namespace lib {
43 namespace idi {
44 
45 
46  namespace format { // generic entry points / integration helpers...
47 
48  string
49  instance_format (string const& prefix, size_t instanceNr)
50  {
51  return _Fmt("%s.%03d")
52  % prefix % instanceNr;
53  }
54 
55  string
56  instance_hex_format (string const& prefix, size_t instanceNr)
57  {
58  return _Fmt("%s.%04X")
59  % prefix % instanceNr;
60  }
61 
62  } //(End)integration helpers...
63 
64 
65  TypedCounter&
66  sharedInstanceCounter()
67  { // Meyer's Singleton
68  static TypedCounter instanceCounter;
69  return instanceCounter;
70  }
71 
72 }} // namespace lib::idi
Front-end for printf-style string template interpolation.
A front-end for using printf-style formatting.
Implementation namespace for support and library code.
Generic functions to build identification schemes.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Simple functions to represent objects, for debugging and diagnostics.