Skip to content

Commit 9e30d57

Browse files
Style overhaul (#64)
* header guards and namespaces * [cpplint] whitespaces * includes * line length * no globl std::string * add some missing copyrights * ignore explicit cpplint violation and add todo to address them on melodic branch * uncrustify * unused variables warnings * litterals on left side of operator * spurious temp file
1 parent 9a3cc66 commit 9e30d57

16 files changed

+1505
-1210
lines changed

include/class_loader/class_loader.h

+231-207
Large diffs are not rendered by default.

include/class_loader/class_loader_core.h

+130-82
Large diffs are not rendered by default.

include/class_loader/class_loader_exceptions.h

+28-16
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
* POSSIBILITY OF SUCH DAMAGE.
2828
*/
2929

30+
#ifndef CLASS_LOADER__CLASS_LOADER_EXCEPTIONS_H_
31+
#define CLASS_LOADER__CLASS_LOADER_EXCEPTIONS_H_
32+
3033
#include <exception>
34+
#include <string>
35+
36+
// TODO(mikaelarguedas) : replace no lints with the explicit keyword in an ABI breaking release
3137

3238
namespace class_loader
3339
{
@@ -36,50 +42,56 @@ namespace class_loader
3642
* @class ClassLoader sException
3743
* @brief A base class for all class_loader exceptions that inherits from std::runtime_exception
3844
*/
39-
class ClassLoaderException: public std::runtime_error
45+
class ClassLoaderException : public std::runtime_error
4046
{
41-
public:
42-
ClassLoaderException(const std::string error_desc) : std::runtime_error(error_desc) {}
47+
public:
48+
ClassLoaderException(const std::string error_desc) // NOLINT(runtime/explicit)
49+
: std::runtime_error(error_desc) {}
4350
};
4451

4552
/**
4653
* @class LibraryLoadException
4754
* @brief An exception class thrown when class_loader is unable to load a runtime library
4855
*/
49-
class LibraryLoadException: public ClassLoaderException
56+
class LibraryLoadException : public ClassLoaderException
5057
{
51-
public:
52-
LibraryLoadException(const std::string error_desc) : ClassLoaderException(error_desc) {}
58+
public:
59+
LibraryLoadException(const std::string error_desc) // NOLINT(runtime/explicit)
60+
: ClassLoaderException(error_desc) {}
5361
};
5462

5563
/**
5664
* @class LibraryUnloadException
5765
* @brief An exception class thrown when class_loader is unable to unload a runtime library
5866
*/
59-
class LibraryUnloadException: public ClassLoaderException
67+
class LibraryUnloadException : public ClassLoaderException
6068
{
61-
public:
62-
LibraryUnloadException(const std::string error_desc) : ClassLoaderException(error_desc) {}
69+
public:
70+
LibraryUnloadException(const std::string error_desc) // NOLINT(runtime/explicit)
71+
: ClassLoaderException(error_desc) {}
6372
};
6473

6574
/**
6675
* @class CreateClassException
6776
* @brief An exception class thrown when class_loader is unable to create a plugin
6877
*/
69-
class CreateClassException: public ClassLoaderException
78+
class CreateClassException : public ClassLoaderException
7079
{
71-
public:
72-
CreateClassException(const std::string error_desc) : ClassLoaderException(error_desc) {}
80+
public:
81+
CreateClassException(const std::string error_desc) // NOLINT(runtime/explicit)
82+
: ClassLoaderException(error_desc) {}
7383
};
7484

7585
/**
7686
* @class NoClassLoaderExistsException
7787
* @brief An exception class thrown when a multilibrary class loader does not have a ClassLoader bound to it
7888
*/
79-
class NoClassLoaderExistsException: public ClassLoaderException
89+
class NoClassLoaderExistsException : public ClassLoaderException
8090
{
81-
public:
82-
NoClassLoaderExistsException(const std::string error_desc) : ClassLoaderException(error_desc) {}
91+
public:
92+
NoClassLoaderExistsException(const std::string error_desc) // NOLINT(runtime/explicit)
93+
: ClassLoaderException(error_desc) {}
8394
};
8495

85-
}
96+
} // namespace class_loader
97+
#endif // CLASS_LOADER__CLASS_LOADER_EXCEPTIONS_H_

include/class_loader/class_loader_register_macro.h

+25-21
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,48 @@
2727
* POSSIBILITY OF SUCH DAMAGE.
2828
*/
2929

30-
#ifndef CLASS_LOADER_REGISTER_MACRO_H_DEFINED
31-
#define CLASS_LOADER_REGISTER_MACRO_H_DEFINED
30+
#ifndef CLASS_LOADER__CLASS_LOADER_REGISTER_MACRO_H_
31+
#define CLASS_LOADER__CLASS_LOADER_REGISTER_MACRO_H_
3232

33-
#include "class_loader_core.h"
34-
#include <console_bridge/console.h>
33+
#include <string>
3534

