Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / stable / src / synfig / nodebase.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file nodebase.h
3 **      \brief Template Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === S T A R T =========================================================== */
24
25 #ifndef __SYNFIG_NODEBASE_H
26 #define __SYNFIG_NODEBASE_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include "protocol.h"
31 #include "string.h"
32 #include "guid.h"
33 #include <sigc++/slot.h>
34
35 /* === M A C R O S ========================================================= */
36
37 #define PX_DEFINE_DATA(name,type) \
38     PX_DEFINE_FUNC_CONST0(get_##name, type) \
39     PX_DEFINE_FUNC1(set_##name, void, type)
40
41 #define PX_DEFINE_FUNC0(name,ret) \
42         sigc::slot< ret > _slot_##name; \
43         ret name() { \
44                 return _slot_##name(); \
45         }
46
47 #define PX_DEFINE_FUNC1(name,ret,type) \
48         sigc::slot< ret, type > _slot_##name; \
49         ret name(type v1) { \
50                 return _slot_##name(v1); \
51         }
52 #define PX_DEFINE_FUNC2(name,ret,type1,type2) \
53         sigc::slot< ret, type1, type2 > _slot_##name; \
54         ret name(type1 v1, type2 v2) { \
55                 return _slot_##name(v1,v2); \
56         }
57 #define PX_DEFINE_FUNC_CONST0(name,ret) \
58         sigc::slot< ret > _slot_##name##_const; \
59         ret name()const { \
60                 return _slot_##name##_const(); \
61         }
62
63 /* === T Y P E D E F S ===================================================== */
64
65 /* === C L A S S E S & S T R U C T S ======================================= */
66
67 namespace synfig {
68 namespace Proto {
69
70 typedef int Query;
71 typedef int NodeList;
72
73 class NodeBase : public Protocol
74 {
75 public:
76
77         PX_DEFINE_DATA(guid, GUID)
78
79         PX_DEFINE_FUNC2(func_test, float, int, int)
80
81         PX_DEFINE_DATA(id, String)
82
83         PX_DEFINE_DATA(root, NodeHandle)
84
85         PX_DEFINE_FUNC0(signal_changed, sigc::signal<void>)
86         PX_DEFINE_FUNC0(signal_deleted, sigc::signal<void>)
87                 
88         PX_DEFINE_FUNC_CONST0(get_parents, const NodeList)
89         PX_DEFINE_FUNC_CONST0(get_children, const NodeList)
90
91         PX_DEFINE_FUNC1(query_children, NodeList, Query)
92
93 }; // END of class Proto::NodeBase
94
95 }; // END of namespace Proto
96 }; // END of namespace synfig
97
98 /* === E N D =============================================================== */
99
100 #endif