RSC  0.10.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
langutils.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of RSC project
4  *
5  * Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
6  *
7  * This file may be licensed under the terms of the
8  * GNU Lesser General Public License Version 3 (the ``LGPL''),
9  * or (at your option) any later version.
10  *
11  * Software distributed under the License is distributed
12  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
13  * express or implied. See the LGPL for the specific language
14  * governing rights and limitations.
15  *
16  * You should have received a copy of the LGPL along with this
17  * program. If not, go to http://www.gnu.org/licenses/lgpl.html
18  * or write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * The development of this software was supported by:
22  * CoR-Lab, Research Institute for Cognition and Robotics
23  * Bielefeld University
24  *
25  * ============================================================ */
26 
29 #pragma once
30 
31 #include <string>
32 
33 #include <boost/cstdint.hpp>
34 #include <boost/shared_ptr.hpp>
35 
36 #include "rsc/rscexports.h"
37 
38 namespace rsc {
39 namespace misc {
40 
49 class RSC_EXPORT NullDeleter {
50 public:
51 
57  void operator()(void* ignored) const;
58 
59 };
60 
72 template<class ParentType>
74 public:
75  ParentSharedPtrDeleter(boost::shared_ptr<ParentType> parent) :
76  parent(parent) {
77  }
78 
79  void operator()(void const *) {
80  parent.reset();
81  }
82 
83 private:
84  boost::shared_ptr<ParentType> parent;
85 };
86 
92 RSC_EXPORT boost::uint64_t currentTimeMillis();
93 
99 RSC_EXPORT boost::uint64_t currentTimeMicros();
100 
106 RSC_EXPORT char randAlnumChar();
107 
114 RSC_EXPORT std::string randAlnumStr(const std::string::size_type& length);
115 
116 #ifdef __GNUC__
117 #define GCC_VERSION (__GNUC__ * 10000 \
118  + __GNUC_MINOR__ * 100 \
119  + __GNUC_PATCHLEVEL__)
120 #endif
121 
138 #ifdef __GNUC__
139 #if GCC_VERSION > 40500
140 #define DEPRECATED_MSG(func, msg) func __attribute__ ((deprecated (#msg)))
141 #else
142 #define DEPRECATED_MSG(func, msg) func __attribute__ ((deprecated))
143 #endif
144 #elif defined(_MSC_VER)
145 #define DEPRECATED_MSG(func, msg) __declspec(deprecated(#msg)) func
146 #else
147 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
148 #define DEPRECATED_MSG(func, msg) func
149 #endif
150 
168 #define DEPRECATED(fun) DEPRECATED_MSG(fun, "Use of deprecated construct.")
169 
182 #ifdef __GNUC__
183 #if GCC_VERSION > 40500
184 #define DEPRECATED_CLASS(msg) __attribute__ ((deprecated (#msg)))
185 #else
186 #define DEPRECATED_CLASS(msg) __attribute__ ((deprecated))
187 #endif
188 #elif defined(_MSC_VER)
189 #define DEPRECATED_CLASS(msg) __declspec(deprecated(#msg))
190 #else
191 #pragma message("WARNING: You need to implement DEPRECATED_CLASS for this compiler")
192 #define DEPRECATED_CLASS(msg)
193 #endif
194 
195 }
196 }
197 
A deleter object that can be used with boost::shared_ptr that doesn't release any memory...
Definition: langutils.h:49
std::string randAlnumStr(const std::string::size_type &length)
Generates a random alpha-numeric string with fixed length.
Definition: langutils.cpp:108
ParentSharedPtrDeleter(boost::shared_ptr< ParentType > parent)
Definition: langutils.h:75
boost::uint64_t currentTimeMillis()
Returns the current system time as milliseconds.
Definition: langutils.cpp:64
void operator()(void const *)
Definition: langutils.h:79
char randAlnumChar()
Generates a random alpha-numeric character.
Definition: langutils.cpp:100
boost::uint64_t currentTimeMicros()
Returns the current system time as microseconds.
Definition: langutils.cpp:82
boost::shared_ptr< ParentType > parent
Definition: langutils.h:84
A deleter for boost::shared_ptr which enables to use a pointer in a shared_ptr, which is not a shared...
Definition: langutils.h:73