SMACC2
Loading...
Searching...
No Matches
smacc_type_info.hpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
20
21#pragma once
22#include <map>
23#include <memory>
24#include <string>
25#include <typeinfo>
26#include <vector>
27
28namespace smacc2
29{
30namespace introspection
31{
33{
34public:
35 typedef std::shared_ptr<TypeInfo> Ptr;
36
37 //---- FACTORY STATIC METHODS -----------
38 static TypeInfo::Ptr getTypeInfoFromString(std::string inputtext);
39 static TypeInfo::Ptr getFromStdTypeInfo(const std::type_info & tid);
40
41 template <typename T>
43 {
44 return TypeInfo::getFromStdTypeInfo(typeid(T));
45 }
46 //---------------------------------------
47
48 std::vector<Ptr> templateParameters;
49
50 TypeInfo(std::string tkey, std::string codedtype, std::string finaltype)
51 {
52 this->tkey = tkey;
53 this->codedtype = codedtype;
54 this->finaltype = finaltype;
55 }
56
57 std::string toString() { return this->tkey + ":" + this->finaltype; }
58
60 {
61 auto index = this->finaltype.find("<");
62 return this->finaltype.substr(0, index);
63 }
64
65 const std::string & getFullName() { return this->finaltype; }
66
67 static std::map<std::string, Ptr> typeInfoDatabase;
68
69private:
70 std::string tkey;
71 std::string codedtype;
72 std::string finaltype;
73};
74} // namespace introspection
75} // namespace smacc2
static TypeInfo::Ptr getTypeInfoFromType()
static TypeInfo::Ptr getTypeInfoFromString(std::string inputtext)
std::shared_ptr< TypeInfo > Ptr
const std::string & getFullName()
static TypeInfo::Ptr getFromStdTypeInfo(const std::type_info &tid)
std::vector< Ptr > templateParameters
static std::map< std::string, Ptr > typeInfoDatabase
TypeInfo(std::string tkey, std::string codedtype, std::string finaltype)