TinyURDF 1.0.0
Loading...
Searching...
No Matches
parser_base.h
Go to the documentation of this file.
1#ifndef INCLUDE_TINYURDF_COMMON_PARSER_BASE_H_
2#define INCLUDE_TINYURDF_COMMON_PARSER_BASE_H_
3
4// Copyright 2025 wissem CHIHA
5
6#include <tinyxml2/tinyxml2.h>
7
8#include <loguru/loguru.hpp>
9#include <memory>
10
11#include "common/object_base.h"
12
13template <class T>
14class ParserBase : public ObjectBase
15{
16 public:
17 const char* getNameOf(const tinyxml2::XMLElement* xml)
18 {
19 const char* name = xml->Attribute("name");
20 if (!name)
21 {
22 return "";
23 }
24 else
25 {
26 return name;
27 }
28 }
29 virtual void parse(const tinyxml2::XMLElement* xml)
30 {
31 if (!xml)
32 {
33 LOG_F(ERROR, "Parser::parse() passed nullptr");
34 return;
35 }
36 }
37 virtual std::shared_ptr<T> get() { return Tptr; }
38
39 protected:
41 virtual ~ParserBase() {}
42 std::shared_ptr<T> Tptr;
43};
44#endif // INCLUDE_TINYURDF_COMMON_PARSER_BASE_H_
Definition object_base.h:9
Definition parser_base.h:15
const char * getNameOf(const tinyxml2::XMLElement *xml)
Definition parser_base.h:17
virtual std::shared_ptr< T > get()
Definition parser_base.h:37
ParserBase()
Definition parser_base.h:40
std::shared_ptr< T > Tptr
Definition parser_base.h:42
virtual ~ParserBase()
Definition parser_base.h:41
virtual void parse(const tinyxml2::XMLElement *xml)
Definition parser_base.h:29