Skip to content

Commit 422877f

Browse files
committed
core: add function to easy expose a type
1 parent 3917a9c commit 422877f

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ SET(${PROJECT_NAME}_HEADERS
8282
${${PROJECT_NAME}_SOLVERS_HEADERS}
8383
include/eigenpy/eigenpy.hpp
8484
include/eigenpy/exception.hpp
85+
include/eigenpy/expose.hpp
8586
include/eigenpy/details.hpp
8687
include/eigenpy/fwd.hpp
8788
include/eigenpy/map.hpp

include/eigenpy/expose.hpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2019, INRIA
3+
*/
4+
5+
#ifndef __eigenpy_expose_hpp__
6+
#define __eigenpy_expose_hpp__
7+
8+
#include "eigenpy/registration.hpp"
9+
10+
namespace eigenpy
11+
{
12+
namespace internal
13+
{
14+
///
15+
/// \brief Allows a template specialization.
16+
///
17+
template<typename T>
18+
struct call_expose
19+
{
20+
static inline void run() { T::expose(); }
21+
};
22+
} // namespace internal
23+
24+
///
25+
/// \brief Call the expose function of a given type T.
26+
///
27+
template<typename T>
28+
inline void expose()
29+
{
30+
if(not register_symbolic_link_to_registered_type<T>())
31+
internal::call_expose<T>::run();
32+
}
33+
}
34+
35+
#endif // ifndef __eigenpy_expose_hpp__

include/eigenpy/fwd.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@
2626
#define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Unaligned
2727
#endif
2828

29+
#include "eigenpy/expose.hpp"
30+
2931
#endif // ifndef __eigenpy_fwd_hpp__
3032

0 commit comments

Comments
 (0)