Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / deployment_configuration.h
blob360c9f872a1b636645b20780b346b43b17047889
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2012 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef DEPLOYMENT_CONFIGURATION_H
20 #define DEPLOYMENT_CONFIGURATION_H
22 //-----------------------------------------------------------------------------
23 // include
24 //-----------------------------------------------------------------------------
26 // nel
27 #include "nel/misc/types_nl.h"
28 #include "nel/misc/common.h"
29 #include "nel/misc/sstring.h"
32 //-----------------------------------------------------------------------------
33 // namespace DEPCFG
34 //-----------------------------------------------------------------------------
36 namespace DEPCFG
38 //-----------------------------------------------------------------------------
39 // some handy constants
40 //-----------------------------------------------------------------------------
42 #define defaultDeploymentConfigurationFileName "server_park_database.txt"
45 //-----------------------------------------------------------------------------
46 // some handy typedefs for identifiers, map keys, etc
47 //-----------------------------------------------------------------------------
49 typedef NLMISC::CSString TDomainName;
50 typedef NLMISC::CSString TShardName;
51 typedef NLMISC::CSString THostName;
52 typedef NLMISC::CSString TAppName;
54 typedef NLMISC::CVectorSString TDomainNames;
55 typedef NLMISC::CVectorSString TShardNames;
56 typedef NLMISC::CVectorSString THostNames;
57 typedef NLMISC::CVectorSString TAppNames;
59 typedef NLMISC::CSString TCmdLine;
60 typedef NLMISC::CSString TCfgFile;
61 typedef NLMISC::CVectorSString TDataPacks;
64 //-----------------------------------------------------------------------------
65 // struct SDomainDescription
66 //-----------------------------------------------------------------------------
68 struct SDomainDescription
70 //-------------------------------------------------------------------------
71 // identifying the domain
72 TDomainName DomainName;
73 //-------------------------------------------------------------------------
74 // the set of shards and apps belonging to this domain and their hosts
75 TShardNames Shards;
76 THostNames Hosts;
77 TAppNames Apps;
79 //-------------------------------------------------------------------------
80 // a handy 'clear()' method
81 void clear()
83 DomainName.clear();
84 Shards.clear();
85 Hosts.clear();
86 Apps.clear();
91 //-----------------------------------------------------------------------------
92 // struct SShardDescription
93 //-----------------------------------------------------------------------------
95 struct SShardDescription
97 //-------------------------------------------------------------------------
98 // identifying the shard by name and domain
99 TDomainName DomainName;
100 TShardName ShardName;
101 //-------------------------------------------------------------------------
102 // the set of hosts and apps used by this shard
103 THostNames Hosts;
104 TAppNames Apps;
106 //-------------------------------------------------------------------------
107 // a handy 'clear()' method
108 void clear()
110 DomainName.clear();
111 ShardName.clear();
112 Hosts.clear();
113 Apps.clear();
118 //-----------------------------------------------------------------------------
119 // struct SHostDescription
120 //-----------------------------------------------------------------------------
122 struct SHostDescription
124 //-------------------------------------------------------------------------
125 // identifying the host (machine's network name)
126 THostName HostName;
127 //-------------------------------------------------------------------------
128 // the set of domains that refference this host
129 TDomainNames Domains;
131 //-------------------------------------------------------------------------
132 // a handy 'clear()' method
133 void clear()
135 HostName.clear();
136 Domains.clear();
141 //-----------------------------------------------------------------------------
142 // struct SAppDescription
143 //-----------------------------------------------------------------------------
145 struct SAppDescription
147 //-------------------------------------------------------------------------
148 // identifying the app, the shard it belongs to, machine it runs on, etc
149 TDomainName DomainName;
150 TShardName ShardName;
151 THostName HostName;
152 TAppName AppName;
153 NLMISC::CSString StartOrder;
155 //-------------------------------------------------------------------------
156 // some real data
157 TCmdLine CmdLine; // the command line to execute the app
158 TCfgFile CfgFile; // the cfg file contents for the app
159 TDataPacks DataPacks; // the set of data packs for the app
161 //-------------------------------------------------------------------------
162 // a handy 'clear()' method
163 void clear()
165 DomainName.clear();
166 ShardName.clear();
167 HostName.clear();
168 AppName.clear();
169 StartOrder.clear();
170 CmdLine.clear();
171 CfgFile.clear();
172 DataPacks.clear();
177 //-----------------------------------------------------------------------------
178 // class CDeploymentConfiguration
179 //-----------------------------------------------------------------------------
181 class CDeploymentConfiguration
183 public :
184 //-------------------------------------------------------------------------
185 // this is a singleton so we have a getInstance() method
186 // remaining methods are pure virtuals...
188 // get hold of the instance of the singleton that derives from CDeploymentConfiguration
189 static CDeploymentConfiguration& getInstance();
192 //-------------------------------------------------------------------------
193 // methods for reading / serialising deployment configuration
195 // read the deployment configuration from a specified file
197 // file format is line base with the following format:
198 // '//'... comment to end of line
199 // 'define' <block_name> // define a new block
200 // 'domain' <domain_name> // flag this block as a domain and give it a name
201 // 'shard' <domain_name> // flag this block as a shard and give it a name
202 // 'use' <block_name> // add a child block to this block
203 // 'name' <block_name> // set the unique name to use for the executables derived from this block
204 // 'cmdLine' <cmd_line> // setup the command line to use for exes derived from this block
205 // 'host' <host_name> // assign the exes derived from this block to a given host
206 // 'cfg' <cfg_line> // add a line to be included in the cfg file of executables derived from this block
207 // 'cfgAfter' <cfg_line> // as above but cfg lines appended at end of cfg file (not at start)
208 // 'data' <data_name> // add dependency on a given data block to exes derived from this block
210 virtual bool read(const NLMISC::CSString& fileName) =0;
212 // write the info blocks out to a file (in no particular order)
213 // the output file can be re-read via the 'read()' method
214 virtual void write(const NLMISC::CSString& fileName) =0;
216 // serialise the deployment configuration, for dispatch to / reception from other apps
217 virtual void serial(NLMISC::IStream& stream) =0;
220 //-------------------------------------------------------------------------
221 // read accessors - getting sets of names
223 // get the complete set of hosts (machines on which we have apps running)
224 virtual void getHostNames(THostNames& result) const =0;
226 // get the complete set of domains
227 virtual void getDomainNames(TDomainNames& result) const =0;
229 // get the shards for a given domain
230 virtual void getShardNames(const TDomainName& domainName,TShardNames& result) const =0;
232 // get the apps for a given host and domain
233 virtual void getAppNames(const THostName& hostName,const TDomainName& domainName,TAppNames& result) const =0;
235 // get the apps for a given host, domain and shard
236 virtual void getAppNames(const THostName& hostName,const TDomainName& domainName,const TShardName& shardName,TAppNames& result) const =0;
239 //-------------------------------------------------------------------------
240 // read accessors - getting info structure for a named object
242 // get a named host
243 virtual void getHost(const THostName& hostName,SHostDescription& result) const =0;
245 // get a named domains
246 virtual void getDomain(const TDomainName& domainName, SDomainDescription& result) const =0;
248 // get a named shard for a given domain
249 virtual void getShard(const TDomainName& domainName,const TShardName& shardName,SShardDescription& result) const =0;
251 // get a named app for a given domain
252 virtual void getApp(const TDomainName& domainName,const TAppName& appName,SAppDescription& result) const =0;
255 //-------------------------------------------------------------------------
256 // methods for dumping info to a given log
258 // dump raw information (organised by info block, not by domain or host)
259 virtual void dumpInfoBlocks(NLMISC::CLog& log) const =0;
261 // dump info organised by domain
262 virtual void dumpDomains(NLMISC::CLog& log) const =0;
265 } // end of namespace
267 //-----------------------------------------------------------------------------
268 #endif