idem mais compile sans erreur

This commit is contained in:
eleonore12345 2024-08-07 12:47:21 +02:00
parent eb8f202889
commit fd3bf3f7a8
7 changed files with 25 additions and 13 deletions

View File

@ -6,7 +6,10 @@
#include "BashManager.h" #include "BashManager.h"
//constructor and destructor inline //constructor and destructor inline
DockerModule::DockerModule()
{
name="Docker";
}
//public methods //public methods
int DockerModule::prepare() int DockerModule::prepare()
{ {

View File

@ -10,12 +10,12 @@
class DockerModule : public Module class DockerModule : public Module
{ {
public: public:
DockerModule(){} //inline DockerModule();//inline
~DockerModule(){} //inline ~DockerModule(){} //inline
int prepare (); int prepare ();
int deploy (string serviceUsername); int deploy (string serviceUsername);
int remove(string serviceUsername); int remove(string serviceUsername);
int clean (); int clean ();
string name;
}; };
#endif #endif

View File

@ -1,12 +1,12 @@
ECHO = @echo ECHO = @echo
GCC = g++ GCC = g++
RM = @rm -f RM = @rm -f
CCFLAGS = -c -O3 -g -std=c++11 -pedantic -Wall CCFLAGS = -c -O3 -g -std=c++20 -pedantic -Wall
SRC = $(wildcard *.cpp) SRC = $(wildcard *.cpp)
BIN = ../bin BIN = ../bin
EXE = deployer EXE = deployer
OBJECTS = $(patsubst %.cpp,$(BIN)/%.o,$(SRC)) OBJECTS = $(patsubst %.cpp,$(BIN)/%.o,$(SRC))
LIBRARIES = LIBRARIES = -lstdc++fs
$(EXE) : $(OBJECTS) $(EXE) : $(OBJECTS)
$(ECHO) "-Linking $(EXE)-" $(ECHO) "-Linking $(EXE)-"

View File

@ -10,6 +10,11 @@
//destructor, could not be inline because pure virtual //destructor, could not be inline because pure virtual
Module::~Module(){} Module::~Module(){}
ostream & operator << (ostream & out, const Module & m)
{
cout << "module " << m.name << endl;
return cout;
}

View File

@ -18,5 +18,7 @@ class Module
virtual int deploy (string serviceUsername)=0; virtual int deploy (string serviceUsername)=0;
virtual int remove(string serviceUsername)=0; virtual int remove(string serviceUsername)=0;
virtual int clean ()=0; virtual int clean ()=0;
friend ostream & operator<< (ostream & out, const Module & m);
string name;
}; };
#endif #endif

View File

@ -1,6 +1,8 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include "Module.h"
#include "DockerModule.h"
using namespace std; using namespace std;
DockerModule dockerModule=DockerModule(); DockerModule dockerModule=DockerModule();
vector <Module> modules = {dockerModule}; vector <Module *> modules={&dockerModule};

View File

@ -9,7 +9,6 @@
#include <filesystem> #include <filesystem>
#include "Services.h" #include "Services.h"
#include "Modules.h" #include "Modules.h"
#include "DockerModule.h"
#include "BashManager.h" #include "BashManager.h"
using namespace std; using namespace std;
@ -67,10 +66,10 @@ int deployService(string serviceUsername){
//call to the deploy functionality of all modules //call to the deploy functionality of all modules
//the modules themselves determine their course of action depending on the service //the modules themselves determine their course of action depending on the service
if (userCreated && envCreated){ if (userCreated && envCreated){
for(Module * mod : modules){ for(Module * mod_ptr : modules){
int modResult = (*mod).deploy(serviceUsername); int modResult = (*mod_ptr).deploy(serviceUsername);
if (modResult!=0){ if (modResult!=0){
cerr << "Error in module "<< mod << " when deploying " << serviceUsername << endl; cerr << "Error in module " << (*mod_ptr) << " when deploying " << serviceUsername << endl;
} }
} }
return 0; return 0;
@ -95,12 +94,12 @@ int main(int argc, char *argv[])
{ {
//check number of arguments //check number of arguments
if (argc != 3){ if (argc != 3){
cout << "Invalid number of arguments. \n" << endl; cerr << "Invalid number of arguments. \n" << endl;
help(argv[0]); help(argv[0]);
return -1; return -1;
} else { } else {
//check that data is mounted on the server //check that data is mounted on the server
if (!filesystem::exists("/data/mounted")) { if (!(filesystem::exists("/data/mounted"))) {
cerr << "Error. The data is not mounted on the server" << endl; cerr << "Error. The data is not mounted on the server" << endl;
return -1; return -1;
} else { } else {
@ -121,7 +120,8 @@ int main(int argc, char *argv[])
} }
} else { } else {
cerr << "Invalid argument. \n" << endl; cerr << "Invalid argument. \n" << endl;
exit(1); return -1;
}
} }
} }
return 0; return 0;