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"
//constructor and destructor inline
DockerModule::DockerModule()
{
name="Docker";
}
//public methods
int DockerModule::prepare()
{

View File

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

View File

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

View File

@ -10,6 +10,11 @@
//destructor, could not be inline because pure virtual
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 remove(string serviceUsername)=0;
virtual int clean ()=0;
friend ostream & operator<< (ostream & out, const Module & m);
string name;
};
#endif

View File

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

View File

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