summaryrefslogtreecommitdiffstats
path: root/kipi-plugins/sync/libkipi2/collection.h
blob: 8ebd4d0930437b55a2b1a6be79d7a2301254c740 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* ============================================================
 * File  : collection.h
 * Author: Colin Guthrie <kde@colin.guthr.ie>
 * Date  : 2007-01-26
 *
 * Copyright 2007 by Colin Guthrie <kde@colin.guthr.ie>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * ============================================================ */

#ifndef KIPI2_COLLECTION_H
#define KIPI2_COLLECTION_H

#include <tqvaluelist.h>

namespace KIPI2
{
  enum Features
  {
    None = 0,
    Comments = 1,
    SubCollections = 2,
    ItemComments = 4,
    NewSubCollections = 8,
    NewItems = 16
  };
  
  // Forward declarations
  class Collection;
  class Item;
  
  // Some list definitions
  typedef TQValueList<Collection*> CollectionList;
  typedef TQValueList<Item*> ItemList;
  
  // And some templated functions for cleaning up in Collection derived destructors
  template <class T> void DestroyCollectionList(CollectionList& collections);
  template <class T> void DestroyItemList(ItemList& items);
  
  // Main (abstract) Collection definition
  class Collection
  {
  public:
    // ctor/dtor
    Collection(Collection* pParent = NULL, unsigned int mFeatures = 0);
    
    // State whether a given Feature is supported.
    bool Supports(enum Features feature);
    
    const Collection* getParentCollection();
    
    // Get the list of Sub-Collections (assuming this is supported)
    virtual const CollectionList* getSubCollections();
    // Create a new sub collection
    virtual const Collection* createSubCollection() = 0;
    
    // Get the list of items.
    virtual const ItemList* getItems();
    // Add a new item
    virtual const Item* addItem() = 0;
  
  private:
    // Store for parent
    Collection* mpParent;
    
    // Store the features that this collection supports
    unsigned int mFeatures;
    
    // Store for the Sub-Collections
    CollectionList* mpSubCollections;
    
    // Store for the Items
    ItemList* mpItems;
  };
}
#endif /* KIPI2_COLLECTION_H */