tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
customer.h
Go to the documentation of this file.
1 /* =============================================================================
2  *
3  * customer.h
4  * -- Representation of customer
5  *
6  * =============================================================================
7  *
8  * Copyright (C) Stanford University, 2006. All Rights Reserved.
9  * Author: Chi Cao Minh
10  *
11  * =============================================================================
12  *
13  * For the license of bayes/sort.h and bayes/sort.c, please see the header
14  * of the files.
15  *
16  * ------------------------------------------------------------------------
17  *
18  * For the license of kmeans, please see kmeans/LICENSE.kmeans
19  *
20  * ------------------------------------------------------------------------
21  *
22  * For the license of ssca2, please see ssca2/COPYRIGHT
23  *
24  * ------------------------------------------------------------------------
25  *
26  * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
27  * header of the files.
28  *
29  * ------------------------------------------------------------------------
30  *
31  * For the license of lib/rbtree.h and lib/rbtree.c, please see
32  * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
33  *
34  * ------------------------------------------------------------------------
35  *
36  * Unless otherwise noted, the following license applies to STAMP files:
37  *
38  * Copyright (c) 2007, Stanford University
39  * All rights reserved.
40  *
41  * Redistribution and use in source and binary forms, with or without
42  * modification, are permitted provided that the following conditions are
43  * met:
44  *
45  * * Redistributions of source code must retain the above copyright
46  * notice, this list of conditions and the following disclaimer.
47  *
48  * * Redistributions in binary form must reproduce the above copyright
49  * notice, this list of conditions and the following disclaimer in
50  * the documentation and/or other materials provided with the
51  * distribution.
52  *
53  * * Neither the name of Stanford University nor the names of its
54  * contributors may be used to endorse or promote products derived
55  * from this software without specific prior written permission.
56  *
57  * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
58  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
61  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
62  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
63  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
64  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
65  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
67  * THE POSSIBILITY OF SUCH DAMAGE.
68  *
69  * =============================================================================
70  */
71 
72 
73 #ifndef CUSTOMER_H
74 #define CUSTOMER_H 1
75 
76 
77 #include "list.h"
78 #include "reservation.h"
79 #include "tm.h"
80 #include "types.h"
81 
82 typedef struct customer {
83  long id;
85 } customer_t;
86 
87 
88 /* =============================================================================
89  * customer_alloc
90  * =============================================================================
91  */
94 customer_alloc (TM_ARGDECL long id);
95 
97 customer_alloc_seq (long id);
98 
99 
100 /* =============================================================================
101  * customer_compare
102  * -- Returns -1 if A < B, 0 if A = B, 1 if A > B
103  * =============================================================================
104  */
105 long
106 customer_compare (customer_t* aPtr, customer_t* bPtr);
107 
108 
109 /* =============================================================================
110  * customer_hash
111  * =============================================================================
112  */
113 unsigned long
114 customer_hash (customer_t* customerPtr);
115 
116 
117 /* =============================================================================
118  * customer_free
119  * =============================================================================
120  */
122 void
123 customer_free (TM_ARGDECL customer_t* customerPtr);
124 
125 
126 /* =============================================================================
127  * customer_addReservationInfo
128  * -- Returns TRUE if success, else FALSE
129  * =============================================================================
130  */
132 bool_t
134  customer_t* customerPtr,
135  reservation_type_t type, long id, long price);
136 
137 bool_t
139  reservation_type_t type, long id, long price);
140 
141 
142 /* =============================================================================
143  * customer_removeReservationInfo
144  * -- Returns TRUE if success, else FALSE
145  * =============================================================================
146  */
148 bool_t
150  customer_t* customerPtr,
151  reservation_type_t type, long id);
152 
153 
154 /* =============================================================================
155  * customer_getBill
156  * -- Returns total cost of reservations
157  * =============================================================================
158  */
160 long
161 customer_getBill (TM_ARGDECL customer_t* customerPtr);
162 
163 long
164 customer_getBill_seq (customer_t* customerPtr);
165 
166 
167 #define CUSTOMER_ALLOC(id) \
168  customer_alloc(TM_ARG id)
169 #define CUSTOMER_ADD_RESERVATION_INFO(cust, type, id, price) \
170  customer_addReservationInfo(TM_ARG cust, type, id, price)
171 #define CUSTOMER_REMOVE_RESERVATION_INFO(cust, type, id) \
172  customer_removeReservationInfo(TM_ARG cust, type, id)
173 #define CUSTOMER_GET_BILL(cust) \
174  customer_getBill(TM_ARG cust)
175 #define CUSTOMER_FREE(cust) \
176  customer_free(TM_ARG cust)
177 
178 
179 #endif /* CUSTOMER_H */
180 
181 
182 /* =============================================================================
183  *
184  * End of customer.h
185  *
186  * =============================================================================
187  */
#define TM_CALLABLE
Definition: cxxtm.hpp:32
TM_CALLABLE bool_t customer_addReservationInfo(TM_ARGDECL customer_t *customerPtr, reservation_type_t type, long id, long price)
Definition: customer.c:178
TM_CALLABLE void customer_free(TM_ARGDECL customer_t *customerPtr)
Definition: customer.c:163
bool_t customer_addReservationInfo_seq(customer_t *customerPtr, reservation_type_t type, long id, long price)
TM_CALLABLE bool_t customer_removeReservationInfo(TM_ARGDECL customer_t *customerPtr, reservation_type_t type, long id)
Definition: customer.c:200
int bool_t
Definition: portable_defns.h:32
long customer_compare(customer_t *aPtr, customer_t *bPtr)
Definition: customer.c:152
#define TM_ARGDECL
Definition: tm.h:532
TM_CALLABLE long customer_getBill(TM_ARGDECL customer_t *customerPtr)
Definition: customer.c:239
long id
Definition: customer.h:83
enum reservation_type reservation_type_t
unsigned long customer_hash(customer_t *customerPtr)
list_t * reservationInfoListPtr
Definition: customer.h:84
Definition: list.h:93
struct customer customer_t
customer_t * customer_alloc_seq(long id)
Definition: customer.c:130
Definition: customer.h:82
long customer_getBill_seq(customer_t *customerPtr)
TM_CALLABLE customer_t * customer_alloc(TM_ARGDECL long id)
Definition: customer.c:113