1 /* 2 * Copyright 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <cstdint> 20 #include <memory> 21 #include <string_view> 22 23 #include "controller/chip.h" 24 #include "model.pb.h" 25 26 namespace netsim { 27 namespace controller { 28 29 class Chip; 30 31 class Device { 32 public: 33 const uint32_t id; 34 const std::string guid; 35 const std::string name; 36 bool visible; 37 model::Position position; 38 model::Orientation orientation; 39 Device(uint32_t id,const std::string & guid,const std::string & name)40 Device(uint32_t id, const std::string &guid, const std::string &name) 41 : id(id), guid(guid), name(name), visible(true) {} 42 43 model::Device Get(); 44 void Patch(const model::Device &request); 45 bool RemoveChip(uint32_t chip_id); 46 std::pair<uint32_t, uint32_t> AddChip(common::ChipKind chip_kind, 47 const std::string &chip_name, 48 const std::string &manufacturer, 49 const std::string &product_name); 50 void Reset(); 51 void Remove(); 52 53 std::unordered_map<uint32_t, std::shared_ptr<Chip>> chips_; 54 }; 55 56 } // namespace controller 57 } // namespace netsim 58