summaryrefslogtreecommitdiff
path: root/cpp/include/qmf/Agent.h
blob: 94083be4f3fde483efca226d075b4e5e09309d5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef QMF_AGENT_H
#define QMF_AGENT_H
/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */

#include <qmf/ImportExport.h>
#include "qmf/Handle.h"
//#include "qmf/Subscription.h"
#include "qmf/exceptions.h"
#include "qpid/messaging/Duration.h"
#include "qpid/types/Variant.h"
#include <string>

namespace qmf {

#ifndef SWIG
    template <class> class PrivateImplRef;
#endif

    class AgentImpl;
    class ConsoleEvent;
    class Query;
    class DataAddr;
    class SchemaId;
    class Schema;

    class QMF_CLASS_EXTERN Agent : public qmf::Handle<AgentImpl> {
    public:
        QMF_EXTERN Agent(AgentImpl* impl = 0);
        QMF_EXTERN Agent(const Agent&);
        QMF_EXTERN Agent& operator=(const Agent&);
        QMF_EXTERN ~Agent();

        QMF_EXTERN std::string getName() const;
        QMF_EXTERN uint32_t getEpoch() const;
        QMF_EXTERN std::string getVendor() const;
        QMF_EXTERN std::string getProduct() const;
        QMF_EXTERN std::string getInstance() const;
        QMF_EXTERN const qpid::types::Variant& getAttribute(const std::string&) const;
        QMF_EXTERN const qpid::types::Variant::Map& getAttributes() const;

        QMF_EXTERN ConsoleEvent query(const Query&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE);
        QMF_EXTERN ConsoleEvent query(const std::string&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE);
        QMF_EXTERN uint32_t queryAsync(const Query&);
        QMF_EXTERN uint32_t queryAsync(const std::string&);

        /**
         * Create a subscription to this agent
         */
        //QMF_EXTERN Subscription subscribe(const Query&, const std::string& options = "");
        //QMF_EXTERN Subscription subscribe(const std::string&, const std::string& options = "");

        QMF_EXTERN ConsoleEvent callMethod(const std::string&, const qpid::types::Variant::Map&, const DataAddr&,
                                           qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE);
        QMF_EXTERN uint32_t callMethodAsync(const std::string&, const qpid::types::Variant::Map&, const DataAddr&);

        /**
         * Query the agent for a list of schema classes that it exposes.  This operation comes in both
         * synchronous (blocking) and asynchronous flavors.
         *
         * This method will typically be used after receiving an AGENT_SCHEMA_UPDATE event from the console session.
         * It may also be used on a newly discovered agent to learn what schemata are exposed.
         *
         * querySchema returns a ConsoleEvent that contains a list of SchemaId objects exposed by the agent.
         * This list is cached locally and can be locally queried using getPackage[Count] and getSchemaId[Count].
         */
        QMF_EXTERN ConsoleEvent querySchema(qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE);
        QMF_EXTERN uint32_t querySchemaAsync();

        /**
         * Get the list of schema packages exposed by the agent.
         *
         *   getPackageCount returns the number of packages exposed.
         *   getPackage returns the name of the package by index (0..package-count)
         *
         * Note that both of these calls are synchronous and non-blocking.  They only return locally cached data
         * and will not send any messages to the remote agent.  Use querySchema[Async] to get the latest schema
         * information from the remote agent.
         */
        QMF_EXTERN uint32_t getPackageCount() const;
        QMF_EXTERN const std::string& getPackage(uint32_t) const;

        /**
         * Get the list of schema identifiers for a particular package.
         *
         *   getSchemaIdCount returns the number of IDs in the indicates package.
         *   getSchemaId returns the SchemaId by index (0..schema-id-count)
         *
         * Note that both of these calls are synchronous and non-blocking.  They only return locally cached data
         * and will not send any messages to the remote agent.  Use querySchema[Async] to get the latest schema
         * information from the remote agent.
         */
        QMF_EXTERN uint32_t getSchemaIdCount(const std::string&) const;
        QMF_EXTERN SchemaId getSchemaId(const std::string&, uint32_t) const;

        /**
         * Get detailed schema information for a specified schema ID.
         *
         * This call will return cached information if it is available.  If not, it will send a query message to the
         * remote agent and block waiting for a response.  The timeout argument specifies the maximum time to wait
         * for a response from the agent.
         */
        QMF_EXTERN Schema getSchema(const SchemaId&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE);


#ifndef SWIG
    private:
        friend class qmf::PrivateImplRef<Agent>;
        friend struct AgentImplAccess;
#endif
    };

}

#endif