/camera/camlib

To get this branch, use:
bzr branch http://darksoft.org/webbzr/camera/camlib

« back to all changes in this revision

Viewing changes to include/pftypes.h

  • Committer: Suren A. Chilingaryan
  • Date: 2011-02-13 01:33:37 UTC
  • Revision ID: csa@dside.dyndns.org-20110213013337-ibm4w4n5a3hu4k7u
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** \file pftypes.h
 
2
 *
 
3
 * Photonfocus API data types
 
4
 *
 
5
 * These are datatypes that have to be exported to the API.
 
6
 *
 
7
 * WARNING: Changes in these data structures may affect
 
8
 * API binary compatibility. If this is the case, the major library
 
9
 * version number must be increased.
 
10
 */
 
11
 
 
12
#ifndef PFTYPES_H_INCLUDED_260872
 
13
#define PFTYPES_H_INCLUDED_260872
 
14
 
 
15
#define TOKEN unsigned long
 
16
#if defined (SM2_DSP)
 
17
        #define MAX_CAMERAS 7
 
18
#else
 
19
        #define MAX_CAMERAS 32
 
20
#endif
 
21
/** Invalid token value. When returned from pfProperty_ParseName(),
 
22
 * a property of that name was not found. Note that pfDevice_GetRoot()
 
23
 * may return the same value as INVALID_TOKEN, which is normal. */
 
24
#define INVALID_TOKEN 0
 
25
 
 
26
 
 
27
/** 
 
28
 *  Property data types
 
29
 */
 
30
 
 
31
typedef enum {
 
32
        PF_INVALID,
 
33
        PF_ROOT,     ///< ROOT NODE TYPE
 
34
        PF_INT,      ///< A 32 bit signed integer
 
35
        PF_FLOAT,    ///< A 4 byte float, single precision
 
36
        PF_BOOL,     ///< A boolean value (1: true, 0: false)
 
37
        PF_MODE,     ///< A mode value. Only the values in the choice are valid.
 
38
        PF_REGISTER, ///< A register value (direct register export)
 
39
        PF_STRING,   ///< A string value (constant or fixed lengh, 0 terminated)
 
40
        PF_BUFFER,   ///< A buffer value. The length is specified in the len field.
 
41
        // Meta types:
 
42
        PF_STRUCT,   ///< A struct value containing other properties
 
43
        PF_ARRAY,    ///< An array value, containing a struct or property
 
44
        // Special:
 
45
        PF_COMMAND,  ///< A command
 
46
        PF_EVENT    ///< An event node.
 
47
} PropertyType;
 
48
 
 
49
 
 
50
/** Property flags
 
51
 *
 
52
 * These flags are queried via pfProperty_GetFlags().
 
53
 *
 
54
 * All other bits are reserved for internal purposes.
 
55
 *
 
56
 */
 
57
 
 
58
#define F_PRIVATE  0x02    ///< Property is private
 
59
#define F_BIG      0x04    ///< Big endian, if Register node
 
60
#define F_RW       0x00    ///< Readable/Writeable
 
61
#define F_RO       0x10    ///< Readonly
 
62
#define F_WO       0x20    ///< Writeonly
 
63
#define F_INACTIVE 0x40    ///< Property is currently inactive
 
64
 
 
65
 
 
66
/** Run time information data type.
 
67
 *
 
68
 * This contains a value union and a type field
 
69
 *
 
70
 * A PFValue is to be initialized as follows:
 
71
 * 
 
72
   \code v.type = <type>; v.value.<valuefield> = <value> \endcode
 
73
 *
 
74
 * For example, see macros #SET_FLOAT, etc.
 
75
 *
 
76
 * In case of a string or buffer value, it is important to know that
 
77
 * the data buffer is not owned by the property structure, i.e. the
 
78
 * PFValue only serves as a descriptor and no value copying actually
 
79
 * happens.
 
80
 * Therefore, the programmer has to distinguish between two cases
 
81
 * before querying a property via pfDevice_GetProperty()
 
82
 *
 
83
 * \li The property is static (fixed length): The caller does not have to
 
84
 *     worry about pointer initialization of the PFValue before calling
 
85
 *     pfDevice_GetProperty()
 
86
 * \li The property is dynamic (read/write) and the caller *must*
 
87
 *     initialize the value buffer.
 
88
 *
 
89
 * For a dynamic string, the initialization would look as follows:
 
90
 *
 
91
\code 
 
92
#define BUF_LEN 80
 
93
        PFValue v;
 
94
        char buffer[BUF_LEN];
 
95
 
 
96
        v.type = PF_STRING;
 
97
        v.len = BUF_LEN;
 
98
        v.value.p = buffer;
 
99
 
 
100
        pfDevice_GetProperty(d, property, &v);
 
101
        // ...
 
102
        //
 
103
\endcode
 
104
 * Note that in this example, the (zero terminated) string has a maximum
 
105
 * length of 79.
 
106
 *
 
107
 * If there was not enough space reserved for the property buffer,
 
108
 * an error #PFERR_PROPERTY_SIZE_MATCH is returned from pfGetProperty()
 
109
 *
 
110
 * Data type checking is performed when setting properties.
 
111
 */
 
112
 
 
113
typedef struct 
 
114
{
 
115
        union{
 
116
                long i;         ///< Union: Integer value
 
117
                float f;        ///< Union: Float value
 
118
                void *p;        ///< Union: Generic Pointer value
 
119
        } value;
 
120
        PropertyType type;      ///< Value Type
 
121
        int len;                ///< length of array, if type is a buffer
 
122
} PFValue;
 
123
 
 
124
/**
 
125
 * \ingroup Misc
 
126
 *
 
127
 * Initialize float PFValue */
 
128
#define SET_FLOAT(v, f) v.type = PF_FLOAT; v.value.f = f
 
129
/**
 
130
 * \ingroup Misc
 
131
 *
 
132
 * Initialize integer PFValue */
 
133
#define SET_INT(v, i)   v.type = PF_INT; v.value.f = i
 
134
 
 
135
/**
 
136
 * \ingroup Misc
 
137
 *
 
138
 * Initialize string PFValue */
 
139
#define SET_STRING(v, s, l)   v.type = PF_STRING; v.value.p = (void *) s; \
 
140
                              v.len = l;
 
141
 
 
142
 
 
143
/** 
 
144
 * \ingroup Misc
 
145
 *
 
146
 * Property callback function for recursive node walker.
 
147
 * See source code for detailed information.
 
148
 *
 
149
 * \param t      The current node token
 
150
 *
 
151
 * \return 1: success, continue walking
 
152
 *         0: quit walking.
 
153
 */
 
154
 
 
155
typedef int (PropCallback)(TOKEN t);
 
156
 
 
157
/**
 
158
 * Feedback function pointer definition
 
159
 *
 
160
 * See pfSetFeedback() in pfcam.h
 
161
 */
 
162
 
 
163
typedef int (*FeedbackFuncP)(int i);
 
164
 
 
165
#endif // PFTYPES_H_INCLUDED_260872