Bonjour,
Je me décide enfin à poster pour un problème qui me bloque désormais totalement dans l'avancée du projet.
Il est assez problématique, et témoignera sûrement d'un manque de connaissance en C++, mais je séche complétement après moultes tests & recherches.
Le problème se situe dans la classe Service, à partir du moment ou j'ajoute en paramètre de méthode un pointeur vers un objet Client (méthode execute). A la compilation, on m'informe sympathiquement que la classe "mole::ctx::Client" n'a pas été déclaré. Donc je déclare auparavant dans Service.hpp cette classe, avec "class Client;". Cela ne change strictement rien.
Et si j'inclue le fichier Client.hpp, la compilation me révéle des erreurs dans d'autres fichiers, qui compilaient auparavant bien, et m'informe cette fois que la classe Service n'existe pas.
J'avouerais être désappointé, et si vous aviez quelques idées sous la main, je vous en serais très reconnaissant. Je joins les 2 .hpp (Service & Client).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #ifndef SERVICE_HPP #define SERVICE_HPP #include "Response.hpp" #include "Request.hpp" // Ici, c'est le drame. //#include "Client.hpp" //class Client; namespace mole { namespace serv { /** * A service is an action that a client can ask to a server. * A request is used to communicate between client & server, into the * service. * It is possible to have for one service many kinds of requests * available. * Notice that input arguments are stored into the service, and output * args are into the request, after the execution. */ class Service { public : /** * Constructs a service with a specific request. * * @param req The request to use into the service. */ Service(mole::ctx::Request *); Service(); ~Service(); /** * Execute the service. There is no return value, cause the * service has to treat argument with the help of the request. */ virtual bool execute(mole::ctx::Client *); /** * Returns the response as an object. */ Response * getResponse(); /* * Returns the request associated to the client. * Useful to parameter the service invocation. */ mole::ctx::Request * getRequest(); virtual Service * newInvocableService(mole::ctx::Request * r); protected : /* The request linked to the service. */ mole::ctx::Request * request; /* The response filled after the request execution */ Response * response; private : }; }; // end of namespace mole }; // end of namespace serv #endif
Merci grandement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102 #ifndef CLIENT_HPP #define CLIENT_HPP #include <string> #include "Server.hpp" #include "RequestFactory.hpp" namespace mole { namespace ctx { /** * A client is bind to a server. This class allows to easily dialog * with a server. */ class Client { public : /** * Constructs a client, and bind it to the server in parameter. * No connection is done at construction * * @param server The server */ Client(Server * server); Client(); ~Client(); /** * Gets the server binded to the client. * @return The server */ Server * getServer(); /** * Gets a service from the server. * * @param service Service to get. */ mole::serv::Service * getService(std::string); /** * Initialize the client and clear all connections. * * @return True if init was success, false else. */ bool init(); /** * Links client to a server. * * @param server Server wanted by the client. * @param co True if you want to connect immediately to the server, else * false. * @return True if connected, false else. */ bool bind(Server * server, bool co); /** * Connect the client to the server. If client is connected, * <b>init</b> is called before any reconnection. * * @return True if connected, false else. */ bool connect(); /** * Disconnect all existing connections between client and server. */ void disconnect(); /** * Execute a service, using this client. * * @param service Service to execute. */ bool execute(mole::serv::Service * service); mole::ctx::Request * createRequest(std::string name); void addRequest(std::string name, mole::ctx::Request * req); protected : /** Flag about connection status. True <==> Connected. */ bool connected; /** Server where the client is connected to */ Server * server; /** A client use a request factory to facilitate services utilisation */ RequestFactory * requestFactory; }; // end of class }; // end of serv }; // end of mole #endif
Partager