Ignition Plugin

API Reference

1.2.1
Factory.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef IGNITION_PLUGIN_FACTORY_HH_
19 #define IGNITION_PLUGIN_FACTORY_HH_
20 
21 #include <chrono>
22 #include <functional>
23 #include <memory>
24 #include <tuple>
25 
27 
28 namespace ignition
29 {
30  namespace plugin
31  {
36  template <typename Interface> class ProductDeleter;
37 
49  template <typename Interface>
50  using ProductPtr =
52 
74  template <typename Interface, typename... Args>
76  {
78 
85  public: ProductPtrType Construct(Args&&... _args);
86 
92  private: virtual Interface *ImplConstruct(Args&&... _args) = 0;
93 
96  public: template <typename Product>
97  class Producing;
98  };
99 
135  void IGNITION_PLUGIN_VISIBLE CleanupLostProducts(
136  const std::chrono::nanoseconds &_safetyWait =
138 
142  std::size_t IGNITION_PLUGIN_VISIBLE LostProductCount();
143  }
144 }
145 
146 #include <ignition/plugin/detail/Factory.hh>
147 
148 #endif
Definition: Factory.hh:97
void CleanupLostProducts(const std::chrono::nanoseconds &_safetyWait=std::chrono::nanoseconds(5))
Call this function to cleanup the Factories of any Products which were not managed by a ProductPtr or...
EnablePluginFromThis is an optional base class which can be inherited by Plugin classes. When a Plugin class inherits it and that Plugin class is instantiated using the Loader class, its instance will be able to access the PluginPtr that manages its lifecycle. This interface will also be available by calling instance->QueryInterface<EnablePluginFromThis>()
Definition: EnablePluginFromThis.hh:40
std::size_t LostProductCount()
Get the number of lost products that have currently accumulated since the last time CleanupLostProduc...
ProductPtrType Construct(Args &&... _args)
This function is called by Loader to construct the class that implements the InterfacePtr interface...
STL class.
This class provides a unary operator for safely deleting pointers to plugin factory products with the...
Definition: Factory.hh:36
Definition: EnablePluginFromThis.hh:25
The Factory class defines a plugin factory that can be used by the Loader class to produce products t...
Definition: Factory.hh:75