1 /********************************************************************\
2 * gncJob.h -- the Core Job Interface *
3 * *
4 * This program is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU General Public License as *
6 * published by the Free Software Foundation; either version 2 of *
7 * the License, or (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License*
15 * along with this program; if not, contact: *
16 * *
17 * Free Software Foundation Voice: +1-617-542-5942 *
18 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19 * Boston, MA 02110-1301, USA gnu@gnu.org *
20 * *
21 \********************************************************************/
22 /** @addtogroup Business
23 @{ */
24 /** @addtogroup Job
25 @{ */
26 /** @file gncJob.h
27 @brief Job Interface
28 @author Copyright (C) 2001, 2002 Derek Atkins <warlord@MIT.EDU>
29 */
30
31 #ifndef GNC_JOB_H_
32 #define GNC_JOB_H_
33
34 typedef struct _gncJob GncJob;
35 typedef struct _gncJobClass GncJobClass;
36
37 #include "gncAddress.h"
38 #include "gncOwner.h"
39
40 #define GNC_ID_JOB "gncJob"
41
42 /* --- type macros --- */
43 #define GNC_TYPE_JOB (gnc_job_get_type ())
44 #define GNC_JOB(o) \
45 (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_JOB, GncJob))
46 #define GNC_JOB_CLASS(k) \
47 (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_JOB, GncJobClass))
48 #define GNC_IS_JOB(o) \
49 (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_JOB))
50 #define GNC_IS_JOB_CLASS(k) \
51 (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_JOB))
52 #define GNC_JOB_GET_CLASS(o) \
53 (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_JOB, GncJobClass))
54 GType gnc_job_get_type(void);
55
56 /* Create/Destroy Functions */
57
58 GncJob *gncJobCreate (QofBook *book);
59 void gncJobDestroy (GncJob *job);
60
61 /** \name Set Functions
62 @{
63 */
64
65 void gncJobSetID (GncJob *job, const char *id);
66 void gncJobSetName (GncJob *job, const char *jobname);
67 void gncJobSetReference (GncJob *job, const char *owner_reference);
68 void gncJobSetRate (GncJob *job, gnc_numeric rate);
69 void gncJobSetOwner (GncJob *job, GncOwner *owner);
70 void gncJobSetActive (GncJob *job, gboolean active);
71
72 /** @} */
73 void gncJobBeginEdit (GncJob *job);
74 void gncJobCommitEdit (GncJob *job);
75
76 /** \name Get Functions
77 @{
78 */
79
80 const char * gncJobGetID (const GncJob *job);
81 const char * gncJobGetName (const GncJob *job);
82 const char * gncJobGetReference (const GncJob *job);
83 gnc_numeric gncJobGetRate (const GncJob *job);
84 GncOwner * gncJobGetOwner (GncJob *job);
85 gboolean gncJobGetActive (const GncJob *job);
86
87 /** @} */
88
89 /** Return a pointer to the instance gncJob that is identified
90 * by the guid, and is residing in the book. Returns NULL if the
91 * instance can't be found.
92 * Equivalent function prototype is
93 * GncJob * gncJobLookup (QofBook *book, const GncGUID *guid);
94 */
gncJobLookup(const QofBook * book,const GncGUID * guid)95 static inline GncJob * gncJobLookup (const QofBook *book, const GncGUID *guid)
96 {
97 QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_JOB, GncJob);
98 }
99
100 /* Other functions */
101
102 int gncJobCompare (const GncJob *a, const GncJob *b);
103 gboolean gncJobEqual(const GncJob *a, const GncJob *b);
104
105 #define JOB_ID "id"
106 #define JOB_NAME "name"
107 #define JOB_REFERENCE "reference"
108 #define JOB_RATE "rate"
109 #define JOB_OWNER "owner"
110 #define Q_JOB_OWNER "owner_collection"
111 #define JOB_ACTIVE "active"
112
113 /** deprecated functions */
114 #define gncJobGetBook(x) qof_instance_get_book(QOF_INSTANCE(x))
115 #define gncJobGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
116 #define gncJobRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()))
117 #define gncJobLookupDirect(G,B) gncJobLookup((B),&(G))
118
119 #endif /* GNC_JOB_H_ */
120 /** @} */
121 /** @} */
122