Skip to content
Snippets Groups Projects
Commit cda6e1cd authored by kk1205's avatar kk1205
Browse files

Komment ráta 100% publikus mezőkön és függvényeken és osztályokon

parent c016c424
No related branches found
No related tags found
No related merge requests found
Showing with 141 additions and 119 deletions
No preview for this file type
/**
* Project Untitled
*/
#ifndef _CACHE_H #ifndef _CACHE_H
#define _CACHE_H #define _CACHE_H
/**
* Cache class
* provides interface to the caching functionality
*/
class Cache { class Cache {
public: public:
/**
* Tries to get a file from the cache
*/
virtual void getFile() = 0; virtual void getFile() = 0;
/**
* Adds a file to the cache
*/
virtual void addFile() = 0; virtual void addFile() = 0;
}; };
......
...@@ -11,7 +11,12 @@ CloudFileSystem::CloudFileSystem(Application &application) : ...@@ -11,7 +11,12 @@ CloudFileSystem::CloudFileSystem(Application &application) :
application(application), application(application),
distributor(application.cm), distributor(application.cm),
homeNetworkBehaviour(NULL), homeNetworkBehaviour(NULL),
cache(new ConcreteCache) {} cache(new ConcreteCache()) {}
CloudFileSystem::~CloudFileSystem(){
delete this->cache;
}
// Not working as we planned, maybe should be rethinked // Not working as we planned, maybe should be rethinked
void CloudFileSystem::setComputeOnPi(bool computeOnPi){ void CloudFileSystem::setComputeOnPi(bool computeOnPi){
......
/**
* @file CloudFileSystem.h
* A CloudFileSystem osztly deklarcija.
*/
#ifndef _CLOUDFILESYSTEM_H #ifndef _CLOUDFILESYSTEM_H
#define _CLOUDFILESYSTEM_H #define _CLOUDFILESYSTEM_H
...@@ -19,133 +13,125 @@ ...@@ -19,133 +13,125 @@
#include "cloud\CloudAccessLayer.h" #include "cloud\CloudAccessLayer.h"
#include "networking\HomeNetworkCommunications.h" #include "networking\HomeNetworkCommunications.h"
#include "Cache.h" #include "Cache.h"
using namespace std;
class Application; class Application;
using namespace std;
/** /**
* A felhben trolt fjlokat tartja karban. * CloudFileSystem class
* Rajta keresztl lehet hozzadni, letlteni s trlni fjlokat. * Maintaines the files that are held in the cloud
* One can add, download, delete files,
* It handles mutexes, cache usage and directories.
*/ */
class CloudFileSystem { class CloudFileSystem {
private: private:
/** /**
* Azt jelzi, hogy a kliensen vagy a Pi-n trtnik a fjlok feldolgozsa. * Indicates where is the process running
* * @TODO rethink
* @TODO Mr nincs r igazi szksg. Ezt a rszt t kellene gondolni.
*/ */
bool computeOnPi; bool computeOnPi;
/** /**
* A bels hlzatbeli mkdst meghatroz objektum. * Object defining inner networking
*/ */
HomeNetworkBehaviour *homeNetworkBehaviour; HomeNetworkBehaviour *homeNetworkBehaviour;
/** /**
* Referencia az Application objektumra, ami tartalmazza ezt az objektumot. * Reference to the application object
* Azrt van r szksg, hogy a tbbi, az Applicationben trolt tagvltozt elrje. * It is needed because the application contains the main parts of the program
*/ */
Application &application; Application &application;
/** /**
* Egy Distributor objektum, ami a fragmensek sztszrst vgzi a felhk kztt. * Distributor object, handles the fragments positions beneath the clouds
*/ */
Distributor distributor; Distributor distributor;
/** /**
* A cache-elsi stratgit megvalst objektum. * The object implementing the caching strategy
*/ */
Cache *cache; Cache *cache;
public: public:
/** /**
* A setComputeOnPi tagvltoz setter fggvnye. * Setter to the setComputePi variable
* A httrben belltja a megfelel HomeNetworkBehaviour tagvltozt. * Sets the right HomeNetworkBehaviour
* * @param setComputeOnPi value to be set
* @TODO A setComputeOnPi tagvltozra nincs igazi szksg. Egyelre bent hagyom a fggvnyt a program tbbi rszvel val kompatibilits miatt.
*/ */
void setComputeOnPi(bool setComputeOnPi); void setComputeOnPi(bool setComputeOnPi);
/** /**
* A setComputeOnPi tagvltoz getter fggvnye. * Getter to the setComputePi variable
* * @return value of setComputePi
* @TODO A setComputeOnPi tagvltozra nincs igazi szksg. Egyelre bent hagyom a fggvnyt a program tbbi rszvel val kompatibilits miatt.
*/ */
bool getComputeOnPi(); bool getComputeOnPi();
/** /**
* A CloudFileSystem osztly konstruktora. * CloudFileSystem constuctor
* * @param application reference to the Application object
* @param application A CloudFileSystem objektumot trol Application objektum referencija.
*/ */
CloudFileSystem(Application &application); CloudFileSystem(Application &application);
/** /**
* Egy fjlt ad hozz felhben val trolsra. * CloudFileSystem destructor
* * Needed to free memory objects
* Elszr a cache-hez adja hozz, majd a HomeNetworkBehaviournek adja tovbb, ami a feltltsrl gondoskodik. */
* ~CloudFileSystem();
* @param localFileID A fjl azonostja a helyi fjlrendszerben.
* Az azonost a fjlt elrsi tjbl s nevbl ll, pldul: /**
* C:\example_path\filename.extension * Adds given file to the cloud
* * Uses the set HomeNetworkBehaviour
* @param destinationFileID A fjlt azonostja a felh trolban. * @param localFileID full path of the local file to upload
* Az azonost a fjlt elrsi tjbl s nevbl ll, pldul: * @param destinationFileID full path of the file on the cloud
* /example_path/filename.extension
*/ */
bool addFile(string localFileID, string destinationFileID); bool addFile(string localFileID, string destinationFileID);
/** /**
* Egy fjlt ad vissza a felh trolbl. * Downloads a file from the cloud
* * Uses the set HomeNetworkBehaviour
* Ha a fjl helyben is elrhet, akkor onnan adja vissza. * Returns with "" if none is set
* Egybknt a homeNetworkBehaviour megfelel fggvnyt hvja meg, hogy az szerezze meg a fjlt. * @param fileDescriptor descriptor of the file to be retrieved
*
* @param fileDescriptor
*/ */
string getFile(FileDescriptor fileDescriptor); string getFile(FileDescriptor fileDescriptor);
/** /**
* Egy mappa ltrehozst vgzi a felh trolban. * Creates a directory on the cloud
* * @TODO not sure how its gonna work
* @TODO Egyelre nem biztos, hogyan fog mkdni a trol, gy mg nem tudom a pontos mkdst. * @param directoryID path of the directory to be created
* @param directoryID A mappa azonostja a felh trrendszerben.
*/ */
bool createDirectory(string directoryID); bool createDirectory(string directoryID);
/** /**
* Egy fjlt trl a felh trolbl. * Deletes a file from the cloud
* * It is completed through the CloudAccessLayer
* A trls a CloudAccessLayern keresztl trtnik. * @param fileDescriptor descriptor of the file to be downloaded
* @param fileDescriptor A fjller, ami meghatrozza a fjlt.
*/ */
bool deleteFile(FileDescriptor fileDescriptor); bool deleteFile(FileDescriptor fileDescriptor);
/** /**
* A homeNetworkBehaviour tagvltoz setter fggvnye. * Setter to homeNetworkBehaviour
* @param homeNetworkBehaviour A belltand HomeNetworkBehaviour objektum mutatja. * @param homeNetworkBehaviour pointer of homeNetworkBehaviour to be set
*/ */
void setHomeNetworkBehaviour(HomeNetworkBehaviour *homeNetworkBehaviour); void setHomeNetworkBehaviour(HomeNetworkBehaviour *homeNetworkBehaviour);
/** /**
* A distributor tagvltoz getter fggvnye. * Getter to distributor variable
*/ */
Distributor* getDistributor(); Distributor* getDistributor();
/** /**
* Az Application objektumbl lekri a kapcsold CloudAccessLayer objektum mutatjt. * Gets CloudAccessLayer from application
*/ */
CloudAccessLayer* getCloudAccessLayer(); CloudAccessLayer* getCloudAccessLayer();
/** /**
* Az Application objektumbl lekri a kapcsold HomeNetworkCommunications objektum mutatjt. * Gets HomeNetworkCommunications from application
*/ */
HomeNetworkCommunications* getHomeNetworkCommunications(); HomeNetworkCommunications* getHomeNetworkCommunications();
/** /**
* A cache tagvltoz getter fggvnye. * Getter to the cache pointer
*/ */
Cache* getCache(); Cache* getCache();
...@@ -160,23 +146,20 @@ private: ...@@ -160,23 +146,20 @@ private:
set<FileDescriptor> fileTree; set<FileDescriptor> fileTree;
/** /**
* Az adott fjl zrolst vgz fggvny. * Creates a lock on a given file.
* * @param fileDescriptor descriptor of thefile to be locked
* @param fileDescriptor A zroland fjl lerja.
*/ */
void lock(FileDescriptor fileDescriptor); void lock(FileDescriptor fileDescriptor);
/** /**
* Az adott fjl zrolst felold fggvny. * Unlocks a given file
* * @param fileDescriptor descriptor of the fiel to be unlocked
* @param fileDescriptor A feloldand fjl lerja.
*/ */
void unlock(FileDescriptor fileDescriptor); void unlock(FileDescriptor fileDescriptor);
/** /**
* Egy fjl zroltsgt meghatroz fggvny. * Determines weather a file is locked
* * @param fileDescriptor descriptor of the file to be determined
* @param fileDescriptor A fjl lerja, aminek a zroltsgt akarjuk lekrdezni.
*/ */
void isLocked(FileDescriptor fileDescriptor); void isLocked(FileDescriptor fileDescriptor);
}; };
......
/**
* Project Untitled
*/
#ifndef _COMPUTEONCLIENT_H #ifndef _COMPUTEONCLIENT_H
#define _COMPUTEONCLIENT_H #define _COMPUTEONCLIENT_H
...@@ -12,21 +7,33 @@ ...@@ -12,21 +7,33 @@
#include "CloudFileSystem.h" #include "CloudFileSystem.h"
using namespace std; using namespace std;
/**
* ComputeOnClient class
* implements HomeNetworkBehaviour class
* it uses the CloudFileSystem to finish the job
*/
class ComputeOnClient: public HomeNetworkBehaviour { class ComputeOnClient: public HomeNetworkBehaviour {
private: private:
CloudFileSystem &cloudFileSystem; CloudFileSystem &cloudFileSystem;
public: public:
/**
* ComputeOnClient constructor
* @param cloudFileSystem the CloudFileSystem reference
*/
ComputeOnClient(CloudFileSystem &cloudFileSystem) : ComputeOnClient(CloudFileSystem &cloudFileSystem) :
cloudFileSystem(cloudFileSystem) {} cloudFileSystem(cloudFileSystem) {}
/** /**
* @param localFileID * Adds a file to the cloud
* @param destinationFileID * @param localFileID path of file to be added
* @param destinationFileID path of file on cloud
*/ */
bool addFile(string localFileID, string destinationFileID); bool addFile(string localFileID, string destinationFileID);
/** /**
* @param fileDescriptor * Gets a file from the cloud
* @param fileDescriptor the descriptor of the file to be retireved
* @return path of the file retrieved
*/ */
string getFile(FileDescriptor fileDescriptor); string getFile(FileDescriptor fileDescriptor);
}; };
......
/**
* Project Untitled
*/
#ifndef _COMPUTEONPI_H #ifndef _COMPUTEONPI_H
#define _COMPUTEONPI_H #define _COMPUTEONPI_H
...@@ -13,7 +8,12 @@ ...@@ -13,7 +8,12 @@
#include "networking\HomeNetworkCommunications.h" #include "networking\HomeNetworkCommunications.h"
using namespace std; using namespace std;
/**
* ComputeOnPi class
* implements HomeNetworkBehaviour class
* it uses the PI to finish the job by sending the request to it
* it will finish the job using the ComputeOnClient implementation
*/
class ComputeOnPi: public HomeNetworkBehaviour { class ComputeOnPi: public HomeNetworkBehaviour {
private: private:
CloudFileSystem &cloudFileSystem; CloudFileSystem &cloudFileSystem;
...@@ -21,13 +21,16 @@ public: ...@@ -21,13 +21,16 @@ public:
ComputeOnPi(CloudFileSystem &cloudFileSystem) : cloudFileSystem(cloudFileSystem) {} ComputeOnPi(CloudFileSystem &cloudFileSystem) : cloudFileSystem(cloudFileSystem) {}
/** /**
* @param localFileID * Adds a file to the cloud
* @param destinationFileID * @param localFileID path of file to be added
* @param destinationFileID path of file on cloud
*/ */
bool addFile(string localFileID, string destinationFileID); bool addFile(string localFileID, string destinationFileID);
/** /**
* @param fileDescriptor * Gets a file from the cloud
* @param fileDescriptor the descriptor of the file to be retireved
* @return path of the file retrieved
*/ */
string getFile(FileDescriptor fileDescriptor); string getFile(FileDescriptor fileDescriptor);
}; };
......
...@@ -8,12 +8,20 @@ ...@@ -8,12 +8,20 @@
#include "Cache.h" #include "Cache.h"
/**
* ConcreteCache class
* implenents Cache interface
*/
class ConcreteCache: public Cache { class ConcreteCache: public Cache {
public: public:
/**
* Tries to get a file from the cache
*/
void getFile(); void getFile();
/**
* Adds a file to the cache
*/
void addFile(); void addFile();
}; };
......
/**
* Project Untitled
*/
#ifndef _DECODER_H #ifndef _DECODER_H
#define _DECODER_H #define _DECODER_H
#include <string> #include <string>
#include "fileModel/FileDescriptor.h" #include "fileModel/FileDescriptor.h"
/**
* Decoder class
* decodes the fragments to a file
* it uses an external library
*/
class Decoder { class Decoder {
public: public:
/** /**
* @param fileDescriptor * decodes the fragments to a file
* @param fileDescriptor descriptor of the file to decode
*/ */
static string decode(FileDescriptor fileDescriptor); static string decode(FileDescriptor fileDescriptor);
}; };
......
...@@ -9,14 +9,22 @@ ...@@ -9,14 +9,22 @@
#include "fileModel/FileDescriptor.h" #include "fileModel/FileDescriptor.h"
#include "cloud\CloudManager.h" #include "cloud\CloudManager.h"
/**
* Distributor class
* It sets the files' fragments' cloudIDs to a valid cloudAdapter ID
*/
class Distributor { class Distributor {
private: private:
CloudManager &cloudManager; CloudManager &cloudManager;
public: public:
/**
* Distributor constructor
* @param cloudManager cloudManager reference
*/
Distributor(CloudManager &cloudManager) : cloudManager(cloudManager) {} Distributor(CloudManager &cloudManager) : cloudManager(cloudManager) {}
/** /**
* It sets the files' fragments' cloudIDs to a valid cloudAdapter ID
* @param fileDescriptor * @param fileDescriptor
*/ */
bool distribute(FileDescriptor fileDescriptor); bool distribute(FileDescriptor fileDescriptor);
......
/**
* Project Untitled
*/
#ifndef _ENCODER_H #ifndef _ENCODER_H
#define _ENCODER_H #define _ENCODER_H
#include "fileModel/FileDescriptor.h" #include "fileModel/FileDescriptor.h"
/**
* Encoder class
* encodes the file to fragments
* it uses an external library
*/
class Encoder { class Encoder {
public: public:
/** /**
* @param localFileID * encodes the file to fragments
* @param localFileID id of the file to encode
*/ */
static FileDescriptor encode(string localFileID); static FileDescriptor encode(string localFileID);
}; };
......
/**
* Project Untitled
*/
#ifndef _HOMENETWORKBEHAVIOUR_H #ifndef _HOMENETWORKBEHAVIOUR_H
#define _HOMENETWORKBEHAVIOUR_H #define _HOMENETWORKBEHAVIOUR_H
...@@ -10,17 +5,24 @@ ...@@ -10,17 +5,24 @@
#include "fileModel/FileDescriptor.h" #include "fileModel/FileDescriptor.h"
using namespace std; using namespace std;
/**
* HomeNetworkBehaviour class
* provides interface to the file exchanging
*/
class HomeNetworkBehaviour { class HomeNetworkBehaviour {
public: public:
/** /**
* @param localFileID * Adds a file to the cloud
* @param destinationFileID * @param localFileID path of file to be added
* @param destinationFileID path of file on cloud
*/ */
virtual bool addFile(string localFileID, string destinationFileID) = 0; virtual bool addFile(string localFileID, string destinationFileID) = 0;
/** /**
* @param fileDescriptor * Gets a file from the cloud
* @param fileDescriptor the descriptor of the file to be retireved
* @return path of the file retrieved
*/ */
virtual string getFile(FileDescriptor fileDescriptor) = 0; virtual string getFile(FileDescriptor fileDescriptor) = 0;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment