Blame view

server/kernel/src/RequestManager/RequestAbstract.h 2.28 KB
346b85c6   Benjamin Renard   First commit with...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef REQUESTABSTRACT_H
#define REQUESTABSTRACT_H

#include <string>

#include "../Application/Application.h"
#include "../WorkingDirManager/WorkingDirManager.h"
#include "RequestLoader.h"
#include "ResultWriter.h"

using namespace TREPS::Application;
using namespace TREPS::WorkingDirManager;

namespace TREPS
{
	namespace RequestManager
	{
		//enumerate that define the request output type
		typedef enum {
			//no output file. Just return OK if the request execution is a success
			OUTPUT_NONE,
			//send a path to a existing xml file
			OUTPUT_XMLFILE,
			//send a path to a generated result file (in a workind dir)
			OUTPUT_RESULTFILE,
			//send a single string
			OUTPUT_STRING
			} t_RequestOutputType;
		
		//Base class to use for all requests!
		class RequestAbstractClass
		{
			public:
				RequestAbstractClass(void);
				
				virtual ~RequestAbstractClass(void) = 0;

				//get request id
				virtual string getRequestId(void) = 0;

				//load request
				virtual bool load(RequestLoaderClass *loader) = 0;
				
				//execute the request process
				virtual bool run(void) = 0;
				
				//write the content of the request result file
				virtual void writeResult(ResultWriterClass *writer) = 0;

				//get the working dir of the current operation
				string getWorkingDir(void);

				//init the oeration id
				bool initOpId(RequestLoaderClass *loader, bool lockWorkingDir);

				//get request output type
				t_RequestOutputType getOutputType(void);

				//To know if this request use the cache - By default set to false
				bool useCacheResult(void);

				//specific suffix used to name result file - only used when the request type is OUTPUT_RESULTFILE
				virtual string getResultFileSuffix(void) = 0;

				//xml file path used as result - only used when the request type is OUTPUT_XMLFILE
				virtual string getXMLFilePath(void) = 0;

				//string as result - only used when the request type is OUTPUT_STRING
				virtual string getStringResult(void) = 0;

				//set request status in opêration list file
				void setStatus(const char *status);

			protected:
				ApplicationClass *app;

				WorkingDirManagerClass *dirMgr;
				
				string opId;

				bool useCache;

				t_RequestOutputType outputType;
		};
	}
}

#endif