source: tags/ms_r16q2/AISC_COM/C/aisc_global.h

Last change on this file was 8814, checked in by westram, 12 years ago
  • fixed some warnings in NDEBUG mode (unused warnings)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : aisc_global.h                                     //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Coded by Ralf Westram (coder@reallysoft.de) in May 2007       //
7//   Institute of Microbiology (Technical University Munich)       //
8//   http://www.arb-home.de/                                       //
9//                                                                 //
10// =============================================================== //
11#ifndef AISC_GLOBAL_H
12#define AISC_GLOBAL_H
13
14#ifndef BYTESTRING_H
15#include <bytestring.h>
16#endif
17#ifndef ARBTOOLS_H
18#include <arbtools.h>
19#endif
20#ifndef ATTRIBUTES_H
21#include <attributes.h>
22#endif
23#ifndef ARB_ASSERT_H
24#include <arb_assert.h>
25#endif
26
27#define aisc_assert(cond) arb_assert(cond)
28
29// type mask
30#define AISC_TYPE_NONE   0x00000000
31#define AISC_TYPE_INT    0x01000000
32#define AISC_TYPE_DOUBLE 0x02000000
33#define AISC_TYPE_STRING 0x03000000
34#define AISC_TYPE_COMMON 0x04000000
35#define AISC_TYPE_BYTES  0x05000000
36
37#define AISC_VAR_TYPE_MASK 0xff000000
38#define AISC_OBJ_TYPE_MASK 0x00ff0000
39#define AISC_ATTR_MASK     0x0000ffff
40
41#define AISC_INDEX       0x1ff0000
42#define AISC_NO_ANSWER  -0x7fffffff
43
44#define AISC_COMMON      0
45
46union double_xfer { // workaround aliasing problems
47    double as_double;
48    int    as_int[2];
49};
50
51class AISC_Object : public Noncopyable {
52    int  type_id;
53    long remote_ptr; // this is a pointer to client-data in server-address-space (casted to long)
54
55    void *operator&() { return 0; } // forbid error-prone idiom (AISC_Object just was 'long' in the past). Instead use as_result_param()
56
57protected:
58
59    void set(int IF_ASSERTION_USED(remoteType), long remotePtr) { aisc_assert(remoteType == type_id); remote_ptr = remotePtr; }
60
61public:
62    AISC_Object(int type_) : type_id(type_), remote_ptr(0) {}
63
64    bool exists() const { return remote_ptr; }
65    long get() const { return remote_ptr; }
66    int type() const { return type_id; }
67
68    void clear() { remote_ptr = 0; }
69    void init(long remotePtr) { aisc_assert(!exists()); set(type_id, remotePtr); }
70
71    long *as_result_param() { return &remote_ptr; }
72
73};
74
75#else
76#error aisc_global.h included twice
77#endif // AISC_GLOBAL_H
78
Note: See TracBrowser for help on using the repository browser.