summaryrefslogtreecommitdiff
path: root/include/globals.h
blob: 125b6a485800485b0455c70bebc4e82fee56df1e (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
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
/**
 *  Globals.h
 *
 *  Wrapper object that gives access to all global variables. You
 *  can use it more or less the same as the $_GLOBALS object in
 *  PHP.
 *
 *  The global PHP variables are acessible via the Php::globals["varname"]
 *  variables.
 *
 *  @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
 *  @copyright 2013 Copernica BV
 */

/**
 *  Set up namespace
 */
namespace Php {

/**
 *  Forward definitions
 */
class Global;

/**
 *  Class definition
 */
class PHPCPP_EXPORT Globals
{
public:
    /**
     *  Disable copy and move operations
     */
    Globals(const Globals &globals) = delete;
    Globals(Globals &&globals) = delete;

    /**
     *  Destructor
     */
    virtual ~Globals() {}

    /**
     *  Get access to a global variable
     *  @param  name
     *  @return Global
     */
    Global operator[](const char *name);

    /**
     *  Get access to a global variable
     *  @param  name
     *  @return Global
     */
    Global operator[](const std::string &name);

private:
    /**
     *  Constructor
     */
    Globals() {}

public:
    /**
     *  Get the one and only instance
     *  @return Globals
     */
    static Globals &instance();
};

/**
 *  We always have one instance of the GLOBALS instance
 *  @var    Globals
 */
extern PHPCPP_EXPORT Globals &GLOBALS;

/**
 *  End of namespace
 */
}