libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
metaobject.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2013 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QI_TYPE_METAOBJECT_HPP_
8 #define _QI_TYPE_METAOBJECT_HPP_
9 
10 #include <qi/type/metamethod.hpp>
11 #include <qi/type/metasignal.hpp>
12 #include <qi/type/metaproperty.hpp>
13 
14 #ifdef _MSC_VER
15 # pragma warning( push )
16 # pragma warning( disable: 4251 )
17 #endif
18 
19 namespace qi {
20 
21  class MetaObjectPrivate;
22  class GenericFunctionParameters;
23 
26  public:
27  MetaObject();
28  MetaObject(const MetaObject &other);
29  MetaObject& operator=(const MetaObject &other);
30  ~MetaObject();
31 
36  int methodId(const std::string &nameWithSignature) const;
41  int signalId(const std::string &name) const;
46  int propertyId(const std::string& name) const;
47 
48  using MethodMap = std::map<unsigned int, MetaMethod>;
52  MethodMap methodMap() const;
53 
54  //not called signals because it conflict with Qt keywords :S
55  using SignalMap = std::map<unsigned int, MetaSignal>;
59  SignalMap signalMap() const;
60 
61  using PropertyMap = std::map<unsigned int, MetaProperty>;
65  PropertyMap propertyMap() const;
66 
71  MetaMethod* method(unsigned int id);
72  const MetaMethod* method(unsigned int id) const;
73 
78  MetaSignal* signal(unsigned int id);
79  const MetaSignal* signal(unsigned int id) const;
84  const MetaSignal* signal(const std::string &name) const;
85 
90  MetaProperty* property(unsigned int id);
91  const MetaProperty* property(unsigned int id) const;
92 
106  int findMethod(const std::string& nameWithOptionalSignature, const GenericFunctionParameters& args, bool* canCache=0) const;
111  std::vector<MetaMethod> findMethod(const std::string &name) const;
112  using CompatibleMethod = std::pair<MetaMethod, float>;
119  std::vector<CompatibleMethod> findCompatibleMethod(const std::string &nameOrSignature) const;
120 
127  static bool isPrivateMember(const std::string &name, unsigned int uid);
128 
134  static qi::MetaObject merge(const qi::MetaObject &source, const qi::MetaObject &dest);
135 
139  std::string description() const;
140 
141  MetaObjectPrivate *_p;
142  MetaObject(const MethodMap& methodMap, const SignalMap& signalMap,
143  const PropertyMap& propertyMap, const std::string& description);
144  };
145 
146  bool QI_API operator < (const MetaObject& a, const MetaObject& b);
147 
148 
151  {
152  MemberAddInfo(unsigned int newId, bool newMember)
153  : id(newId), isNewMember(newMember)
154  {}
155 
156  unsigned int id;
157  bool isNewMember;
158  };
159 
160  class MetaObjectBuilderPrivate;
162  public:
164 
165  void setDescription(const std::string& desc);
166 
167  MemberAddInfo addMethod(const qi::Signature &sigret,
168  const std::string &name,
169  const qi::Signature &signature,
170  int id = -1);
171 
173  MemberAddInfo addMethod(MetaMethodBuilder& builder, int id = -1);
174 
176  MemberAddInfo addSignal(const std::string &name, const qi::Signature& sig, int id = -1);
177 
179  MemberAddInfo addProperty(const std::string& name, const qi::Signature& sig, int id = -1);
180  qi::MetaObject metaObject();
181 
182  private:
183  // C4251
184  boost::shared_ptr<MetaObjectBuilderPrivate> _p;
185  };
186 
187  namespace detail {
188  QI_API void printMetaObject(std::ostream &stream, const qi::MetaObject &metaObject, bool color=true, bool showHidden=false, bool showDoc=false, bool raw=false, bool parseable=false);
189  }
190 
191 }
192 
193 
194 #ifdef _MSC_VER
195 # pragma warning( pop )
196 #endif
197 
198 #endif // _QITYPE_METAOBJECT_HPP_
#define QI_API
Definition: api.hpp:33
std::map< unsigned int, MetaSignal > SignalMap
Definition: metaobject.hpp:55
Representation of a method in an GenericObject.
Definition: metamethod.hpp:42
MetaObjectPrivate * _p
Definition: metaobject.hpp:141
Representation of a Signal in an GenericObject.
Definition: metasignal.hpp:20
void printMetaObject(std::ostream &stream, const qi::MetaObject &metaObject, bool color=true, bool showHidden=false, bool showDoc=false, bool raw=false, bool parseable=false)
bool isNewMember
True iff the member has been created through the operation.
Definition: metaobject.hpp:157
unsigned int id
Id of the member that has been created or that already existed.
Definition: metaobject.hpp:156
std::map< unsigned int, MetaMethod > MethodMap
Definition: metaobject.hpp:48
std::map< unsigned int, MetaProperty > PropertyMap
Definition: metaobject.hpp:61
std::pair< MetaMethod, float > CompatibleMethod
Definition: metaobject.hpp:112
MemberAddInfo(unsigned int newId, bool newMember)
Definition: metaobject.hpp:152
LogColor color()
Get log color.
bool operator<(const AnyReference &a, const AnyReference &b)
Description of the signals and methods accessible on an ObjectTypeInterface.
Definition: metaobject.hpp:25