Warning, file /sdk/dferry/client/introspection.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef INTROSPECTION_H
0002 #define INTROSPECTION_H
0003 
0004 #include "message.h"
0005 
0006 #include <map>
0007 #include <string>
0008 #include <vector>
0009 
0010 struct DFERRYCLIENT_EXPORT Argument
0011 {
0012     std::string name;
0013     std::string type;
0014     bool isDirectionOut; // in otherwise
0015 };
0016 
0017 struct DFERRYCLIENT_EXPORT Method
0018 {
0019     Message::Type type; // allowed: MethodCallMessage, SignalMessage
0020     std::string name;
0021     std::vector<Argument> arguments;
0022 };
0023 
0024 struct DFERRYCLIENT_EXPORT Property
0025 {
0026     enum Access {
0027         Invalid = 0,
0028         Read = 1,
0029         Write = 2,
0030         ReadWrite = Read | Write
0031     };
0032     std::string name;
0033     std::string type;
0034     Access access;
0035 };
0036 
0037 struct DFERRYCLIENT_EXPORT Interface
0038 {
0039     std::string name;
0040     std::map<std::string, Method> methods;
0041     std::map<std::string, Property> properties;
0042 };
0043 
0044 struct DFERRYCLIENT_EXPORT IntrospectionNode
0045 {
0046     // IntrospectionNode *parent() const;
0047     std::string path() const; // returns all parents' names plus this node's like "/grand/parent/this"
0048 
0049     IntrospectionNode *parent; // null for toplevel
0050     std::string name;
0051     std::map<std::string, IntrospectionNode *> children; // nodes by name
0052     std::map<std::string, Interface> interfaces;
0053 };
0054 
0055 namespace tinyxml2 { class XMLElement; }
0056 namespace tx2 = tinyxml2;
0057 
0058 class DFERRYCLIENT_EXPORT IntrospectionTree
0059 {
0060 public:
0061     IntrospectionTree();
0062     ~IntrospectionTree();
0063 
0064     bool mergeXml(const char *documentText, const char *path);
0065     // do we need this? void removePath(std::string path); / removeNode(IntrospectionNode *);
0066     IntrospectionNode *rootNode() const;
0067 private:
0068     IntrospectionNode *findOrCreateParent(const char *path, std::string *leafName = nullptr);
0069     void pruneBranch(IntrospectionNode *node);
0070     void removeNode(IntrospectionNode *node);
0071     void deleteChildren(IntrospectionNode *node);
0072 
0073     bool addNode(IntrospectionNode *parent, const tx2::XMLElement *el);
0074     bool addInterface(IntrospectionNode *node, const tx2::XMLElement *el);
0075     bool addMethod(Interface *iface, const tx2::XMLElement *el, Message::Type messageType);
0076     bool addArgument(Method *method, const tx2::XMLElement *el, Message::Type messageType);
0077     bool addProperty(Interface *iface, const tx2::XMLElement *el);
0078 
0079 public:
0080 
0081     IntrospectionNode *m_rootNode;
0082 };
0083 
0084 #endif // INTROSPECTION_H