macros.hpp 3.7 KB
Newer Older
1 2
#ifndef OPENPOSE_CORE_MACROS_HPP
#define OPENPOSE_CORE_MACROS_HPP
G
Gines 已提交
3

G
gineshidalgo99 已提交
4
#include <chrono> // std::chrono:: functionaligy, e.g., std::chrono::milliseconds
R
Raaj 已提交
5 6
#include <memory> // std::shared_ptr
#include <ostream>
7
#include <string>
G
gineshidalgo99 已提交
8
#include <thread> // std::this_thread
R
Raaj 已提交
9 10
#include <vector>

11 12
// OpenPose name and version
const std::string OPEN_POSE_NAME_STRING = "OpenPose";
G
Gines Hidalgo 已提交
13
const std::string OPEN_POSE_VERSION_STRING = "1.6.0";
14
const std::string OPEN_POSE_NAME_AND_VERSION = OPEN_POSE_NAME_STRING + " " + OPEN_POSE_VERSION_STRING;
15
// #define COMMERCIAL_LICENSE
16

G
Gines 已提交
17 18 19 20 21 22 23 24
#ifndef _WIN32
    #define OP_API
#elif defined OP_EXPORTS
    #define OP_API __declspec(dllexport)
#else
    #define OP_API __declspec(dllimport)
#endif

G
gineshidalgo99 已提交
25
// Disable some Windows Warnings
26
#ifdef _WIN32
27
    #pragma warning(disable: 4251) // 'XXX': class 'YYY' needs to have dll-interface to be used by clients of class 'ZZZ'
28 29
#endif

G
Gines 已提交
30 31 32 33 34 35
#define UNUSED(unusedVariable) (void)(unusedVariable)

#define DELETE_COPY(className) \
    className(const className&) = delete; \
    className& operator=(const className&) = delete

36
// Instantiate a class with all the basic types
G
Gines 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#define COMPILE_TEMPLATE_BASIC_TYPES_CLASS(className) COMPILE_TEMPLATE_BASIC_TYPES(className, class)
#define COMPILE_TEMPLATE_BASIC_TYPES_STRUCT(className) COMPILE_TEMPLATE_BASIC_TYPES(className, struct)
#define COMPILE_TEMPLATE_BASIC_TYPES(className, classType) \
    template classType OP_API className<char>; \
    template classType OP_API className<signed char>; \
    template classType OP_API className<short>; \
    template classType OP_API className<int>; \
    template classType OP_API className<long>; \
    template classType OP_API className<long long>; \
    template classType OP_API className<unsigned char>; \
    template classType OP_API className<unsigned short>; \
    template classType OP_API className<unsigned int>; \
    template classType OP_API className<unsigned long>; \
    template classType OP_API className<unsigned long long>; \
    template classType OP_API className<float>; \
    template classType OP_API className<double>; \
    template classType OP_API className<long double>

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
// Instantiate a class with float and double specifications
#define COMPILE_TEMPLATE_FLOATING_TYPES_CLASS(className) COMPILE_TEMPLATE_FLOATING_TYPES(className, class)
#define COMPILE_TEMPLATE_FLOATING_TYPES_STRUCT(className) COMPILE_TEMPLATE_FLOATING_TYPES(className, struct)
#define COMPILE_TEMPLATE_FLOATING_TYPES(className, classType) \
  char gInstantiationGuard##className; \
  template classType OP_API className<float>; \
  template classType OP_API className<double>

// Instantiate a class with float and double specifications
#define COMPILE_TEMPLATE_FLOATING_INT_TYPES_CLASS(className) COMPILE_TEMPLATE_FLOATING_INT_TYPES(className, class)
#define COMPILE_TEMPLATE_FLOATING_INT_TYPES_STRUCT(className) COMPILE_TEMPLATE_FLOATING_INT_TYPES(className, struct)
#define COMPILE_TEMPLATE_FLOATING_INT_TYPES(className, classType) \
  char gInstantiationGuard##className; \
  template classType OP_API className<int>; \
  template classType OP_API className<unsigned int>; \
  template classType OP_API className<float>; \
  template classType OP_API className<double>

R
Raaj 已提交
73 74 75 76 77 78 79 80 81 82 83
/**
 * cout operator overload calling toString() function
 * @return std::ostream containing output from toString()
 */
#define OVERLOAD_C_OUT(className) \
    template<typename T> std::ostream &operator<<(std::ostream& ostream, const op::className<T>& obj) \
    { \
        ostream << obj.toString(); \
        return ostream; \
    }

84 85 86 87
// PIMPL does not work if function arguments need the 3rd-party class. Alternative:
// stackoverflow.com/questions/13978775/how-to-avoid-include-dependency-to-external-library?answertab=active#tab-top
struct dim3;

88
#endif // OPENPOSE_CORE_MACROS_HPP