Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
ptree-employee-factory.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the gobelijn software.
3  * Gobelijn is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the
5  * Free Software Foundation, either version 3 of the License, or any later
6  * version. Gobelijn is distributed in the hope that it will be useful, but
7  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8  * or FITNESS FOR A PARTICULAR PURPOSE.
9  * See the GNU General Public License for details. You should have received
10  * a copy of the GNU General Public License along with the software. If not,
11  * see <http://www.gnu.org/licenses/>.
12  *
13  * Copyright 2016, Jan Broeckhove.
14  */
20 #include "ptree-employee-factory.h"
21 
22 namespace AbstractFactory {
23 
28 {
29  // Grab some values from the ptree, and use them to build an Employee instance.
30  Employee result;
31  result.Name = m_ptree.get_child(EmployeeNameKey).get_value<std::string>();
32  result.DepartmentName = m_ptree.get_child(EmployeeDepartmentNameKey).get_value<std::string>();
33  result.Salary = m_ptree.get_child(EmployeeSalaryKey).get_value<double>();
34  return result;
35 }
36 
37 } // namespace AbstractFactory
double Salary
Stores the employee's monthly wage.
Definition: employee.h:34
std::string DepartmentName
Stores the name of the employee's department.
Definition: employee.h:33
std::string Name
Stores the person's name.
Definition: employee.h:32
static constexpr const char * EmployeeNameKey
The Boost property tree key for the employees' names.
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.
Concrete ptree based factory.
Employee Create() final
Instructs this factory to create a value.
static constexpr const char * EmployeeSalaryKey
The Boost property tree key for the employees' salaries.