taskrambler  0.1.9
Web server and task management solution.
hashable.c
Go to the documentation of this file.
1 /**
2  * \file
3  *
4  * \author Georg Hopp
5  *
6  * \copyright
7  * Copyright © 2012 Georg Hopp
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <stdarg.h>
26 
27 #include "class.h"
29 
30 const struct interface i_Hashable = {
31  "hashable",
32  2
33 };
34 
35 unsigned long
36 hashableGetHash(void * hashable)
37 {
38  unsigned long ret;
39 
40  //RETCALL(hashable, Hashable, getHash, ret);
41  do {
42  struct i_Hashable * iface;
43  //_CALL(GET_CLASS(hashable), Hashable, getHash);
44  do {
45  class_ptr class = GET_CLASS(hashable);
46  iface = (struct i_Hashable *)IFACE_GET(class, &i_Hashable);
47  while ((NULL == iface || NULL == iface->getHash) && HAS_PARENT(class)) {
48  class = class->parent;
49  iface = (struct i_Hashable *)IFACE_GET(class, &i_Hashable);
50  }
51  assert(NULL != iface->getHash);
52  } while(0);
53 
54  ret = iface->getHash(hashable);
55  } while(0);
56 
57 
58  return ret;
59 }
60 
61 void
62 hashableHandleDouble(void * hashable, void * new_hashable)
63 {
64  CALL(hashable, Hashable, handleDouble, new_hashable);
65 }
66 
67 // vim: set ts=4 sw=4:
fptr_hashableGetHash getHash
Definition: hashable.h:36
#define CALL(object, _iface, method,...)
Definition: class/class.h:106
unsigned long hashableGetHash(void *hashable)
Definition: hashable.c:36
void hashableHandleDouble(void *hashable, void *new_hashable)
Definition: hashable.c:62
fptr_hashableHandleDouble handleDouble
Definition: hashable.h:37
#define IFACE_GET(class, iface)
Definition: class/class.h:85
#define HAS_PARENT(class)
Definition: class/class.h:86