/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcilib/view.h

  • Committer: Suren A. Chilingaryan
  • Date: 2015-10-18 01:47:47 UTC
  • Revision ID: csa@suren.me-20151018014747-9ji2ygdhz1l9wnt5
Support properties of arbitrary type

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
} pcilib_view_flags_t;
17
17
 
18
18
typedef struct {
19
 
    pcilib_version_t version;
20
 
    size_t description_size;
21
 
    pcilib_view_context_t *(*init)(pcilib_t *ctx);
22
 
    void (*free)(pcilib_t *ctx, pcilib_view_context_t *view);
23
 
    void (*free_description)(pcilib_t *ctx, pcilib_view_description_t *view);
24
 
    int (*read_from_reg)(pcilib_t *ctx, pcilib_view_context_t *view, pcilib_register_value_t regval, pcilib_value_t *val);
25
 
    int (*write_to_reg)(pcilib_t *ctx, pcilib_view_context_t *view, pcilib_register_value_t *regval, const pcilib_value_t *val);
 
19
    pcilib_version_t version;                                                                                                           /**< Version */
 
20
    size_t description_size;                                                                                                            /**< The actual size of the description */
 
21
    pcilib_view_context_t *(*init)(pcilib_t *ctx);                                                                                      /**< Optional function which should allocated context used by read/write functions */
 
22
    void (*free)(pcilib_t *ctx, pcilib_view_context_t *view);                                                                           /**< Optional function which should clean context */
 
23
    void (*free_description)(pcilib_t *ctx, pcilib_view_description_t *view);                                                           /**< Optional function which shoud clean required parts of the extended description if non-static memory was used to initialize it */
 
24
    int (*read_from_reg)(pcilib_t *ctx, pcilib_view_context_t *view, pcilib_register_value_t regval, pcilib_value_t *val);              /**< Function which computes view value based on the passed the register value (view-based properties should not use register value) */
 
25
    int (*write_to_reg)(pcilib_t *ctx, pcilib_view_context_t *view, pcilib_register_value_t *regval, const pcilib_value_t *val);        /**< Function which computes register value based on the passed value (view-based properties are not required to set the register value) */
26
26
} pcilib_view_api_description_t;
27
27
 
28
28
struct pcilib_view_description_s {
29
29
    const pcilib_view_api_description_t *api;
30
30
    pcilib_value_type_t type;                                                   /**< The default data type returned by operation, PCILIB_VIEW_TYPE_STRING is supported by all operations */
31
 
    pcilib_view_flags_t flags;                                                  /**< Flags specifying type of the view */
 
31
    pcilib_access_mode_t mode;                                                  /**< Specifies if the view is read/write-only */
32
32
    const char *unit;                                                           /**< Returned unit (if any) */
33
33
    const char *name;                                                           /**< Name of the view */
34
34
    const char *description;                                                    /**< Short description */
37
37
struct pcilib_view_context_s {
38
38
    const char *name;
39
39
    pcilib_view_t view;
 
40
    pcilib_view_flags_t flags;                                                  /**< Flags specifying type of the view */
40
41
    UT_hash_handle hh;
41
42
};
42
43
 
44
45
extern "C" {
45
46
#endif
46
47
 
 
48
/**
 
49
 * Use this function to add new view definitions into the model. It is error to re-register
 
50
 * already registered view. The function will copy the context of unit description, but name, 
 
51
 * transform, and other strings in the structure are considered to have static duration 
 
52
 * and will not be copied. On error no new views are initalized.
 
53
 * @param[in,out] ctx - pcilib context
 
54
 * @param[in] n - number of views to initialize. It is OK to pass 0 if protocols variable is NULL terminated (last member of protocols array have all members set to 0)
 
55
 * @param[in] desc - view descriptions
 
56
 * @return - error or 0 on success
 
57
 */
47
58
int pcilib_add_views(pcilib_t *ctx, size_t n, const pcilib_view_description_t *desc);
48
 
void pcilib_clean_views(pcilib_t *ctx);
 
59
 
 
60
/**
 
61
 * Destroys data associated with views. This is an internal function and will
 
62
 * be called during clean-up.
 
63
 * @param[in,out] ctx - pcilib context
 
64
 * @param[in] start - specifies first view to clean (used to clean only part of the views to keep the defined state if pcilib_add_views has failed)
 
65
 */
 
66
void pcilib_clean_views(pcilib_t *ctx, pcilib_view_t start);
49
67
 
50
68
pcilib_view_context_t *pcilib_find_view_context_by_name(pcilib_t *ctx, const char *view);
51
69
pcilib_view_context_t *pcilib_find_register_view_context_by_name(pcilib_t *ctx, pcilib_register_t reg, const char *name);