summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/opimaccessbackend.h
blob: 5707b585fcdbe6339232e53cb53c133b0911faa2 (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
85
86
87
88
89
#ifndef OPIE_PIM_ACCESS_BACKEND
#define OPIE_PIM_ACCESS_BACKEND

#include <qarray.h>

#include <opie/opimrecord.h>


/**
 * OPimAccessBackend is the base class
 * for all private backends
 * it operates on OPimRecord as the base class
 * and it's responsible for fast manipulating
 * the resource the implementation takes care
 *  of
 */
template <class T = OPimRecord>
class OPimAccessBackend {
public:
    OPimAccessBackend();
    virtual ~OPimAccessBackend();
    
    /**
     * load the resource
     */
    virtual void load() = 0;
    
    /**
     * reload the resource
     */
    virtual void reload() = 0;
    
    /**
     * save the resource and
     * all it's changes
     */
    virtual void save() = 0;
    
    /**
     * return an array of
     * all available uids
     */
    virtual QArray<int> allRecords()const = 0;
    
    /**
     * queryByExample for T with the SortOrder
     * sort
     */
    virtual QArray<int> queryByExample( const T& t, int sort ) = 0;
    
    /**
     * find the OPimRecord with uid @param uid
     * returns T and T.isEmpty() if nothing was found
     */
    virtual T find(int uid ) = 0;
    
    /**
     * clear the back end
     */
    virtual void clear() = 0;
    
    /**
     * add T
     */
    virtual bool add( const T& t ) = 0;
    
    /**
     * remove
     */
    virtual bool remove( int uid ) = 0;
    
    /**
     * replace a record with T.uid()
     */
    virtual bool replace( const T& t ) = 0;


};

template <class T>
OPimAccessBackend<T>::OPimAccessBackend() {

}
template <class T>
OPimAccessBackend<T>::~OPimAccessBackend() {

}

#endif