GVariant: add support for single precision floats
[platform/upstream/glib.git] / gio / fen / fen-node.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim:set expandtab ts=4 shiftwidth=4: */
3 /* 
4  * Copyright (c) 2008, 2010 Oracle and/or its affiliates, Inc. All rights
5  * reserved.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General
18  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19  *
20  * Authors: Lin Ma <lin.ma@sun.com>
21  */
22
23 #include <port.h>
24 #include <gio/gio.h>
25
26 #ifndef _FEN_NODE_H_
27 #define _FEN_NODE_H_
28
29 #ifdef GIO_COMPILATION
30 #define FN_EVENT_CREATED G_FILE_MONITOR_EVENT_CREATED
31 #else
32 #define FN_EVENT_CREATED GAMIN_EVENT_CREATED
33 #endif
34
35 #define NODE_STATE_NONE       0x00000000
36 #define NODE_STATE_ASSOCIATED 0x00000001 /* This is a confilct to NODE_FLAG_STAT_DONE */
37 #define NODE_STATE_HAS_EVENTS 0x00000002
38
39 #define NODE_FLAG_NONE             0x00000000
40 #define NODE_FLAG_SNAPSHOT_UPDATED 0x00000001
41 #define NODE_FLAG_DIR              0x00000002
42 #define NODE_FLAG_STAT_UPDATED     0x00000004
43
44 #define NODE_CLE_STATE(f, st)  (f->state &= ~(st))
45 #define NODE_SET_STATE(f, st)  (f->state = ((f->state & ~(st)) | (st)))
46 #define NODE_HAS_STATE(f, st)  (f->state & (st))
47
48 #define NODE_CLE_FLAG(f, fl)  (f->flag &= ~(fl))
49 #define NODE_SET_FLAG(f, fl)  (f->flag = ((f->flag & ~(fl)) | (fl)))
50 #define NODE_HAS_FLAG(f, fl)  (f->flag & (fl))
51
52 typedef struct node node_t;
53 struct node
54 {
55     file_obj_t  fobj;           /* Inherit from file_obj_t, must be the first. */
56     GSource    *source;
57     gchar      *basename;
58     guint32     state;
59         guint32     flag;
60     GTimeVal    atv;            /* Timestamp for the first added sub. */
61
62         /* the parent and children of node */
63     node_t *parent;
64     GHashTable *children; /* children in basename */
65
66         /* List of subscriptions monitoring this fdata/path */
67         GList *subs;
68         GList *dir_subs;
69
70 #ifdef GIO_COMPILATION
71     GFile* gfile;
72 #endif
73 };
74
75 #define FILE_OBJECT(f)                ((file_obj_t *)(f))
76 #define NODE_NAME(f)                  (FILE_OBJECT(f)->fo_name)
77 #define NODE_PARENT(f)                (((node_t *)f)->parent)
78 #define NODE_IS_ACTIVE(f)             (f->dir_subs || f->subs)
79 #define NODE_IS_REQUIRED_BY_PARENT(f) (NODE_PARENT(f) && NODE_PARENT(f)->dir_subs)
80
81 gboolean node_timeval_lt(const GTimeVal *val1, const GTimeVal *val2);
82 gboolean node_try_delete(node_t* node);
83 void     node_traverse(node_t* node, void(*traverse_cb)(node_t*, gpointer), gpointer user_data);
84 node_t*  node_find(node_t* node, const gchar* filename, gboolean create_on_missing);
85 gint     node_lstat(node_t *f);
86 void     node_create_children_snapshot(node_t *f, gint created_event, gboolean emit);
87 void     node_adjust_deleted(node_t *f);
88 gboolean node_class_init();
89
90 typedef struct node_event
91 {
92     int e;
93     gpointer user_data;
94     gpointer pair_data;
95     GTimeVal ctv;               /* Created timestamp */
96     GTimeVal rename_tv;         /* Possible rename timestamp */
97 } node_event_t;
98
99 node_event_t* node_event_new (int event, gpointer user_data);
100 void node_event_delete (node_event_t* ev);
101
102 #endif /* _FEN_NODE_H_ */