libtrbase  1.0.2
Web server and task management solution.
indexable.h
Go to the documentation of this file.
1 /**
2  * \file
3  * This interface provides only one function at all.
4  * indexUuid will generate a uuid to the current object.
5  *
6  * This one is not generic enough for an interface...I
7  * don't want to rely on Uuid here....The Uuid stuff is more
8  * an implementation of this interface.
9  *
10  * An implementation of indexable::index should always return
11  * an instance of class Index / or an class that implements
12  * the index interface. Uuid would then be a candidate for such
13  * a class.
14  *
15  * \todo
16  * Maybe merge hashable and indexable. Thus we might get an
17  * easy way to exchange the hashing mechanism used for my
18  * associative arrays.
19  *
20  * \author Georg Hopp
21  *
22  * \copyright
23  * Copyright © 2014 Georg Hopp
24  *
25  * This program is free software: you can redistribute it and/or modify
26  * it under the terms of the GNU General Public License as published by
27  * the Free Software Foundation, either version 3 of the License, or
28  * (at your option) any later version.
29  *
30  * This program is distributed in the hope that it will be useful,
31  * but WITHOUT ANY WARRANTY; without even the implied warranty of
32  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33  * GNU General Public License for more details.
34  *
35  * You should have received a copy of the GNU General Public License
36  * along with this program. If not, see <http://www.gnu.org/licenses/>.
37  */
38 
39 #ifndef __TR_INTERFACE_INDEXABLE_H__
40 #define __TR_INTERFACE_INDEXABLE_H__
41 
42 #include "tr/interface.h"
43 
44 
45 typedef void * (* fptr_TR_getIndex)(void *);
46 
47 TR_INTERFACE(TR_Indexable) {
48  TR_IFID;
49  fptr_TR_getIndex index;
50 };
51 
52 /**
53  * Get it's index from an indexable object.
54  */
55 inline
56 void *
57 TR_getIndex(void * indexable)
58 {
59  void * ret;
60  TR_RETCALL(indexable, TR_Indexable, index, ret);
61  return ret;
62 }
63 
64 #endif // __TR_INTERFACE_INDEXABLE_H__
65 
66 // vim: set ts=4 sw=4:
#define TR_RETCALL(object, _iface, method, ret,...)
Definition: class.h:270
#define TR_IFID
Definition: interface.h:61
TR_INTERFACE(TR_Indexable)
Definition: indexable.h:47
void *(* fptr_TR_getIndex)(void *)
Definition: indexable.h:45
void * TR_getIndex(void *indexable)
Definition: indexable.h:57