environment.h
1/*
2 This file is part of libqopensync.
3
4 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#ifndef OSYNC_ENVIRONMENT_H
23#define OSYNC_ENVIRONMENT_H
24
25#include <tqstring.h>
26
27#include <libqopensync/group.h>
28#include <libqopensync/plugin.h>
29#include <libqopensync/result.h>
30#include <libqopensync/conversion.h>
31
32struct OSyncEnv;
33
34namespace QSync {
35
36class Environment
37{
38 public:
39 Environment();
40 ~Environment();
41
42 class GroupIterator
43 {
44 friend class Environment;
45
46 public:
47 GroupIterator( Environment *environment )
48 : mEnvironment( environment ), mPos( -1 )
49 {
50 }
51
52 GroupIterator( const GroupIterator &it )
53 {
54 mEnvironment = it.mEnvironment;
55 mPos = it.mPos;
56 }
57
58 Group operator*()
59 {
60 return mEnvironment->groupAt( mPos );
61 }
62
63 GroupIterator &operator++() { mPos++; return *this; }
64 GroupIterator &operator++( int ) { mPos++; return *this; }
65 GroupIterator &operator--() { mPos--; return *this; }
66 GroupIterator &operator--( int ) { mPos--; return *this; }
67 bool operator==( const GroupIterator &it ) { return mEnvironment == it.mEnvironment && mPos == it.mPos; }
68 bool operator!=( const GroupIterator &it ) { return mEnvironment == it.mEnvironment && mPos != it.mPos; }
69
70 private:
71 Environment *mEnvironment;
72 int mPos;
73 };
74
75 class PluginIterator
76 {
77 friend class Environment;
78
79 public:
80 PluginIterator( Environment *environment )
81 : mEnvironment( environment ), mPos( -1 )
82 {
83 }
84
85 PluginIterator( const PluginIterator &it )
86 {
87 mEnvironment = it.mEnvironment;
88 mPos = it.mPos;
89 }
90
91 Plugin operator*()
92 {
93 return mEnvironment->pluginAt( mPos );
94 }
95
96 PluginIterator &operator++() { mPos++; return *this; }
97 PluginIterator &operator++( int ) { mPos++; return *this; }
98 PluginIterator &operator--() { mPos--; return *this; }
99 PluginIterator &operator--( int ) { mPos--; return *this; }
100 bool operator==( const PluginIterator &it ) { return mEnvironment == it.mEnvironment && mPos == it.mPos; }
101 bool operator!=( const PluginIterator &it ) { return mEnvironment == it.mEnvironment && mPos != it.mPos; }
102
103 private:
104 Environment *mEnvironment;
105 int mPos;
106 };
107
112 GroupIterator groupBegin();
113
118 GroupIterator groupEnd();
119
124 PluginIterator pluginBegin();
125
130 PluginIterator pluginEnd();
131
136 Result initialize();
137
142 Result finalize();
143
147 int groupCount() const;
148
152 Group groupAt( int pos ) const;
153
158 Group groupByName( const TQString &name ) const;
159
165 Group addGroup();
166
170 Result removeGroup( const Group &group );
171
175 int pluginCount() const;
176
180 Plugin pluginAt( int pos ) const;
181
186 Plugin pluginByName( const TQString &name ) const;
187
191 Conversion conversion() const;
192
193 private:
194 OSyncEnv *mEnvironment;
195};
196
197}
198
199#endif