libdoclone  0.8.0
Clone.h
1 /*
2  * libdoclone - library for cloning GNU/Linux systems
3  * Copyright (C) 2013, 2015 Joan Lledó <joanlluislledo@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef CLONE_H_
20 #define CLONE_H_
21 
22 #include <stdint.h>
23 
24 #include <string>
25 #include <vector>
26 
27 #include <doclone/Operation.h>
28 #include <doclone/observer/AbstractSubject.h>
29 
30 #include <doclone/exception/Exception.h>
31 
32 namespace Doclone {
33 
241 class Clone : public AbstractSubject {
242 public:
243  static Clone* getInstance();
244  ~Clone();
245 
246  void create() throw(Exception);
247  void restore() throw(Exception);
248  void send() throw(Exception);
249  void receive() throw(Exception);
250  void chainOrigin() throw(Exception);
251  void chainLink() throw(Exception);
252 
253  bool getEmpty() const;
254  void setEmpty(bool empty);
255  unsigned int getNodesNumber() const;
256  void setNodesNumber(unsigned int nodesNum);
257  const std::string &getDevice() const;
258  void setDevice(const std::string &device);
259  const std::string &getImage() const;
260  void setImage(const std::string &image);
261  const std::string &getAddress() const;
262  void setAddress(const std::string &address);
263  const std::string &getInterface() const;
264  void setInterface(const std::string &interface);
265  bool getForce() const;
266  void setForce(bool force);
267 
268  void addOperation(Operation *op);
269  void markCompleted(dcOperationType type, const std::string &target);
270  Operation* getOperation(dcOperationType type, const std::string &target);
271 
272  void triggerEvent(dcEvent event, const std::string &target);
273 protected:
275  Clone();
276 
278  std::string _image;
280  std::string _device;
282  std::string _address;
284  std::string _interface;
286  unsigned int _nodesNumber;
288  bool _empty;
290  bool _force;
291 
293  std::vector<Operation *> _operations;
294 };
295 
296 }
297 
298 #endif /* CLONE_H_ */
void chainOrigin()
Sends an image or a device to the network in link mode.
Definition: Clone.cc:206
void setNodesNumber(unsigned int nodesNum)
Sets the number of receivers in the network.
Definition: Clone.cc:283
bool _force
Mode force enabled/disabled.
Definition: Clone.h:290
void setEmpty(bool empty)
Sets the no-data mode on/off.
Definition: Clone.cc:268
std::string _device
Device path entered by the user.
Definition: Clone.h:280
Definition: Clone.h:32
Clone()
Private constructor for singleton pattern.
Definition: Clone.cc:42
std::string _interface
Ip address of the interface to be used in the link mode.
Definition: Clone.h:284
void restore()
Restores an image in a device.
Definition: Clone.cc:111
void setForce(bool force)
Sets the force mode on/off.
Definition: Clone.cc:358
std::string _image
Image path entered by the user.
Definition: Clone.h:278
Interface of the library.
Definition: Clone.h:241
static Clone * getInstance()
Returns a pointer to a Doclone::Clone object.
Definition: Clone.cc:59
dcOperationType
C wrapper for Doclone::dcOperationType.
Definition: clone.h:313
void setInterface(const std::string &interface)
Sets the IP address of the network interface to be used in the link mode.
Definition: Clone.cc:343
void send()
Sends an image or a device to the network.
Definition: Clone.cc:145
std::string _address
Ip address entered by the user.
Definition: Clone.h:282
Operation * getOperation(dcOperationType type, const std::string &target)
Gets the operation required using its type and target to identify it.
Definition: Clone.cc:409
unsigned int _nodesNumber
Number of receivers entered by the user.
Definition: Clone.h:286
std::vector< Operation * > _operations
Vector with the state of the execution.
Definition: Clone.h:293
void create()
Creates an image of a device.
Definition: Clone.cc:77
void receive()
Receives an image or a device to the network.
Definition: Clone.cc:176
dcEvent
C wrapper for Doclone::dcEvent.
Definition: clone.h:341
void markCompleted(dcOperationType type, const std::string &target)
Marks one operation as completed.
Definition: Clone.cc:384
void setDevice(const std::string &device)
Sets the device on which work.
Definition: Clone.cc:298
void triggerEvent(dcEvent event, const std::string &target)
Used by the library to trigger a general event.
Definition: Clone.cc:450
bool _empty
Empty mode enabled/disabled.
Definition: Clone.h:288
void setAddress(const std::string &address)
Sets the IP address of the server in unicast/multicast mode.
Definition: Clone.cc:328
void chainLink()
Receives an image or a device to the network in link mode.
Definition: Clone.cc:236
~Clone()
Deletes all the objects in the vector of operations and clears it.
Definition: Clone.cc:435
void addOperation(Operation *op)
Adds a pending operation to the vector.
Definition: Clone.cc:368
void setImage(const std::string &image)
Sets the image on which work.
Definition: Clone.cc:313