libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
type.hpp
Go to the documentation of this file.
1 /*
2 ** Author(s):
3 ** - Cedric GESTES <gestes@aldebaran-robotics.com>
4 **
5 ** Copyright (C) 2014 Aldebaran Robotics
6 */
7 
8 #ifndef _QITYPE_TYPE_HPP_
9 # define _QITYPE_TYPE_HPP_
10 
11 
12 #include <string>
13 #include <vector>
15 
16 
17 // THIS INTERFACE IS NOT STABLE. (that's why it belongs to details)
18 // DO NOT USE.
19 
20 namespace qi {
21 
22  namespace detail {
23 
24  class AnyType;
25 
26  struct FieldInfo {
27  //Type2 type;
28  std::string name;
30  std::string description;
31  };
32  using FieldInfoVector = std::vector<FieldInfo>;
33 
35 
36  class AnyType;
37  using AnyTypeVector = std::vector<AnyType>;
38 
40  QI_API AnyType makeTypeList(const AnyType& element);
41  QI_API AnyType makeTypeMap(const AnyType& key, const AnyType& element);
42  QI_API AnyType makeTypeTuple(const AnyTypeVector& elements);
43 
44  class QI_API AnyType {
45  public:
46  AnyType();
47  AnyType(TypeInterface *typeInterface);
48 
49 
50  AnyType(const AnyType& rhs);
51  AnyType &operator=(const AnyType& rhs);
52 
53  //## General
54 
55  TypeKind kind() const;
56  TypeSignature signature() const; //really?
57  TypeInterface* type() const { return _type; }
58 
59  //convert to a human readable format
60  //Vector<Point>, Map<Int, Function>
61  std::string toString();
62 
63  //unique type identifier
64  std::string name() const;
65 
66  //## Type Specific
67 
68  //Struct/Object
69  std::string className() const;
70 
71  AnyTypeVector elements();
72 
73  //Struct/Object
74  FieldInfoVector members();
75 
76  //Object
77  FieldInfoVector methods();
78  FieldInfo method(const uint32_t id);
79  FieldInfoVector methodOverloads(const std::string& name);
80 
81  FieldInfoVector sigs(); //qt reserve signals
82  FieldInfo signal(const uint32_t id);
83  FieldInfo signal(const std::string& id);
84 
85  FieldInfoVector properties();
86  FieldInfo property(const uint32_t id);
87  FieldInfo property(const std::string& name);
88 
89  //Method/Signal
90  FieldInfoVector paramsIn();
91  //Method
92  FieldInfoVector paramsOut();
93 
94  //Map
95  AnyType key();
96 
97  //List/Map/Pointer/Property (not dynamic)
98  AnyType element();
99 
100  //Float/Int
101  int bits();
102  //Int
103  int isSigned();
104 
105  //## Operations
106  bool isConvertible(AnyType type);
107  //compare kind?
108  //bool isCompatible(Type2 type);
109  bool isConstructible(AnyType type);
110 
111  //hummm what?
112  bool operator==(const AnyType& rhs) { return rhs.type() == _type; }
113 
114  private:
115  TypeInterface *_type;
116  };
117 
118  }
119 }
120 
121 #endif /* !TYPE2_PP_ */
#define QI_API
Definition: api.hpp:33
uint32_t uint32_t
Definition: types.hpp:65
std::string description
Definition: type.hpp:30
AnyType makeTypeMap(const AnyType &key, const AnyType &element)
std::vector< AnyType > AnyTypeVector
Definition: type.hpp:37
bool operator==(const AnyType &rhs)
Definition: type.hpp:112
AnyType makeTypeOf(TypeKind kind)
qi::uint64_t index
Definition: type.hpp:29
TypeInterface * type() const
Definition: type.hpp:57
AnyType makeTypeTuple(const AnyTypeVector &elements)
TypeKind
Definition: fwd.hpp:54
std::string name
Definition: type.hpp:28
AnyType makeTypeList(const AnyType &element)
uint64_t uint64_t
Definition: types.hpp:66
std::vector< FieldInfo > FieldInfoVector
Definition: type.hpp:32