Clean up CMakeLists in all C++ examples
+ Rename output executables to match directory structure + Remove libraries for small examples + Supress -Wreturn-type warnings for singleton that is intentionally not copyable
This commit is contained in:
33
cpp/patterns/factory/abstract-factory.hpp
Normal file
33
cpp/patterns/factory/abstract-factory.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
#ifndef FACTORY_HPP
|
||||
#define FACTORY_HPP
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "parts.hpp"
|
||||
|
||||
// Gear Concrete Factory
|
||||
class GearFactory {
|
||||
public:
|
||||
explicit GearFactory(std::string name_="GearFactory") :
|
||||
name(std::move(name_)) {}
|
||||
|
||||
Part* requestPart();
|
||||
Part* requestPart(std::string partName, float price);
|
||||
void showStock() const;
|
||||
std::string getName() const { return name;}
|
||||
|
||||
protected:
|
||||
Part* makePart();
|
||||
Part* makePart(std::string name, float price);
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
std::unordered_map<std::string, int> inventory;
|
||||
};
|
||||
|
||||
#endif // FACTORY_HPP
|
||||
Reference in New Issue
Block a user