add ports
This commit is contained in:
parent
dc966782b5
commit
89fcef5619
5 changed files with 52 additions and 0 deletions
|
@ -5,6 +5,8 @@
|
|||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class Port;
|
||||
|
||||
class Device {
|
||||
public:
|
||||
friend std::ostream& operator<<(std::ostream& os, const Device& device);
|
||||
|
@ -24,6 +26,9 @@ public:
|
|||
private:
|
||||
void parseAndSetMac(const std::string& macAddress);
|
||||
|
||||
private:
|
||||
std::shared_ptr<Port> port;
|
||||
|
||||
public:
|
||||
uint8_t macAddress[6];
|
||||
};
|
20
netsim/include/Port.hpp
Normal file
20
netsim/include/Port.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class Device;
|
||||
|
||||
class Port {
|
||||
public:
|
||||
Port();
|
||||
|
||||
void Connect(std::shared_ptr<Port> port);
|
||||
|
||||
void Send(const std::vector<uint8_t>& data);
|
||||
std::vector<uint8_t> Receive();
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> data;
|
||||
std::weak_ptr<Port> connection;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue