RSC  0.7.17
 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 
27 #pragma once
28 
29 #include <string>
30 
31 #include <boost/cstdint.hpp>
32 #include <boost/shared_ptr.hpp>
33 
34 #include "rsc/rscexports.h"
35 
36 namespace rsc {
37 namespace misc {
38 
47 class RSC_EXPORT NullDeleter {
48 public:
49 
55  void operator()(void* ignored) const;
56 
57 };
58 
70 template<class ParentType>
72 public:
73  ParentSharedPtrDeleter(boost::shared_ptr<ParentType> parent) :
74  parent(parent) {
75  }
76 
77  void operator()(void const *) {
78  parent.reset();
79  }
80 
81 private:
82  boost::shared_ptr<ParentType> parent;
83 };
84 
90 RSC_EXPORT boost::uint64_t currentTimeMillis();
91 
97 RSC_EXPORT boost::uint64_t currentTimeMicros();
98 
104 RSC_EXPORT char randAlnumChar();
105 
112 RSC_EXPORT std::string randAlnumStr(const std::string::size_type& length);
113 
114 // This macro allows you to mark a function as being deprecated. Please note
115 // that if your return type contains a comma (template) you need to typedef it.
116 // Otherwise the commas are interpreted as arguments to this macro.
117 // Usage:
118 // DEPRECATED(void deprecatedFunction(int foo));
119 // void deprecatedFunction(int foo) {
120 // int bla = foo + 1;
121 // bla = bla + 1;
122 // }
123 #ifdef __GNUC__
124 #define DEPRECATED(func) func __attribute__ ((deprecated))
125 #elif defined(_MSC_VER)
126 #define DEPRECATED(func) __declspec(deprecated) func
127 #else
128 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
129 #define DEPRECATED(func) func
130 #endif
131 
132 }
133 }
134 
A deleter object that can be used with boost::shared_ptr that doesn't release any memory...
Definition: langutils.h:47
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:73
boost::uint64_t currentTimeMillis()
Returns the current system time as milliseconds.
Definition: langutils.cpp:64
void operator()(void const *)
Definition: langutils.h:77
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:82
A deleter for boost::shared_ptr which enables to use a pointer in a shared_ptr, which is not a shared...
Definition: langutils.h:71