aboutsummaryrefslogtreecommitdiff
path: root/oop2eindopdr/Pokedex.h
blob: ec4ac26b61d190ace95c964eccd8ee31e4506853 (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include <string>
#include <vector>

#include "CacheManager.h"

class PokemonCard;
class PokemonTCGAPIClient;
class DownloadManager;

/** @brief user pokedex class, handles caching and api access silently */
class Pokedex {
private:
	std::vector<PokemonCard*> cards;

	/** @brief download card collection using API client */
	virtual void load_collection_remote();
	/** @brief load cards from cache */
	virtual void load_collection_local();

	/** @brief verify all cards in collection */
	virtual void verify_collection();

	/** @brief cache connection */
	CacheManager* cache = nullptr;
	PokemonTCGAPIClient* api = nullptr;
	DownloadManager* download_manager = nullptr;

	friend class PokemonCard;

	virtual std::vector<PokemonCard*> search_cards_local(std::string query);
	virtual std::vector<PokemonCard*> search_cards_remote(std::string query);

	/** @brief convert std::string to lowercase */
	std::string lower(std::string input);

public:
	Pokedex();
	virtual ~Pokedex();

	/** @brief search cards that contain `query` in id or name field */
	virtual std::vector<PokemonCard*> search_cards(std::string query);
	/** @brief get card with specific id */
	virtual PokemonCard* get_card_by_id(std::string id);
};