Design Pattern Examples
Overview of object-oriented design patterns
Strategy_ISortEntries.h
Go to the documentation of this file.
1
5
6#pragma once
7#ifndef __STRATEGY_ISORTENTRIES_H__
8#define __STRATEGY_ISORTENTRIES_H__
9
10#include <memory>
11#include <vector>
12#include <string>
13
15{
16
21 {
26
31
36 };
37
38
39 //########################################################################
40 //########################################################################
41
42
43 struct EntryInformation; // forward reference
44
49 {
53 using shared_ptr_t = std::shared_ptr<ISortEntries>;
54
58 virtual ~ISortEntries() {}
59
64 virtual void Sort(std::vector<EntryInformation>& entries) = 0;
65
70 virtual std::string ToString() = 0;
71 };
72
73} // end namespace
74
75#endif // __STRATEGY_ISORTENTRIES_H__
76
static EntryInformation entries[]
List of individuals to play around with in the Strategy exercise.
The namespace containing all Design Pattern Examples implemented in C++.
SortOptions
Identifies the different sorting strategies available.
@ ByHeight
Sort numerically by height in ascending order.
@ ByAge
Sort numerically by age in ascending order.
@ ByName
Sort alphabetically name in ascending order.
std::shared_ptr< ISortEntries > shared_ptr_t
Alias to make it easier to work with a shared pointer.
virtual void Sort(std::vector< EntryInformation > &entries)=0
Sort the specified list of entries in place.
virtual ~ISortEntries()
Required virtual destructor for interfaces in C++.
virtual std::string ToString()=0
Return a string representation of the sorting strategy.
Represents an individual with a Name, Age, and Height.