summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/otemplatebase.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/otemplatebase.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/otemplatebase.h33
1 files changed, 32 insertions, 1 deletions
diff --git a/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/otemplatebase.h
index cadac74..17d9961 100644
--- a/libopie2/opiepim/core/otemplatebase.h
+++ b/libopie2/opiepim/core/otemplatebase.h
@@ -1,32 +1,61 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6 .>+-=
7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
1#ifndef OPIE_TEMPLATE_BASE_H 29#ifndef OPIE_TEMPLATE_BASE_H
2#define OPIE_TEMPLATE_BASE_H 30#define OPIE_TEMPLATE_BASE_H
3 31
4#include <qarray.h> 32#include <qarray.h>
5 33
6#include <opie/opimrecord.h> 34#include <opie2/opimrecord.h>
7 35
8 36
37namespace Opie {
9/** 38/**
10 * Templates do not have a base class, This is why 39 * Templates do not have a base class, This is why
11 * we've this class 40 * we've this class
12 * this is here to give us the possibility 41 * this is here to give us the possibility
13 * to have a common base class 42 * to have a common base class
14 * You may not want to use that interface internaly 43 * You may not want to use that interface internaly
15 * POOR mans interface 44 * POOR mans interface
16 */ 45 */
17class OPimBasePrivate; 46class OPimBasePrivate;
18struct OPimBase { 47struct OPimBase {
19 /** 48 /**
20 * return the rtti 49 * return the rtti
21 */ 50 */
22 virtual int rtti()= 0; 51 virtual int rtti()= 0;
23 virtual OPimRecord* record()const = 0; 52 virtual OPimRecord* record()const = 0;
24 virtual OPimRecord* record(int uid)const = 0; 53 virtual OPimRecord* record(int uid)const = 0;
25 virtual bool add( const OPimRecord& ) = 0; 54 virtual bool add( const OPimRecord& ) = 0;
26 virtual bool remove( int uid ) = 0; 55 virtual bool remove( int uid ) = 0;
27 virtual bool remove( const OPimRecord& ) = 0; 56 virtual bool remove( const OPimRecord& ) = 0;
28 virtual void clear() = 0; 57 virtual void clear() = 0;
29 virtual bool load() = 0; 58 virtual bool load() = 0;
30 virtual bool save() = 0; 59 virtual bool save() = 0;
31 virtual QArray<int> records()const = 0; 60 virtual QArray<int> records()const = 0;
32 /* 61 /*
@@ -74,25 +103,27 @@ private:
74 * implementation 103 * implementation
75 */ 104 */
76template <class T> 105template <class T>
77int 106int
78OTemplateBase<T>::rtti() { 107OTemplateBase<T>::rtti() {
79 return T::rtti(); 108 return T::rtti();
80} 109}
81template <class T> 110template <class T>
82OPimRecord* OTemplateBase<T>::record()const { 111OPimRecord* OTemplateBase<T>::record()const {
83 T* t = new T; 112 T* t = new T;
84 return t; 113 return t;
85} 114}
86template <class T> 115template <class T>
87OPimRecord* OTemplateBase<T>::record(int uid )const { 116OPimRecord* OTemplateBase<T>::record(int uid )const {
88 T t2 = find(uid ); 117 T t2 = find(uid );
89 T* t1 = new T(t2); 118 T* t1 = new T(t2);
90 119
91 return t1; 120 return t1;
92}; 121};
93template <class T> 122template <class T>
94T* OTemplateBase<T>::rec() { 123T* OTemplateBase<T>::rec() {
95 return new T; 124 return new T;
96} 125}
97 126
127}
128
98#endif 129#endif