-
Notifications
You must be signed in to change notification settings - Fork 124
/
BaseClass.h
102 lines (88 loc) · 2.78 KB
/
BaseClass.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/// \ingroup base
/// \class ttk::BaseClass
/// \author Guillaume Favelier <[email protected]>
/// \date June 2018.
///
///\brief TTK base package.
#pragma once
#ifdef _WIN32
// enable the `and` and `or` keywords on MSVC
#include <ciso646>
#endif // _WIN32
#include <DataTypes.h>
#include <OpenMP.h>
#ifdef TTK_ENABLE_MPI
#define OMPI_SKIP_MPICXX 1
#include <mpi.h>
#endif // TTK_ENABLE_MPI
#if defined(_MSC_VER) && defined(TTK_ENABLE_SHARED_BASE_LIBRARIES)
#if defined(common_EXPORTS)
// building common.dll
#define COMMON_EXPORTS __declspec(dllexport)
// building every other .dll that include this header
#else
#define COMMON_EXPORTS __declspec(dllimport)
#endif // common_EXPORTS
#else
#define COMMON_EXPORTS
#endif // _MSC_VER && TTK_ENABLE_SHARED_BASE_LIBRARIES
/**
* @brief Mark function/method parameters that are not used in the
* function body at all.
*
* This is the TTK version of vtkNotUsed. It silences compiler
* warnings about unused parameters when those parameters are not used
* in the current function/method body but still necessary in the
* function/method signature (for instance when implementing a
* particular API with inheritance).
*
* Basically, it removes the name of the parameter at its definition
* site (similar to commenting the parameter name).
*/
#define ttkNotUsed(x)
/**
* @brief Force the compiler to use the function/method parameter.
*
* Some function/method parameters are used under some `#ifdef`
* preprocessor conditions. This macro introduce a no-op statement
* that uses those parameters, to silence compiler warnings in the
* `#else` blocks. It can be inserted anywhere in the function body.
*/
#define TTK_FORCE_USE(x) (void)(x)
namespace ttk {
COMMON_EXPORTS extern int globalThreadNumber_;
COMMON_EXPORTS extern int MPIrank_;
COMMON_EXPORTS extern int MPIsize_;
#ifdef TTK_ENABLE_MPI
COMMON_EXPORTS extern MPI_Comm MPIcomm_;
#endif
class Wrapper;
class BaseClass {
public:
BaseClass();
virtual ~BaseClass() = default;
int getThreadNumber() const {
return threadNumber_;
}
virtual int setThreadNumber(const int threadNumber) {
threadNumber_ = threadNumber;
return 0;
}
/// Specify a pointer to a calling object that wraps the current class
/// deriving from ttk::BaseClass.
///
/// This function is useful to pass the execution context (debug level,
/// number of threads, etc.) from a wrapper to a base object.
/// \param wrapper Pointer to the wrapping object.
/// \return Returns 0 upon success, negative values otherwise.
virtual int setWrapper(const Wrapper *wrapper);
protected:
bool lastObject_;
mutable int threadNumber_;
Wrapper *wrapper_;
#ifdef TTK_ENABLE_MPI
bool hasMPISupport_{false};
#endif
};
} // namespace ttk
#include <MPIUtils.h>