master
h 49 lines 1.16 KB
Raw
1 // Copyright (C) Microsoft Corporation. All rights reserved.
2 #pragma once
3
4 namespace p9fs {
5
6 // This class serves as a base for the platform-specific Root class. It has
7 // no functionality.
8 class IRoot
9 {
10 public:
11 virtual ~IRoot() = default;
12
13 protected:
14 IRoot() = default;
15 };
16
17 class IShareList
18 {
19 public:
20 virtual ~IShareList() = default;
21
22 virtual Expected<std::shared_ptr<const IRoot>> MakeRoot(std::string_view aname, LX_UID_T uid) = 0;
23 virtual size_t MaximumConnectionCount() = 0;
24 };
25
26 // Interface through which virtio can process messages on a handler.
27 // N.B. This definition is not in p9handler so it can be used without needing to include all the
28 // coroutine related headers as well.
29 class IHandler
30 {
31 public:
32 using HandlerCallback = std::function<void(const std::vector<gsl::byte>& response)>;
33 virtual void ProcessMessageAsync(std::vector<gsl::byte>&& message, size_t responseSize, HandlerCallback&& callback) = 0;
34 };
35
36 class HandlerFactory
37 {
38 public:
39 HandlerFactory(IShareList& shareList) : m_shareList{shareList}
40 {
41 }
42
43 std::unique_ptr<IHandler> CreateHandler() const;
44
45 private:
46 IShareList& m_shareList;
47 };
48
49 } // namespace p9fs