/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2010-2025 German Aerospace Center (DLR) and others.3// activitygen module4// Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)5// This program and the accompanying materials are made available under the6// terms of the Eclipse Public License 2.0 which is available at7// https://www.eclipse.org/legal/epl-2.0/8// This Source Code may also be made available under the following Secondary9// Licenses when the conditions for such availability set forth in the Eclipse10// Public License 2.0 are satisfied: GNU General Public License, version 211// or later which is available at12// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html13// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later14/****************************************************************************/15/// @file AGChild.cpp16/// @author Piotr Woznica17/// @author Daniel Krajzewicz18/// @author Michael Behrisch19/// @author Walter Bamberger20/// @author Michael Behrisch21/// @date July 201022///23// Person in age to go to school: linked to a school object24/****************************************************************************/25#include <config.h>2627#include <iostream>28#include <vector>29#include <limits>30#include "AGChild.h"31#include "AGSchool.h"323334// ===========================================================================35// method definitions36// ===========================================================================37void38AGChild::print() const {39std::cout << "- Child: Age=" << age << " School=" << mySchool << std::endl;40}4142bool43AGChild::setSchool(AGSchool* school) {44if (school == nullptr) {45return false;46}47bool enoughPlace = school->addNewChild();48if (enoughPlace) {49mySchool = school;50}51return enoughPlace;52}5354bool55AGChild::allocateASchool(std::list<AGSchool>* schools, AGPosition housePos) {56double minDist = std::numeric_limits<double>::infinity();57AGSchool* sch = nullptr;58if (schools->size() == 0) {59return false;60}61std::list<AGSchool>::iterator it;6263for (it = schools->begin(); it != schools->end(); ++it) {64if (it->acceptThisAge(age) && it->getPlaces() > 0 && housePos.distanceTo(it->getPosition()) < minDist) {65minDist = housePos.distanceTo(it->getPosition());66sch = &(*it);67}68}69return setSchool(sch);70}7172bool73AGChild::leaveSchool() {74if (mySchool != nullptr)75if (!mySchool->removeChild()) {76return false;77}78mySchool = nullptr;79return true;80}8182bool83AGChild::haveASchool() const {84return (mySchool != nullptr);85}8687AGPosition88AGChild::getSchoolLocation() const {89return mySchool->getPosition();90}9192int93AGChild::getSchoolClosing() const {94return mySchool->getClosingHour();95}9697int98AGChild::getSchoolOpening() const {99return mySchool->getOpeningHour();100}101102103/****************************************************************************/104105106