Cupt
worker.hpp
Go to the documentation of this file.
00001 /**************************************************************************
00002 *   Copyright (C) 2010 by Eugene V. Lyubimkin                             *
00003 *                                                                         *
00004 *   This program is free software; you can redistribute it and/or modify  *
00005 *   it under the terms of the GNU General Public License                  *
00006 *   (version 3 or above) as published by the Free Software Foundation.    *
00007 *                                                                         *
00008 *   This program is distributed in the hope that it will be useful,       *
00009 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00010 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00011 *   GNU General Public License for more details.                          *
00012 *                                                                         *
00013 *   You should have received a copy of the GNU GPL                        *
00014 *   along with this program; if not, write to the                         *
00015 *   Free Software Foundation, Inc.,                                       *
00016 *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA               *
00017 **************************************************************************/
00018 #ifndef CUPT_SYSTEM_WORKER_SEEN
00019 #define CUPT_SYSTEM_WORKER_SEEN
00020 
00022 
00023 #include <map>
00024 
00025 #include <cupt/common.hpp>
00026 #include <cupt/fwd.hpp>
00027 #include <cupt/system/resolver.hpp>
00028 
00029 namespace cupt {
00030 
00031 namespace internal {
00032 
00033 class WorkerImpl;
00034 
00035 }
00036 
00037 namespace system {
00038 
00040 class CUPT_API Worker
00041 {
00042     internal::WorkerImpl* __impl;
00043 
00044     Worker(const Worker&);
00045     Worker& operator=(const Worker&);
00046  public:
00048     struct Action
00049     {
00050         enum Type {
00051             Install, 
00052             Remove, 
00053             Purge, 
00054             Upgrade, 
00055             Downgrade, 
00056             Configure, 
00057             Deconfigure, 
00058             ProcessTriggers, 
00059             Count 
00060         };
00061         static const char* rawStrings[Count]; 
00062     };
00063     struct ActionsPreview
00064     {
00065         Resolver::SuggestedPackages groups[Action::Count]; 
00066 
00067 
00074         std::map< string, bool > autoFlagChanges;
00075     };
00076 
00078 
00082     Worker(const shared_ptr< const Config >& config, const shared_ptr< const Cache >& cache);
00083     virtual ~Worker();
00091     void setDesiredState(const Resolver::Offer& offer);
00108     void setPackagePurgeFlag(const string& packageName, bool value);
00109 
00115     shared_ptr< const ActionsPreview > getActionsPreview() const;
00121     map< string, ssize_t > getUnpackedSizesPreview() const;
00127     pair< size_t, size_t > getDownloadSizesPreview() const;
00128 
00135     void setAutomaticallyInstalledFlag(const string& packageName, bool value);
00142     void changeSystem(const shared_ptr< download::Progress >& progress);
00143 
00150     void updateReleaseAndIndexData(const shared_ptr< download::Progress >& progress);
00151 
00153 
00160     vector< pair< string, shared_ptr< const BinaryVersion > > > getArchivesInfo() const;
00167     void deleteArchive(const string& path);
00171     void deletePartialArchives();
00172 
00178     void saveSnapshot(const Snapshots&, const string& name);
00185     void renameSnapshot(const Snapshots&,
00186         const string& previousName, const string& newName);
00192     void removeSnapshot(const Snapshots&, const string& name);
00193 };
00194 
00195 }
00196 }
00197 
00198 #endif
00199