~ubuntu-branches/ubuntu/saucy/libee/saucy

« back to all changes in this revision

Viewing changes to include/libee/valnode.h

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2010-12-11 12:37:09 UTC
  • Revision ID: james.westby@ubuntu.com-20101211123709-i8v7mpdtzhgjoqn5
Tags: upstream-0.1.0
ImportĀ upstreamĀ versionĀ 0.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @file valnode.h
 
3
 * @brief An object to represent a value node inside a list of values.
 
4
 * @class ee_valnode valnode.h
 
5
 *
 
6
 *//*
 
7
 *
 
8
 * Libee - An Event Expression Library inspired by CEE
 
9
 * Copyright 2010 by Rainer Gerhards and Adiscon GmbH.
 
10
 *
 
11
 * This file is part of libee.
 
12
 *
 
13
 * This library is free software; you can redistribute it and/or
 
14
 * modify it under the terms of the GNU Lesser General Public
 
15
 * License as published by the Free Software Foundation; either
 
16
 * version 2.1 of the License, or (at your option) any later version.
 
17
 *
 
18
 * This library is distributed in the hope that it will be useful,
 
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
21
 * Lesser General Public License for more details.
 
22
 *
 
23
 * You should have received a copy of the GNU Lesser General Public
 
24
 * License along with this library; if not, write to the Free Software
 
25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
26
 *
 
27
 * A copy of the LGPL v2.1 can be found in the file "COPYING" in this distribution.
 
28
 */
 
29
#ifndef LIBEE_VALNODE_H_INCLUDED
 
30
#define LIBEE_VALNODE_H_INCLUDED
 
31
 
 
32
/**
 
33
 * An object to represent node inside a list of values.
 
34
 * This probably will only be used inside fields, but I have
 
35
 * created a separate class because I envision some other potential
 
36
 * uses for it.
 
37
 * This is NOT a core CEE object, but rather a libee helper entity.
 
38
 */
 
39
struct ee_valnode {
 
40
        unsigned objID;
 
41
                /**< a magic number to prevent some memory adressing errors */
 
42
        struct ee_value *val;
 
43
        struct ee_valnode *next;
 
44
};
 
45
 
 
46
/**
 
47
 * Constructor for the ee_valnode object.
 
48
 *
 
49
 * @memberof ee_valnode
 
50
 * @public
 
51
 *
 
52
 * @return new object or NULL if an error occured
 
53
 */
 
54
static inline struct ee_valnode*
 
55
ee_newValnode(void)
 
56
{
 
57
        struct ee_valnode* valnode;
 
58
        if((valnode = malloc(sizeof(struct ee_valnode))) == NULL) goto done;
 
59
        valnode->objID = ObjID_VALNODE;
 
60
        valnode->next = NULL;
 
61
done:
 
62
        return valnode;
 
63
}
 
64
 
 
65
 
 
66
/**
 
67
 * Destructor for the ee_valnode object.
 
68
 * Note: only the single object is destructed, \b not the complete node.
 
69
 * So the caller must ensure the last will not be broken.
 
70
 *
 
71
 * @memberof ee_valnode
 
72
 * @public
 
73
 *
 
74
 * @param valnode The valnode to be discarded.
 
75
 */
 
76
void ee_deleteValnode(struct ee_valnode *valnode);
 
77
 
 
78
 
 
79
#endif /* #ifndef LIBEE_VALNODE_H_INCLUDED */