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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
// **********************************************************************
//
// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifndef ICE_GRID_DESCRIPTOR_HELPER_H
#define ICE_GRID_DESCRIPTOR_HELPER_H
#include <IceGrid/Admin.h>
#include <IceXML/Parser.h>
namespace IceGrid
{
class DescriptorVariables : public IceUtil::SimpleShared
{
public:
DescriptorVariables();
DescriptorVariables(const std::map<std::string, std::string>&);
std::string substitute(const std::string&);
std::string substituteWithMissing(const std::string&, std::set<std::string>&);
std::string getVariable(const std::string&);
void addVariable(const std::string&, const std::string&);
bool hasVariable(const std::string&) const;
void remove(const std::string&);
void dumpVariables() const;
void reset(const std::map<std::string, std::string>&, const std::vector<std::string>&);
void push(const std::map<std::string, std::string>&);
void push();
void pop();
std::map<std::string, std::string> getCurrentScopeVariables() const;
std::vector<std::string> getCurrentScopeParameters() const;
void addParameter(const std::string&);
std::vector<std::string> getDeploymentTargets(const std::string&) const;
void substitution(bool);
bool substitution() const;
private:
std::string substituteImpl(const std::string&, std::set<std::string>&);
struct VariableScope
{
std::map<std::string, std::string> variables;
std::set<std::string> used;
std::set<std::string> parameters;
bool substitution;
};
std::vector<VariableScope> _scopes;
std::vector<std::string> _deploymentTargets;
};
typedef IceUtil::Handle<DescriptorVariables> DescriptorVariablesPtr;
class DescriptorHelper;
class ServerDescriptorHelper;
class ServiceDescriptorHelper;
class DescriptorTemplates : public IceUtil::SimpleShared
{
public:
DescriptorTemplates(const ApplicationDescriptorPtr&);
ServerDescriptorPtr instantiateServer(const DescriptorHelper&, const std::string&,
const std::map<std::string, std::string>&);
ServiceDescriptorPtr instantiateService(const DescriptorHelper&, const std::string&,
const std::map<std::string, std::string>&);
void addServerTemplate(const std::string&, const ServerDescriptorPtr&, const Ice::StringSeq&);
void addServiceTemplate(const std::string&, const ServiceDescriptorPtr&, const Ice::StringSeq&);
ApplicationDescriptorPtr getApplicationDescriptor() const;
private:
const ApplicationDescriptorPtr _application;
};
typedef IceUtil::Handle<DescriptorTemplates> DescriptorTemplatesPtr;
class XmlAttributesHelper
{
public:
XmlAttributesHelper(const DescriptorVariablesPtr&, const IceXML::Attributes&);
bool contains(const std::string&);
std::string operator()(const std::string&);
std::string operator()(const std::string&, const std::string&);
private:
const DescriptorVariablesPtr& _variables;
const IceXML::Attributes& _attributes;
};
class DescriptorHelper
{
public:
const DescriptorVariablesPtr& getVariables() const;
protected:
DescriptorHelper(const Ice::CommunicatorPtr&, const DescriptorVariablesPtr&, const DescriptorTemplatesPtr&);
DescriptorHelper(const DescriptorHelper&);
virtual ~DescriptorHelper();
const Ice::CommunicatorPtr _communicator;
const DescriptorVariablesPtr _variables;
const DescriptorTemplatesPtr _templates;
};
class ServerDescriptorHelper;
class ServiceDescriptorHelper;
class ApplicationDescriptorHelper : public DescriptorHelper
{
public:
ApplicationDescriptorHelper(const Ice::CommunicatorPtr&, const ApplicationDescriptorPtr&);
ApplicationDescriptorHelper(const Ice::CommunicatorPtr&, const DescriptorVariablesPtr&, const IceXML::Attributes&);
void endParsing();
const ApplicationDescriptorPtr& getDescriptor() const;
void setComment(const std::string&);
void addNode(const IceXML::Attributes&);
void endNodeParsing();
void addServer(const std::string&, const IceXML::Attributes&);
void addServer(const ServerDescriptorPtr&);
std::auto_ptr<ServerDescriptorHelper> addServerTemplate(const std::string&, const IceXML::Attributes&);
std::auto_ptr<ServiceDescriptorHelper> addServiceTemplate(const std::string&, const IceXML::Attributes&);
private:
ApplicationDescriptorPtr _descriptor;
};
class ComponentDescriptorHelper : public DescriptorHelper
{
public:
ComponentDescriptorHelper(const DescriptorHelper&);
ComponentDescriptorHelper(const Ice::CommunicatorPtr&, const DescriptorVariablesPtr&,
const DescriptorTemplatesPtr&);
bool operator==(const ComponentDescriptorHelper&) const;
bool operator!=(const ComponentDescriptorHelper&) const;
void setComment(const std::string&);
void addProperty(const IceXML::Attributes&);
void addAdapter(const IceXML::Attributes&);
void addObject(const IceXML::Attributes&);
void addDbEnv(const IceXML::Attributes&);
void addDbEnvProperty(const IceXML::Attributes&);
protected:
void init(const ComponentDescriptorPtr&, const IceXML::Attributes& = IceXML::Attributes());
virtual void instantiateImpl(const ComponentDescriptorPtr&, std::set<std::string>&) const;
private:
ComponentDescriptorPtr _descriptor;
};
class ServerDescriptorHelper : public ComponentDescriptorHelper
{
public:
ServerDescriptorHelper(const DescriptorHelper&, const ServerDescriptorPtr&);
ServerDescriptorHelper(const DescriptorHelper&, const IceXML::Attributes&, const std::string&);
~ServerDescriptorHelper();
void endParsing();
bool operator==(const ServerDescriptorHelper&) const;
bool operator!=(const ServerDescriptorHelper&) const;
virtual ServerDescriptorPtr instantiate(std::set<std::string>&) const;
const ServerDescriptorPtr& getDescriptor() const;
const std::string& getTemplateId() const;
void addService(const std::string&, const IceXML::Attributes&);
void addService(const ServiceDescriptorPtr&);
std::auto_ptr<ServiceDescriptorHelper> addServiceTemplate(const std::string&, const IceXML::Attributes&);
void addOption(const std::string&);
void addEnv(const std::string&);
void addInterpreterOption(const std::string&);
private:
virtual void instantiateImpl(const ServerDescriptorPtr&, std::set<std::string>&) const;
ServerDescriptorPtr _descriptor;
std::string _templateId;
};
class ServiceDescriptorHelper : public ComponentDescriptorHelper
{
public:
ServiceDescriptorHelper(const DescriptorHelper&, const ServiceDescriptorPtr&);
ServiceDescriptorHelper(const DescriptorHelper&, const IceXML::Attributes&, const std::string&);
~ServiceDescriptorHelper();
void endParsing();
bool operator==(const ServiceDescriptorHelper&) const;
bool operator!=(const ServiceDescriptorHelper&) const;
virtual ServiceDescriptorPtr instantiate(std::set<std::string>&) const;
const ServiceDescriptorPtr& getDescriptor() const;
const std::string& getTemplateId() const;
private:
virtual void instantiateImpl(const ServiceDescriptorPtr&, std::set<std::string>&) const;
ServiceDescriptorPtr _descriptor;
std::string _templateId;
};
}
#endif
|