Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2010-2024 German Aerospace Center (DLR) and others. 4 : // activitygen module 5 : // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/) 6 : // This program and the accompanying materials are made available under the 7 : // terms of the Eclipse Public License 2.0 which is available at 8 : // https://www.eclipse.org/legal/epl-2.0/ 9 : // This Source Code may also be made available under the following Secondary 10 : // Licenses when the conditions for such availability set forth in the Eclipse 11 : // Public License 2.0 are satisfied: GNU General Public License, version 2 12 : // or later which is available at 13 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 14 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 15 : /****************************************************************************/ 16 : /// @file AGAdult.h 17 : /// @author Piotr Woznica 18 : /// @author Walter Bamberger 19 : /// @author Daniel Krajzewicz 20 : /// @author Michael Behrisch 21 : /// @date July 2010 22 : /// 23 : // Person in working age: can be linked to a work position. 24 : /****************************************************************************/ 25 : #pragma once 26 : #include <config.h> 27 : 28 : #include <vector> 29 : #include <stdexcept> 30 : #include "AGPerson.h" 31 : 32 : 33 : // =========================================================================== 34 : // class declarations 35 : // =========================================================================== 36 : class AGWorkPosition; 37 : 38 : 39 : // =========================================================================== 40 : // class definitions 41 : // =========================================================================== 42 : /** 43 : * @class AGAdult 44 : * @brief An adult person who can have a job. 45 : * 46 : * AGAdult extends AGPerson by various methods to handle work life. 47 : */ 48 9503 : class AGAdult : public AGPerson { 49 : public: 50 : /** @brief Initialises the base class and the own attributes. 51 : * 52 : * @param[in] the age of the AGPerson 53 : */ 54 : AGAdult(int age); 55 : 56 : /** @brief Puts out a summary of the attributes. 57 : */ 58 : void print() const; 59 : 60 : /** @brief States whether this person occupies a work position at present. 61 : * 62 : * @return true if she has a work position 63 : */ 64 : bool isWorking() const; 65 : 66 : /** @brief Tries to get a new work position. 67 : * 68 : * Depending on the employment rate, this adult randomly gets unemployed 69 : * or employed. If it gets employed, it randomly chooses one of the free 70 : * work positions and occupies it. 71 : * 72 : * The new state (employed or unemployed) is chosen independently from the 73 : * previous state. If the adult was employed, her previous job is given up. 74 : * 75 : * @param[in]: employmentRate (1 - unemploymentRate) 76 : * @param[in]: wps the list of work positions (open or not) in the city 77 : */ 78 : void tryToWork(double employmentRate, std::vector<AGWorkPosition>* wps); 79 : 80 : /** @brief Called when the adult has lost her job. 81 : * 82 : * This method is called from AGWorkPosition, whenever the adult lost 83 : * her job, be it because it got fired or because its resignation has 84 : * been accepted. 85 : */ 86 : void lostWorkPosition(); 87 : 88 : /** @brief Called when the adult should resign her job. 89 : * 90 : * This method asks the WorkPosition to quit the job. The WorkPosition in 91 : * turn calls AGAdult::lostWorkPosition. 92 : */ 93 : void resignFromWorkPosition(); 94 : 95 : /** @brief Provides the work position of the adult. 96 : * 97 : * You should test before, whether the adult has a job. If you call this 98 : * method and the adult has no job, then a ProcessError is thrown. 99 : * 100 : * @return the work position 101 : * @throw ProcessError the adult has no work position 102 : */ 103 : const AGWorkPosition& getWorkPosition() const; 104 : 105 : private: 106 : /** The work position of this adult. 107 : * 108 : * A pointer to the work position or 0 if the adult is unemployed at present. 109 : */ 110 : AGWorkPosition* work; 111 : 112 : /** @brief Randomly selects a free work position from the list. 113 : * 114 : * @param[in] the list of work positions (free or not) 115 : * @return the chosen free work position 116 : */ 117 : static AGWorkPosition* randomFreeWorkPosition(std::vector<AGWorkPosition>* wps); 118 : };