Beerappa S M | 7af96e5 | 2021-04-20 18:57:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021-present Open Networking Foundation |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at |
| 6 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | * Unless required by applicable law or agreed to in writing, software |
| 8 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | * See the License for the specific language governing permissions and |
| 11 | * limitations under the License. |
| 12 | */ |
| 13 | |
| 14 | #ifndef DMI_HW_MGMT_H_ |
| 15 | #define DMI_HH_MGMT_H_ |
| 16 | |
| 17 | #include "hw_management_service.grpc.pb.h" |
| 18 | #include "hw_management_service.pb.h" |
| 19 | #include "dmi_common.h" |
| 20 | |
| 21 | using grpc::ServerWriter; |
| 22 | |
| 23 | grpc::Status StartManagingDevice_( |
| 24 | const dmi::ModifiableComponent* request, |
| 25 | ServerWriter<dmi::StartManagingDeviceResponse>* writer |
| 26 | ); |
| 27 | grpc::Status StopManagingDevice_(dmi::StopManagingDeviceResponse* response); |
| 28 | grpc::Status GetManagedDevices_(dmi::ManagedDevicesResponse* response); |
| 29 | grpc::Status GetPhysicalInventory_(dmi::PhysicalInventoryResponse* response); |
| 30 | |
| 31 | class HWMgmtService final : public dmi::NativeHWManagementService::Service |
| 32 | { |
| 33 | public: |
| 34 | static HWMgmtService& getHWInstance() |
| 35 | { |
| 36 | static HWMgmtService hwinstance; |
| 37 | return hwinstance; |
| 38 | } |
| 39 | |
| 40 | grpc::Status StartManagingDevice( |
| 41 | ServerContext* context, |
| 42 | const dmi::ModifiableComponent* request, |
| 43 | ServerWriter<dmi::StartManagingDeviceResponse>* writer |
| 44 | ) |
| 45 | { |
| 46 | return StartManagingDevice_(request, writer); |
| 47 | } |
| 48 | |
| 49 | grpc::Status StopManagingDevice( |
| 50 | ServerContext* context, |
| 51 | const dmi::StopManagingDeviceRequest* request, |
| 52 | dmi::StopManagingDeviceResponse* response |
| 53 | ) |
| 54 | { |
| 55 | return StopManagingDevice_(response); |
| 56 | } |
| 57 | |
| 58 | grpc::Status GetManagedDevices( |
| 59 | ServerContext* context, |
| 60 | const google::protobuf::Empty* request, |
| 61 | dmi::ManagedDevicesResponse* response |
| 62 | ) |
| 63 | { |
| 64 | return GetManagedDevices_(response); |
| 65 | } |
| 66 | |
| 67 | grpc::Status GetPhysicalInventory( |
| 68 | ServerContext* context, |
| 69 | const dmi::PhysicalInventoryRequest* request, |
| 70 | dmi::PhysicalInventoryResponse* response |
| 71 | ) |
| 72 | { |
| 73 | return GetPhysicalInventory_(response); |
| 74 | } |
| 75 | |
| 76 | private: |
| 77 | HWMgmtService() |
| 78 | { |
| 79 | } |
| 80 | |
| 81 | ~HWMgmtService() |
| 82 | { |
| 83 | } |
| 84 | }; |
| 85 | |
| 86 | #endif |