10#ifndef __STRATEGY_SORTENTRIES_CLASSES_H__
11#define __STRATEGY_SORTENTRIES_CLASSES_H__
67 return reversedSort ? (first.
Name > second.
Name) : (first.
Name < second.
Name);
74 std::string function(__FUNCTION__);
75 return function.substr(0, function.rfind(
"::"));
128 return reversedSort ? (first.
Age > second.
Age) : (first.
Age < second.
Age);
135 std::string function(__FUNCTION__);
136 return function.substr(0, function.rfind(
"::"));
196 std::string function(__FUNCTION__);
197 return function.substr(0,function.rfind(
"::"));
Implementation of the EntryInformation class as used for data in the Strategy Pattern.
static EntryInformation entries[]
List of individuals to play around with in the Strategy exercise.
Declaration of the ISortEntries interface as used in the Strategy Pattern.
Strategy for sorting the ages in ascending (or descending) order.
bool _reversedSort
Controls order of sort: true for descending, false for ascending.
void Sort(std::vector< EntryInformation > &entries)
Sort the specified list of entries in place. A list is used here so we can leverage the List's sortin...
std::string ToString()
Return a string representation of the sorting strategy.
Strategy_SortEntries_ByAge(bool reversedSort)
Constructor.
Strategy for sorting the heights in ascending (or descending) order.
bool _reversedSort
Controls order of sort: true for descending, false for ascending.
void Sort(std::vector< EntryInformation > &entries)
Sort the specified list of entries in place. A list is used here so we can leverage the List's sortin...
std::string ToString()
Return a string representation of the sorting strategy.
Strategy_SortEntries_ByHeight(bool reversedSort)
Constructor.
Strategy for sorting the names in ascending (or descending) order.
bool _reversedSort
Controls order of sort: true for descending, false for ascending.
void Sort(std::vector< EntryInformation > &entries)
Sort the specified list of entries in place. A list is used here so we can leverage the List's sortin...
std::string ToString()
Return a string representation of the sorting strategy.
Strategy_SortEntries_ByName(bool reversedSort)
Constructor.
Holds the class constructor for the sorting strategies.
static ISortEntries::shared_ptr_t Create(SortOptions sortOption, bool reversedSort)
Generate an instance of a sorting strategy based on the given sorting option and reversed sort flag....
The namespace containing all Design Pattern Examples implemented in C++.
SortOptions
Identifies the different sorting strategies available.
Represents an individual with a Name, Age, and Height.
int Age
Age of this individual, in years.
int Height
Height of this individual, in inches.
std::string Name
Name of this individual.
Represents a sorting strategy.
std::shared_ptr< ISortEntries > shared_ptr_t
Alias to make it easier to work with a shared pointer.