-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainServer.cpp
More file actions
25 lines (23 loc) · 791 Bytes
/
MainServer.cpp
File metadata and controls
25 lines (23 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "MainServer.hpp"
// Adds a new movie to the main server
void MainServer::addMovie(const std::string& name, std::string path) {
// Insert the movie into the library using the movie name as the key
movieLibrary[name] =new Movie(name, path);
}
// Retrieves a movie by name from the main server
Movie* MainServer::getMovie(const std::string& movieName) {
auto it = movieLibrary.find(movieName);
if (it != movieLibrary.end()) {
return (it->second); // Return a pointer to the Movie object if found
}
return nullptr; // Return nullptr if the movie is not found
}
const std::vector<Movie*> MainServer::getAllMovies()
{
std::vector<Movie*> movies;
for(auto it: movieLibrary)
{
movies.push_back((it.second));
}
return movies;
}