Network Class The Network class represents a network of people that are connected to each other and are able to contact and send messages to each other through the network. Create a Network class with the following: Member Variables A Network has just one private member variable: phonebook_ - a std::map which maps from a std::string for a person's name, to the std::shared_ptr object that belongs to that person. Constructor You do not need to explicitly define a constructor. The default constructor will implicitly be created for us by the compiler, initializing the phonebook_ to an empty map. AddPhone Create a function AddPhone that accepts a std::shared_ptr to a Phone and inserts that Phone to the phonebook_. The key is the name of that phone's owner, and the value is the shared pointer to the Phone. SendMessage Create a function SendMessage that accepts a std::shared_ptr to a Message and a const reference to a std::string representing the intended recipient of this message. You must check if the intended recipient is in the phonebook_, because if an invalid recipie

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Network Class

The Network class represents a network of people that are connected to each other and are able to contact and send messages to each other through the network. Create a Network class with the following:

Member Variables

A Network has just one private member variable:

  1. phonebook_ - a std::map which maps from a std::string for a person's name, to the std::shared_ptr<Phone> object that belongs to that person.

Constructor

You do not need to explicitly define a constructor. The default constructor will implicitly be created for us by the compiler, initializing the phonebook_ to an empty map.

AddPhone

Create a function AddPhone that accepts a std::shared_ptr to a Phone and inserts that Phone to the phonebook_. The key is the name of that phone's owner, and the value is the shared pointer to the Phone.

SendMessage

Create a function SendMessage that accepts a std::shared_ptr to a Message and a const reference to a std::string representing the intended recipient of this message. You must check if the intended recipient is in the phonebook_, because if an invalid recipient is provided, no message should be sent over the network. If the recipient exists in the phonebook_, then use the Phone::AcceptMessage function to send that message to the recipient's phone.

SendMessage Overload

Create a function SendMessage that accepts a std::shared_ptr to a Message and a const reference to a vector of std::string representing a list of recipients in the network to send the given message to. Like above, you must check if the intended recipient is in the phonebook_ before sending the message to that recipient's phone.

network.hx C network.cc x
Run
C phone.h x C+ phone.ccx
1 // ===========
========= YOUR CODE HERE =========================
2 // This implementation file (network.cc) is where you should implement
3 // the member functions declared in the header (network.h), only
4 // if you didn't implement them inline within network.h.
5
//
6 // Remember to specify the name of the class with :: in this format:
<return type> MyClassName::MyFunction() {
7
8
//
9
//
}
10 // to tell the compiler that each function belongs to the Network class.
11 // ===
C message.h x +
=======
Transcribed Image Text:network.hx C network.cc x Run C phone.h x C+ phone.ccx 1 // =========== ========= YOUR CODE HERE ========================= 2 // This implementation file (network.cc) is where you should implement 3 // the member functions declared in the header (network.h), only 4 // if you didn't implement them inline within network.h. 5 // 6 // Remember to specify the name of the class with :: in this format: <return type> MyClassName::MyFunction() { 7 8 // 9 // } 10 // to tell the compiler that each function belongs to the Network class. 11 // === C message.h x + =======
>
1 #pragma once
2
3 #include <map>
4 #include <memory>
5
6 #include "message.h"
7 #include "phone.h"
8
9▼ class Network {
10
11
12
13
14 private:
15
16
17
18
19
20
21
22 };
//
YOUR CODE HERE
// Write the Network class here. Refer to the README for the member
// variables, constructors, and member functions needed.
//
std::map<std::string, std::shared_ptr<Phone>> phonebook_;
public:
// If you were the "driver" for the Phone class, then switch roles
// with your lab partner and act as the "navigator" for this class.
Transcribed Image Text:> 1 #pragma once 2 3 #include <map> 4 #include <memory> 5 6 #include "message.h" 7 #include "phone.h" 8 9▼ class Network { 10 11 12 13 14 private: 15 16 17 18 19 20 21 22 }; // YOUR CODE HERE // Write the Network class here. Refer to the README for the member // variables, constructors, and member functions needed. // std::map<std::string, std::shared_ptr<Phone>> phonebook_; public: // If you were the "driver" for the Phone class, then switch roles // with your lab partner and act as the "navigator" for this class.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY