Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
ptree-employee-factory.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This file is part of the gobelijn software.
4  * Gobelijn is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation, either version 3 of the License, or any later
7  * version. Gobelijn is distributed in the hope that it will be useful, but
8  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9  * or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for details. You should have received
11  * a copy of the GNU General Public License along with the software. If not,
12  * see <http://www.gnu.org/licenses/>.
13  *
14  * Copyright 2016, Jan Broeckhove.
15  */
21 #include "employee.h"
22 #include "factory.h"
23 #include <boost/property_tree/ptree.hpp>
24 
25 namespace AbstractFactory {
30 class PtreeEmployeeFactory : public Factory<Employee>
31 {
32 public:
34  explicit PtreeEmployeeFactory(const boost::property_tree::ptree& ptree) : m_ptree(ptree) {}
35 
37  Employee Create() final;
38 
40  static constexpr const char* EmployeeNameKey = "Name";
41 
43  static constexpr const char* EmployeeDepartmentNameKey = "DepartmentName";
44 
46  static constexpr const char* EmployeeSalaryKey = "Salary";
47 
48 private:
49  boost::property_tree::ptree m_ptree;
50 };
51 } // namespace AbstractFactory
PtreeEmployeeFactory(const boost::property_tree::ptree &ptree)
Creates a factory that analyzes the given property tree, and construct an employee instance...
static constexpr const char * EmployeeNameKey
The Boost property tree key for the employees' names.
Employee POD.
Factory interface.
A data structure that represents an employee's data.
Definition: employee.h:28
static constexpr const char * EmployeeDepartmentNameKey
The Boost property tree key for the employees' department names.
An employee factory implementation that uses Boost property trees to construct employee instances...
Employee Create() final
Instructs this factory to create a value.
static constexpr const char * EmployeeSalaryKey
The Boost property tree key for the employees' salaries.
A class template for abstract factories: objects that construct values based on their internal state...
Definition: factory.h:27