ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
factorycollection.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2017-2023 German Aerospace Center (DLR).
3  * Eclipse ADORe, Automated Driving Open Research https://eclipse.org/adore
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License 2.0 which is available at
7  * http://www.eclipse.org/legal/epl-2.0.
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  * Matthias Nichting - initial API and implementation
13  * Thomas Lobig - initial API and implementation
14  ********************************************************************************/
15 
16 #pragma once
21 
22 namespace adore
23 {
24  namespace if_ROS
25  {
26 
31  {
32  private:
33  ros::NodeHandle *nh_;
34 
35  public:
36  FactoryCollection(ros::NodeHandle *nh = nullptr)
37  {
38  nh_ = nh;
39  }
40  void init(ros::NodeHandle *nh = nullptr, std::string param_namespace = "")
41  {
42 
43  if (nh != nullptr)
44  {
45  nh_ = nh;
46  }
47  adore::env::EnvFactoryInstance::init(this->getFactory<ENV_Factory>());
48  adore::fun::FunFactoryInstance::init(this->getFactory<FUN_Factory>());
49  adore::sim::SimFactoryInstance::init(this->getFactory<SIM_Factory>());
51  }
56  template <typename T>
58  {
59  if (nh_ == nullptr)
60  {
61  throw std::runtime_error("No ros node handle available while calling getFactory()");
62  }
63  static T the_factory(nh_);
64  return &the_factory;
65  }
66  PARAMS_Factory *getParamsFactory(std::string prefix = "")
67  {
68  if (nh_ == nullptr)
69  {
70  throw std::runtime_error("No ros node handle available while calling getParamsFactory");
71  }
72  static PARAMS_Factory params_factory(*nh_, prefix);
73  return &params_factory;
74  }
75  };
76  } // namespace if_ROS
77 } // namespace adore
static void init(adore::env::AFactory *envFactory)
Initialize private members of AllFactory.
Definition: afactory.h:254
static void init(adore::fun::AFactory *funFactory)
Initialize private members of funFactory.
Definition: afactory.h:188
Definition: factorycollection.h:31
void init(ros::NodeHandle *nh=nullptr, std::string param_namespace="")
Definition: factorycollection.h:40
T * getFactory()
Definition: factorycollection.h:57
FactoryCollection(ros::NodeHandle *nh=nullptr)
Definition: factorycollection.h:36
ros::NodeHandle * nh_
Definition: factorycollection.h:33
PARAMS_Factory * getParamsFactory(std::string prefix="")
Definition: factorycollection.h:66
Definition: paramsfactory.h:49
static void init(adore::params::AFactory *paramsFactory)
Initialize private members of AllFactory.
Definition: afactory.h:121
static void init(adore::sim::AFactory *factory)
Initialize private members of AllFactory.
Definition: afactory.h:162
Definition: areaofeffectconverter.h:20