Start building a class to enable clustering of files.
[geeqie.git] / src / filecluster.h
1 /*
2  * Copyright (C) 2008 - 2016 The Geeqie Team
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 #ifndef FILECLUSTER_H
20 #define FILECLUSTER_H
21
22 #include "main.h"
23
24 typedef struct _FileCluster FileCluster;
25 typedef struct _FileClusterList FileClusterList;
26
27 // A FileCluster is a GList with HashTable access to each node (to perform contains() checks quickly).
28 struct _FileCluster
29 {
30         GList *head;
31         GList *items;
32 };
33
34 struct _FileClusterList
35 {
36         // All of the elements in the list, regardless of whether they're part of a cluster or not.
37         GList *fd_list;
38
39         // A map from any clustered FileData to the FileCluster object that describes the cluster.
40         GHashTable *clusters;
41 };
42
43 FileClusterList *fileclusterlist_new();
44 FileCluster *filecluster_new();  // internal?
45 void fileclusterlist_free(FileClusterList *fcl);
46 void filecluster_free(FileCluster *fc);
47
48 // Creates a cluster with items that must already be in the cluster list.  Will fail (and make no
49 // changes) if any of the specified items isn't in the list, or if any of the items is already
50 // part of a different cluster.
51 FileCluster *fileclusterlist_create_cluster(FileClusterList *fcl, GList *fd_items);
52
53 gboolean fileclusterlist_has_head(FileClusterList *fcl, FileData *fd);
54 gboolean fileclusterlist_has_child(FileClusterList *fcl, FileData *fd);
55
56
57 #endif  // FILECLUSTER_H