35+
#include "class_loader/class_loader_core.h"
3636
#include "class_loader/console_bridge_compatibility.h"
3737

38+
#include "console_bridge/console.h"
39+
3840
#define CLASS_LOADER_REGISTER_CLASS_INTERNAL_WITH_MESSAGE(Derived, Base, UniqueID, Message) \
39-
namespace \
40-
{\
41-
struct ProxyExec##UniqueID \
42-
{\
41+
namespace \
42+
{ \
43+
struct ProxyExec ## UniqueID \
44+
{ \
4345
typedef Derived _derived; \
44-
typedef Base _base; \
45-
ProxyExec##UniqueID() \
46+
typedef Base _base; \
47+
ProxyExec ## UniqueID() \
4648
{ \
47-
if(std::string(Message)!="")\
48-
CONSOLE_BRIDGE_logInform("%s", Message);\
49+
if (std::string(Message) != "") { \
50+
CONSOLE_BRIDGE_logInform("%s", Message);} \
4951
class_loader::class_loader_private::registerPlugin<_derived, _base>(#Derived, #Base); \
50-
}\
51-
};\
52-
static ProxyExec##UniqueID g_register_plugin_##UniqueID;\
53-
}
52+
} \
53+
}; \
54+
static ProxyExec ## UniqueID g_register_plugin_ ## UniqueID; \
55+
} // namespace
5456

55-
#define CLASS_LOADER_REGISTER_CLASS_INTERNAL_HOP1_WITH_MESSAGE(Derived, Base, UniqueID, Message) CLASS_LOADER_REGISTER_CLASS_INTERNAL_WITH_MESSAGE(Derived, Base, UniqueID, Message)
57+
#define CLASS_LOADER_REGISTER_CLASS_INTERNAL_HOP1_WITH_MESSAGE(Derived, Base, UniqueID, Message) \
58+
CLASS_LOADER_REGISTER_CLASS_INTERNAL_WITH_MESSAGE(Derived, Base, UniqueID, Message)
5659

5760
/**
5861
* @macro This macro is same as CLASS_LOADER_REGISTER_CLASS, but will spit out a message when the plugin is registered
5962
* at library load time
6063
*/
61-
#define CLASS_LOADER_REGISTER_CLASS_WITH_MESSAGE(Derived, Base, Message) CLASS_LOADER_REGISTER_CLASS_INTERNAL_HOP1_WITH_MESSAGE(Derived, Base, __COUNTER__, Message)
64+
#define CLASS_LOADER_REGISTER_CLASS_WITH_MESSAGE(Derived, Base, Message) \
65+
CLASS_LOADER_REGISTER_CLASS_INTERNAL_HOP1_WITH_MESSAGE(Derived, Base, __COUNTER__, Message)
6266

6367
/**
6468
* @macro This is the macro which must be declared within the source (.cpp) file for each class that is to be exported as plugin.
6569
* The macro utilizes a trick where a new struct is generated along with a declaration of static global variable of same type after it. The struct's constructor invokes a registration function with the plugin system. When the plugin system loads a library with registered classes in it, the initialization of static variables forces the invocation of the struct constructors, and all exported classes are automatically registerd.
6670
*/
67-
#define CLASS_LOADER_REGISTER_CLASS(Derived, Base) CLASS_LOADER_REGISTER_CLASS_WITH_MESSAGE(Derived, Base, "")
68-
69-
#endif
71+
#define CLASS_LOADER_REGISTER_CLASS(Derived, Base) \
72+
CLASS_LOADER_REGISTER_CLASS_WITH_MESSAGE(Derived, Base, "")
7073

74+
#endif // CLASS_LOADER__CLASS_LOADER_REGISTER_MACRO_H_

include/class_loader/console_bridge_compatibility.h

+32-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
1-
#ifndef CLASS_LOADER__CONSOLE_BRIDGE_COMPATIBILITY_H
2-
#define CLASS_LOADER__CONSOLE_BRIDGE_COMPATIBILITY_H
1+
/*
2+
* Copyright (c) 2017, Open Source Robotics Foundation, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* * Neither the name of the Willow Garage, Inc. nor the names of its
14+
* contributors may be used to endorse or promote products derived from
15+
* this software without specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27+
* POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#ifndef CLASS_LOADER__CONSOLE_BRIDGE_COMPATIBILITY_H_
31+
#define CLASS_LOADER__CONSOLE_BRIDGE_COMPATIBILITY_H_
332

433
#include <console_bridge/console.h>
534

@@ -19,4 +48,4 @@
1948
#define CONSOLE_BRIDGE_logInform logInform
2049
#endif
2150

22-
#endif // CLASS_LOADER__CONSOLE_BRIDGE_COMPATIBILITY_H
51+
#endif // CLASS_LOADER__CONSOLE_BRIDGE_COMPATIBILITY_H_

0 commit comments

Comments
 (0)