libdoclone  0.7.1
Functions
C++ API

C++ API for libdoclone. More...

Functions

static Clone * Doclone::Clone::getInstance ()
 Returns a pointer to a Doclone::Clone object.
void Doclone::Clone::create () throw (Exception)
 Creates an image of a device.
void Doclone::Clone::restore () throw (Exception)
 Restores an image in a device.
void Doclone::Clone::send () throw (Exception)
 Sends an image or a device to the network.
void Doclone::Clone::receive () throw (Exception)
 Receives an image or a device to the network.
void Doclone::Clone::chainOrigin () throw (Exception)
 Sends an image or a device to the network in link mode.
void Doclone::Clone::chainLink () throw (Exception)
 Receives an image or a device to the network in link mode.
void Doclone::Clone::setEmpty (bool empty)
 Sets the no-data mode on/off.
void Doclone::Clone::setNodesNumber (unsigned int nodesNum)
 Sets the number of receivers in the network.
void Doclone::Clone::setDevice (const std::string &device)
 Sets the device on which work.
void Doclone::Clone::setImage (const std::string &image)
 Sets the image on which work.
void Doclone::Clone::setAddress (const std::string &address)
 Sets the IP address of the server in unicast/multicast mode.
void Doclone::Clone::setForce (bool force)
 Sets the force mode on/off.

Detailed Description

C++ API for libdoclone.

This class provides a way for calling the methods of libdoclone from a C++ program. To create an object, the static method getInstance() must be called by this way:

It is possible to subscribe the events of the library. These can be used to know the operations progress and possible incidences. To do this, some functions must be implemented with the proper prototype.

First of all, These are the four kinds of libdoclone events:

Subscribing to any of these events can be performed by extending the Doclone::AbstractObserver class and overriding all its notify() methods:

void notify(Doclone::dcTransferEvent event, uint64_t numBytes);
void notify(Doclone::dcOperationEvent event,
Doclone::dcOperationType type, const std::string &target);
void notify(Doclone::dcEvent event, const std::string &target);
void notify(const std::string &str);

For example:

class MyObserver : public Doclone::AbstractObserver {
public:
MyObserver();
void notify(Doclone::dcTransferEvent event, uint64_t numBytes);
void notify(Doclone::dcOperationEvent event,
Doclone::dcOperationType type, const std::string &target);
void notify(Doclone::dcEvent event, const std::string &target);
void notify(const std::string &str);
};
void MyObserver::notify(const std::string &str) {
std::cerr << "Something has happened:" << " " << str << std::endl;
}

The next step is to set all the doclone object required properties before performing the work. These are:

These are some setters for configuring the properties:

void setEmpty(bool empty);
void setNodesNumber(unsigned int nodesNum);
void setDevice(const std::string &device);
void setImage(const std::string &image);
void setAddress(const std::string &address);
void setForce(bool force);

The last step is to call one of the methods that perform the work:

void create() throw(Exception);
void restore() throw(Exception);
void send() throw(Exception);
void receive() throw(Exception);
void chainOrigin() throw(Exception);
void chainLink() throw(Exception);

All this methods raise an exception if anything goes wrong. The library has two kinds of exceptions, the Warning Exceptions and the Error Exceptions. The Warning Exceptions don't stop the execution and are captured in the library, but their messages are sent to the views. These messages are received by the views with "void notify(const std::string &str)" method override. The Error Exceptions are defined for severe errors, these ones always stop the execution and are raised to the caller. The library user must decide what to do with them.

These are some examples of use:

Function Documentation

void Doclone::Clone::chainLink ( ) throw (Exception)

Receives an image or a device to the network in link mode.

Image or device path must be set before calling this function.

void Doclone::Clone::chainOrigin ( ) throw (Exception)

Sends an image or a device to the network in link mode.

Image or device path must be set before calling this function.

void Doclone::Clone::create ( ) throw (Exception)

Creates an image of a device.

Both image an device path must be set before calling this function.

Clone * Doclone::Clone::getInstance ( )
static

Returns a pointer to a Doclone::Clone object.

Returns
A pointer to a doclone object
void Doclone::Clone::receive ( ) throw (Exception)

Receives an image or a device to the network.

Server's IP and either image or device path must be set before calling this function.

void Doclone::Clone::restore ( ) throw (Exception)

Restores an image in a device.

Both image an device path must be set before calling this function.

void Doclone::Clone::send ( ) throw (Exception)

Sends an image or a device to the network.

The number of receivers and either image or device path must be set before calling this function.

void Doclone::Clone::setAddress ( const std::string &  address)

Sets the IP address of the server in unicast/multicast mode.

Parameters
addressIP Address
void Doclone::Clone::setDevice ( const std::string &  device)

Sets the device on which work.

Parameters
deviceDevice path
void Doclone::Clone::setForce ( bool  force)

Sets the force mode on/off.

Parameters
forcetrue = on; false = off
void Doclone::Clone::setImage ( const std::string &  image)

Sets the image on which work.

Parameters
imageImage path
void Doclone::Clone::setNodesNumber ( unsigned int  nodesNumber)

Sets the number of receivers in the network.

Parameters
nodesNumberNumber of nodes