~markwright/scalestack/zeromq

« back to all changes in this revision

Viewing changes to ScaleStack/Common.h.in

  • Committer: Eric Day
  • Date: 2010-02-21 10:36:03 UTC
  • Revision ID: eday@oddments.org-20100221103603-u0agc1fsduqhl728
Initial commit with build system and basic module loading.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Scale Stack
 
3
 *
 
4
 * Copyright (C) 2010 Eric Day (eday@oddments.org)
 
5
 * All rights reserved.
 
6
 *
 
7
 * Use and distribution licensed under the BSD license. See the
 
8
 * COPYING file in the root project directory for full text.
 
9
 */
 
10
 
 
11
/**
 
12
 * @file
 
13
 * @brief Common Declarations and Macros
 
14
 */
 
15
 
 
16
#ifndef SCALESTACK_COMMON_H
 
17
#define SCALESTACK_COMMON_H
 
18
 
 
19
#include <exception>
 
20
 
 
21
namespace ScaleStack
 
22
{
 
23
 
 
24
/**
 
25
 * Be sure to put SCALESTACK_API in front of all public API symbols, or one of
 
26
 * the other macros as appropriate. The default visibility without a macro is
 
27
 * to be hidden (SCALESTACK_LOCAL).
 
28
 */
 
29
 
 
30
#if defined(BUILDING_SCALESTACK) && defined(HAVE_VISIBILITY)
 
31
# if defined(__GNUC__)
 
32
#  define SCALESTACK_API __attribute__ ((visibility("default")))
 
33
#  define SCALESTACK_INTERNAL_API __attribute__ ((visibility("hidden")))
 
34
#  define SCALESTACK_API_DEPRECATED __attribute__ ((deprecated,visibility("default")))
 
35
#  define SCALESTACK_LOCAL  __attribute__ ((visibility("hidden")))
 
36
# elif (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)) || (defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550))
 
37
#  define SCALESTACK_API __global
 
38
#  define SCALESTACK_INTERNAL_API __hidden
 
39
#  define SCALESTACK_API_DEPRECATED __global
 
40
#  define SCALESTACK_LOCAL __hidden
 
41
# elif defined(_MSC_VER)
 
42
#  define SCALESTACK_API extern __declspec(dllexport)
 
43
#  define SCALESTACK_INTERNAL_API extern __declspec(dllexport)
 
44
#  define SCALESTACK_DEPRECATED_API extern __declspec(dllexport)
 
45
#  define SCALESTACK_LOCAL
 
46
# endif
 
47
#else  /* defined(BUILDING_SCALESTACK) && defined(HAVE_VISIBILITY) */
 
48
# if defined(_MSC_VER)
 
49
#  define SCALESTACK_API extern __declspec(dllimport)
 
50
#  define SCALESTACK_INTERNAL_API extern __declspec(dllimport)
 
51
#  define SCALESTACK_API_DEPRECATED extern __declspec(dllimport)
 
52
#  define SCALESTACK_LOCAL
 
53
# else
 
54
#  define SCALESTACK_API
 
55
#  define SCALESTACK_INTERNAL_API
 
56
#  define SCALESTACK_API_DEPRECATED
 
57
#  define SCALESTACK_LOCAL
 
58
# endif /* defined(_MSC_VER) */
 
59
#endif  /* defined(BUILDING_SCALESTACK) && defined(HAVE_VISIBILITY) */
 
60
 
 
61
/**
 
62
 * Macro that defines the current API version to use for interfaces.
 
63
 */
 
64
#define ScaleStackCurrentAPIVersion @LIBSCALESTACK_VERSION_CURRENT@
 
65
 
 
66
/**
 
67
 * Macro used for converting defined values into quoted strings.
 
68
 */
 
69
#define ScaleStackQuote(string) #string
 
70
#define ScaleStackQuoteValue(string) ScaleStackQuote(string)
 
71
 
 
72
/**
 
73
 * Macro to keep new exception declarations small, this should appeat in
 
74
 * header files.
 
75
 */
 
76
#define ScaleStackException(name) \
 
77
class SCALESTACK_API name: public std::exception \
 
78
{ \
 
79
public: \
 
80
  virtual const char* what() const throw(); \
 
81
}
 
82
 
 
83
/**
 
84
 * Macro for what() method for exceptions, this should appear in the source
 
85
 * files.
 
86
 */
 
87
#define ScaleStackExceptionMessage(name, message) \
 
88
  const char* name::what() const throw() { return message; } \
 
89
 
 
90
/**
 
91
 * Functor to use with containers of pointers when the objects should be
 
92
 * deleted.
 
93
 */
 
94
class DeletePointer
 
95
{
 
96
public:
 
97
  template<typename T>
 
98
  void operator()(const T* pointer) const
 
99
  {
 
100
    delete pointer;
 
101
  }
 
102
};
 
103
 
 
104
} /* namespace ScaleStack */
 
105
 
 
106
#endif /* SCALESTACK_COMMON_H */