Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BLI_static_class_ids.h « blenlib « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d048fef64ae1bbe948265b90283ed6f37dbfd14a (plain)
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
#ifndef __BLI_STATIC_CLASS_IDS_H__
#define __BLI_STATIC_CLASS_IDS_H__

#include "BLI_utildefines.h"

namespace BLI {

using class_id_t = uintptr_t;

template<typename T> class_id_t get_class_id();

}  // namespace BLI

#define BLI_CREATE_CLASS_ID_UTIL1(class_name, id) \
  namespace BLI { \
  static char class_id_char##id = 0; \
  static class_id_t class_id##id = (class_id_t)&class_id_char##id; \
  template<> class_id_t get_class_id<class_name>() \
  { \
    return class_id##id; \
  } \
  }

#define BLI_CREATE_CLASS_ID_UTIL2(class_name, id) BLI_CREATE_CLASS_ID_UTIL1(class_name, id)

#define BLI_CREATE_CLASS_ID(class_name) BLI_CREATE_CLASS_ID_UTIL2(class_name, __LINE__)

#endif /* __BLI_STATIC_CLASS_IDS_H__ */