object_finders.cpp
Go to the documentation of this file.
1 /**
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotAPI::libraries::aron
17  * @author Philip Scherer ( ulila@student.kit.edu )
18  * @date 2021
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #include "object_finders.h"
24 
25 namespace armarx::aron
26 {
27  SubObjectFinder::SubObjectFinder(const std::string& typeNamePrefix) :
28  typeNamePrefix(typeNamePrefix)
29  {
30  }
31 
32  const std::map<std::string, std::pair<aron::data::VariantPtr, aron::type::VariantPtr>>&
34  {
35  return foundSubObjects;
36  }
37 
38  void
40  {
41  if (elementType && simox::alg::starts_with(elementType->getFullName(), typeNamePrefix))
42  {
43  foundSubObjects.emplace(elementData->getPath().toString(),
44  std::make_pair(elementData, elementType));
45  }
46  }
47 
48  void
50  {
51  // Ignore (the base class throws an exception here)
52  }
53 
56  {
57  return RecursiveConstTypedVariantVisitor::GetObjectElementsWithNullType(elementData,
58  elementType);
59  }
60 } // namespace armarx::aron
armarx::aron::SubObjectFinder::visitUnknown
void visitUnknown(DataInput &elementData, TypeInput &elementType) override
Definition: object_finders.cpp:49
armarx::aron::data::RecursiveTypedVisitor< const data::VariantPtr, const type::VariantPtr >::MapElements
std::map< std::string, std::pair< DataInputNonConst, TypeInputNonConst > > MapElements
Definition: RecursiveVisitor.h:86
armarx::starts_with
bool starts_with(const std::string &haystack, const std::string &needle)
Definition: StringHelpers.cpp:43
armarx::aron::SubObjectFinder::getObjectElements
MapElements getObjectElements(DataInput &elementData, TypeInput &elementType) override
Definition: object_finders.cpp:55
armarx::aron::data::RecursiveTypedVisitor< const data::VariantPtr, const type::VariantPtr >::TypeInput
typename TypedVisitorBase< const data::VariantPtr, const type::VariantPtr >::TypeInput TypeInput
Definition: RecursiveVisitor.h:81
armarx::aron
Definition: DataDisplayVisitor.cpp:5
armarx::aron::SubObjectFinder::getFoundObjects
const std::map< std::string, std::pair< aron::data::VariantPtr, aron::type::VariantPtr > > & getFoundObjects()
Get the objects that have been found.
Definition: object_finders.cpp:33
object_finders.h
armarx::aron::data::RecursiveTypedVisitor< const data::VariantPtr, const type::VariantPtr >::DataInput
typename TypedVisitorBase< const data::VariantPtr, const type::VariantPtr >::DataInput DataInput
Definition: RecursiveVisitor.h:80
armarx::aron::SubObjectFinder::visitObjectOnEnter
void visitObjectOnEnter(DataInput &elementData, TypeInput &elementType) override
Definition: object_finders.cpp:39
armarx::aron::SubObjectFinder::SubObjectFinder
SubObjectFinder(const std::string &typeNamePrefix)
Definition: object_finders.cpp:27