/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
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
#ifndef __H_BOX__
#define __H_BOX__
#include "defs.h"
#include "baseobject.h"
#include "Func.h"

/** @file
 * An SBox is a boxed type.
 */

BEGIN_DECLS

/** @brief
 * A reference counted box sitting on top of an SObject
 */
typedef struct SBox SBox;

typedef struct SBoxClass SBoxClass;

typedef struct SBoxPrivate SBoxPrivate;

struct SBox {
  SObject parent;
  SBoxPrivate * priv;
};

struct SBoxClass {
  SObjectClass parent_class;
};

/**
 * Creates a new SBox object.
 * 
 * @param object The object to be boxed.
 * @param type The type of object that is being boxed.
 * @param freefunc The Function to be used when freeing the boxed object.
 *
 * @return A new SBox object.
 *
 * @note if freefunc is NULL, then standard free() will be used.
 */
SBox * s_box_new (spointer object, SType type, FreeFunc freefunc);

/**
 * Free the an SBox.
 *
 * @param box The SBox to be freed.
 *
 * @warn Freeing an SBox will free the object that is held by it.
 */
void s_box_free (SBox * box);

/**
 * Get the object that is contained inside the SBox.
 *
 * @param box The SBox to get the object from.
 *
 * @return a pointer to the object.
 */
spointer s_box_get_object (SBox * box);

/**
 * Gets the SType of the object that is stored in the SBox.
 */
SType s_box_get_object_type (SBox * box);

/**
 * Gets the type name of the object.
 *
 * @param box The SBox to get the type name from.
 * @return A String containing the name of the type.
 * 
 * @warn caller must free the string.
 */
char * s_box_get_object_type_name (SBox * box);

END_DECLS

#endif