paludis  Version 2.6.0
syncer.hh
Go to the documentation of this file.
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
5  *
6  * This file is part of the Paludis package manager. Paludis is free software;
7  * you can redistribute it and/or modify it under the terms of the GNU General
8  * Public License version 2, as published by the Free Software Foundation.
9  *
10  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17  * Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef PALUDIS_GUARD_PALUDIS_SYNCER_HH
21 #define PALUDIS_GUARD_PALUDIS_SYNCER_HH 1
22 
24 #include <paludis/output_manager-fwd.hh>
25 #include <paludis/repository.hh>
26 #include <string>
27 
28 /** \file
29  * Declarations for the Syncer class, which can be used by repositories to
30  * simplify syncing.
31  *
32  * \ingroup g_repository
33  *
34  * \section Examples
35  *
36  * - None at this time.
37  */
38 
39 namespace paludis
40 {
41  namespace n
42  {
43  typedef Name<struct name_environment> environment;
44  typedef Name<struct name_filter_file> filter_file;
45  typedef Name<struct name_local> local;
46  typedef Name<struct name_options> options;
47  typedef Name<struct name_output_manager> output_manager;
48  typedef Name<struct name_remote> remote;
49  typedef Name<struct name_revision> revision;
50  }
51 
52  /**
53  * Options used by Syncer.
54  *
55  * \ingroup g_repository
56  * \nosubgrouping
57  */
58  struct SyncOptions
59  {
62 
63  /**
64  * \since 0.36
65  */
67  };
68 
69  /**
70  * Parameters for a Syncer.
71  *
72  * \see Syncer
73  * \ingroup g_repository
74  * \nosubgrouping
75  */
76  struct SyncerParams
77  {
79 
81 
83 
84  /**
85  * Usually empty, and not supported by most syncers.
86  *
87  * \since 0.61
88  */
90  };
91 
92  /**
93  * A Syncer subclass handles syncing Repository instances.
94  *
95  * \ingroup g_repository
96  */
98  {
99  protected:
100  /**
101  * Constructor.
102  */
103  Syncer();
104 
105  public:
106  /**
107  * Destructor.
108  */
109  virtual ~Syncer();
110 
111  Syncer(const Syncer &) = delete;
112  Syncer & operator= (const Syncer &) = delete;
113 
114  /**
115  * Perform the sync.
116  */
117  virtual void sync(const SyncOptions &) const = 0;
118  };
119 
120  /**
121  * A Syncer subclass that uses a program from the syncers/ directory.
122  *
123  * \ingroup g_repository
124  */
126  public Syncer
127  {
128  private:
129  std::string _local, _remote, _revision;
130  const Environment *_environment;
131 
132  std::string _syncer;
133 
134  public:
135  /**
136  * Constructor.
137  */
138  DefaultSyncer(const SyncerParams &);
139 
140  /**
141  * Destructor.
142  */
143  virtual ~DefaultSyncer();
144 
145  /**
146  * Perform the sync.
147  */
148  virtual void sync(const SyncOptions &) const;
149  };
150 
151  /**
152  * Thrown if a sync fails.
153  *
154  * \ingroup g_repository
155  * \ingroup g_exceptions
156  */
158  public Exception
159  {
160  public:
161  /**
162  * Constructor.
163  */
164  SyncFailedError(const std::string & msg) noexcept;
165 
166  /**
167  * Constructor.
168  */
169  SyncFailedError(const std::string & local, const std::string & remote) noexcept;
170  };
171 
172  /**
173  * Thrown if a syncer of the specified type does not exist.
174  *
175  * \ingroup g_repository
176  * \ingroup g_exceptions
177  */
179  {
180  public:
181  /**
182  * Constructor.
183  */
184  NoSuchSyncerError(const std::string & format) noexcept;
185  };
186 }
187 
188 #endif
Definition: syncer.hh:97
Definition: about_metadata-fwd.hh:23
Definition: syncer.hh:178
Definition: syncer.hh:58
NamedValue< n::revision, std::string > revision
Definition: syncer.hh:89
NamedValue< n::output_manager, std::shared_ptr< OutputManager > > output_manager
Definition: syncer.hh:66
Definition: syncer.hh:76
Definition: syncer.hh:157
Definition: exception.hh:74
Definition: environment.hh:200
Definition: named_value-fwd.hh:26
Definition: syncer.hh:125
#define PALUDIS_VISIBLE
Definition: attributes.hh:59