kitchensync
environment.h
00001 /* 00002 This file is part of libqopensync. 00003 00004 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef OSYNC_ENVIRONMENT_H 00023 #define OSYNC_ENVIRONMENT_H 00024 00025 #include <qstring.h> 00026 00027 #include <libqopensync/group.h> 00028 #include <libqopensync/plugin.h> 00029 #include <libqopensync/result.h> 00030 #include <libqopensync/conversion.h> 00031 00032 struct OSyncEnv; 00033 00034 namespace QSync { 00035 00036 class Environment 00037 { 00038 public: 00039 Environment(); 00040 ~Environment(); 00041 00042 class GroupIterator 00043 { 00044 friend class Environment; 00045 00046 public: 00047 GroupIterator( Environment *environment ) 00048 : mEnvironment( environment ), mPos( -1 ) 00049 { 00050 } 00051 00052 GroupIterator( const GroupIterator &it ) 00053 { 00054 mEnvironment = it.mEnvironment; 00055 mPos = it.mPos; 00056 } 00057 00058 Group operator*() 00059 { 00060 return mEnvironment->groupAt( mPos ); 00061 } 00062 00063 GroupIterator &operator++() { mPos++; return *this; } 00064 GroupIterator &operator++( int ) { mPos++; return *this; } 00065 GroupIterator &operator--() { mPos--; return *this; } 00066 GroupIterator &operator--( int ) { mPos--; return *this; } 00067 bool operator==( const GroupIterator &it ) { return mEnvironment == it.mEnvironment && mPos == it.mPos; } 00068 bool operator!=( const GroupIterator &it ) { return mEnvironment == it.mEnvironment && mPos != it.mPos; } 00069 00070 private: 00071 Environment *mEnvironment; 00072 int mPos; 00073 }; 00074 00075 class PluginIterator 00076 { 00077 friend class Environment; 00078 00079 public: 00080 PluginIterator( Environment *environment ) 00081 : mEnvironment( environment ), mPos( -1 ) 00082 { 00083 } 00084 00085 PluginIterator( const PluginIterator &it ) 00086 { 00087 mEnvironment = it.mEnvironment; 00088 mPos = it.mPos; 00089 } 00090 00091 Plugin operator*() 00092 { 00093 return mEnvironment->pluginAt( mPos ); 00094 } 00095 00096 PluginIterator &operator++() { mPos++; return *this; } 00097 PluginIterator &operator++( int ) { mPos++; return *this; } 00098 PluginIterator &operator--() { mPos--; return *this; } 00099 PluginIterator &operator--( int ) { mPos--; return *this; } 00100 bool operator==( const PluginIterator &it ) { return mEnvironment == it.mEnvironment && mPos == it.mPos; } 00101 bool operator!=( const PluginIterator &it ) { return mEnvironment == it.mEnvironment && mPos != it.mPos; } 00102 00103 private: 00104 Environment *mEnvironment; 00105 int mPos; 00106 }; 00107 00112 GroupIterator groupBegin(); 00113 00118 GroupIterator groupEnd(); 00119 00124 PluginIterator pluginBegin(); 00125 00130 PluginIterator pluginEnd(); 00131 00136 Result initialize(); 00137 00142 Result finalize(); 00143 00147 int groupCount() const; 00148 00152 Group groupAt( int pos ) const; 00153 00158 Group groupByName( const QString &name ) const; 00159 00165 Group addGroup(); 00166 00170 Result removeGroup( const Group &group ); 00171 00175 int pluginCount() const; 00176 00180 Plugin pluginAt( int pos ) const; 00181 00186 Plugin pluginByName( const QString &name ) const; 00187 00191 Conversion conversion() const; 00192 00193 private: 00194 OSyncEnv *mEnvironment; 00195 }; 00196 00197 } 00198 00199 #endif