g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
core
robust_kernel_factory.cpp
Go to the documentation of this file.
1
// g2o - General Graph Optimization
2
// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are
7
// met:
8
//
9
// * Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// * Redistributions in binary form must reproduce the above copyright
12
// notice, this list of conditions and the following disclaimer in the
13
// documentation and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
#include "
robust_kernel_factory.h
"
28
29
#include <cassert>
30
31
#include "
g2o/stuff/logger.h
"
32
33
using namespace
std
;
34
35
namespace
g2o
{
36
37
std::unique_ptr<RobustKernelFactory>
RobustKernelFactory::factoryInstance
;
38
39
RobustKernelFactory
*
RobustKernelFactory::instance
() {
40
if
(
factoryInstance
==
nullptr
) {
41
factoryInstance
.reset(
new
RobustKernelFactory
);
42
}
43
44
return
factoryInstance
.get();
45
}
46
47
void
RobustKernelFactory::registerRobustKernel
(
48
const
std::string& tag,
const
AbstractRobustKernelCreator::Ptr
& c) {
49
CreatorMap::const_iterator foundIt =
_creator
.find(tag);
50
if
(foundIt !=
_creator
.end()) {
51
G2O_WARN
(
"RobustKernelFactory WARNING: Overwriting robust kernel tag {}"
,
52
tag);
53
assert(0);
54
}
55
56
_creator
[tag] = c;
57
}
58
59
void
RobustKernelFactory::unregisterType
(
const
std::string& tag) {
60
CreatorMap::iterator tagPosition =
_creator
.find(tag);
61
if
(tagPosition !=
_creator
.end()) {
62
_creator
.erase(tagPosition);
63
}
64
}
65
66
RobustKernel
*
RobustKernelFactory::construct
(
const
std::string& tag)
const
{
67
CreatorMap::const_iterator foundIt =
_creator
.find(tag);
68
if
(foundIt !=
_creator
.end()) {
69
return
foundIt->second->construct();
70
}
71
return
nullptr
;
72
}
73
74
AbstractRobustKernelCreator
*
RobustKernelFactory::creator
(
75
const
std::string& tag)
const
{
76
CreatorMap::const_iterator foundIt =
_creator
.find(tag);
77
if
(foundIt !=
_creator
.end()) {
78
return
foundIt->second.get();
79
}
80
return
nullptr
;
81
}
82
83
void
RobustKernelFactory::fillKnownKernels
(
84
std::vector<std::string>& types)
const
{
85
types.clear();
86
for
(CreatorMap::const_iterator it =
_creator
.begin(); it !=
_creator
.end();
87
++it)
88
types.push_back(it->first);
89
}
90
91
void
RobustKernelFactory::destroy
() {
92
std::unique_ptr<RobustKernelFactory> aux;
93
factoryInstance
.swap(aux);
94
}
95
96
}
// namespace g2o
g2o::AbstractRobustKernelCreator
Abstract interface for allocating a robust kernel.
Definition
robust_kernel_factory.h:46
g2o::AbstractRobustKernelCreator::Ptr
std::shared_ptr< AbstractRobustKernelCreator > Ptr
Definition
robust_kernel_factory.h:53
g2o::RobustKernelFactory::construct
RobustKernel * construct(const std::string &tag) const
Definition
robust_kernel_factory.cpp:66
g2o::RobustKernelFactory::fillKnownKernels
void fillKnownKernels(std::vector< std::string > &types) const
Definition
robust_kernel_factory.cpp:83
g2o::RobustKernelFactory::registerRobustKernel
void registerRobustKernel(const std::string &tag, const AbstractRobustKernelCreator::Ptr &c)
Definition
robust_kernel_factory.cpp:47
g2o::RobustKernelFactory::creator
AbstractRobustKernelCreator * creator(const std::string &tag) const
Definition
robust_kernel_factory.cpp:74
g2o::RobustKernelFactory::destroy
static void destroy()
free the instance
Definition
robust_kernel_factory.cpp:91
g2o::RobustKernelFactory::instance
static RobustKernelFactory * instance()
return the instance
Definition
robust_kernel_factory.cpp:39
g2o::RobustKernelFactory::RobustKernelFactory
RobustKernelFactory(RobustKernelFactory const &)=delete
g2o::RobustKernelFactory::factoryInstance
static std::unique_ptr< RobustKernelFactory > factoryInstance
Definition
robust_kernel_factory.h:112
g2o::RobustKernelFactory::unregisterType
void unregisterType(const std::string &tag)
Definition
robust_kernel_factory.cpp:59
g2o::RobustKernelFactory::_creator
CreatorMap _creator
look-up map for the existing creators
Definition
robust_kernel_factory.h:109
g2o::RobustKernel
base for all robust cost functions
Definition
robust_kernel.h:48
G2O_WARN
#define G2O_WARN(...)
logger.h
g2o
Definition
dl_wrapper.cpp:55
std
Definition
jet.h:876
robust_kernel_factory.h
Generated on
for g2o by
1.17.0