Ver Fonte

server-mode: Pass server into cmServerProtocol

The information will be needed to send signals.
Tobias Hunger há 9 anos atrás
pai
commit
cc576c2c7f
4 ficheiros alterados com 10 adições e 4 exclusões
  1. 1 1
      Source/cmServer.cxx
  2. 2 1
      Source/cmServer.h
  3. 4 1
      Source/cmServerProtocol.cxx
  4. 3 1
      Source/cmServerProtocol.h

+ 1 - 1
Source/cmServer.cxx

@@ -220,7 +220,7 @@ cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request)
   }
 
   std::string errorMessage;
-  if (!this->Protocol->Activate(request, &errorMessage)) {
+  if (!this->Protocol->Activate(this, request, &errorMessage)) {
     this->Protocol = CM_NULLPTR;
     return request.ReportError("Failed to activate protocol version: " +
                                errorMessage);

+ 2 - 1
Source/cmServer.h

@@ -95,6 +95,7 @@ private:
 
   mutable bool Writing = false;
 
-  friend class cmServerRequest;
   friend class cmServerConnection;
+  friend class cmServerProtocol;
+  friend class cmServerRequest;
 };

+ 4 - 1
Source/cmServerProtocol.cxx

@@ -109,9 +109,12 @@ Json::Value cmServerResponse::Data() const
   return this->m_Data;
 }
 
-bool cmServerProtocol::Activate(const cmServerRequest& request,
+bool cmServerProtocol::Activate(cmServer* server,
+                                const cmServerRequest& request,
                                 std::string* errorMessage)
 {
+  assert(server);
+  this->m_Server = server;
   this->m_CMakeInstance = std::make_unique<cmake>();
   const bool result = this->DoActivate(request, errorMessage);
   if (!result)

+ 3 - 1
Source/cmServerProtocol.h

@@ -87,7 +87,8 @@ public:
   virtual bool IsExperimental() const = 0;
   virtual const cmServerResponse Process(const cmServerRequest& request) = 0;
 
-  bool Activate(const cmServerRequest& request, std::string* errorMessage);
+  bool Activate(cmServer* server, const cmServerRequest& request,
+                std::string* errorMessage);
 
 protected:
   cmake* CMakeInstance() const;
@@ -97,6 +98,7 @@ protected:
 
 private:
   std::unique_ptr<cmake> m_CMakeInstance;
+  cmServer* m_Server = nullptr; // not owned!
 
   friend class cmServer;
 };