comparison OrthancServer/main.cpp @ 893:f57802f8b4dc plugins

plugins for windows
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Jun 2014 16:14:56 +0200
parents 84513f2ee1f3
children bafc9d592632
comparison
equal deleted inserted replaced
892:517e28b420af 893:f57802f8b4dc
46 #include "OrthancInitialization.h" 46 #include "OrthancInitialization.h"
47 #include "ServerContext.h" 47 #include "ServerContext.h"
48 #include "OrthancFindRequestHandler.h" 48 #include "OrthancFindRequestHandler.h"
49 #include "OrthancMoveRequestHandler.h" 49 #include "OrthancMoveRequestHandler.h"
50 #include "ServerToolbox.h" 50 #include "ServerToolbox.h"
51 #include "../Plugins/Engine/PluginsManager.h"
51 52
52 using namespace Orthanc; 53 using namespace Orthanc;
53 54
54 55
55 56
202 return true; 203 return true;
203 } 204 }
204 }; 205 };
205 206
206 207
207 void PrintHelp(char* path) 208 static void PrintHelp(char* path)
208 { 209 {
209 std::cout 210 std::cout
210 << "Usage: " << path << " [OPTION]... [CONFIGURATION]" << std::endl 211 << "Usage: " << path << " [OPTION]... [CONFIGURATION]" << std::endl
211 << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research." << std::endl 212 << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research." << std::endl
212 << std::endl 213 << std::endl
229 << " -1 if error (have a look at the logs)." << std::endl 230 << " -1 if error (have a look at the logs)." << std::endl
230 << std::endl; 231 << std::endl;
231 } 232 }
232 233
233 234
234 void PrintVersion(char* path) 235 static void PrintVersion(char* path)
235 { 236 {
236 std::cout 237 std::cout
237 << path << " " << ORTHANC_VERSION << std::endl 238 << path << " " << ORTHANC_VERSION << std::endl
238 << "Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege (Belgium) " << std::endl 239 << "Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege (Belgium) " << std::endl
239 << "Licensing GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>, with OpenSSL exception." << std::endl 240 << "Licensing GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>, with OpenSSL exception." << std::endl
242 << std::endl 243 << std::endl
243 << "Written by Sebastien Jodogne <s.jodogne@gmail.com>" << std::endl; 244 << "Written by Sebastien Jodogne <s.jodogne@gmail.com>" << std::endl;
244 } 245 }
245 246
246 247
248
249 static void LoadLuaScripts(ServerContext& context)
250 {
251 std::list<std::string> luaScripts;
252 Configuration::GetGlobalListOfStringsParameter(luaScripts, "LuaScripts");
253 for (std::list<std::string>::const_iterator
254 it = luaScripts.begin(); it != luaScripts.end(); ++it)
255 {
256 std::string path = Configuration::InterpretStringParameterAsPath(*it);
257 LOG(WARNING) << "Installing the Lua scripts from: " << path;
258 std::string script;
259 Toolbox::ReadFile(script, path);
260 context.GetLuaContext().Execute(script);
261 }
262 }
263
264
265 static void LoadPlugins(PluginsManager& pluginsManager)
266 {
267 std::list<std::string> plugins;
268 Configuration::GetGlobalListOfStringsParameter(plugins, "Plugins");
269 for (std::list<std::string>::const_iterator
270 it = plugins.begin(); it != plugins.end(); ++it)
271 {
272 std::string path = Configuration::InterpretStringParameterAsPath(*it);
273 LOG(WARNING) << "Registering a plugin from: " << path;
274 pluginsManager.RegisterPlugin(path);
275 }
276 }
277
278
279
280
247 int main(int argc, char* argv[]) 281 int main(int argc, char* argv[])
248 { 282 {
249 // Initialize Google's logging library. 283 // Initialize Google's logging library.
250 FLAGS_logtostderr = true; 284 FLAGS_logtostderr = true;
251 FLAGS_minloglevel = 1; 285 FLAGS_minloglevel = 1;
335 LOG(WARNING) << "Index directory: " << indexDirectory; 369 LOG(WARNING) << "Index directory: " << indexDirectory;
336 370
337 context.SetCompressionEnabled(Configuration::GetGlobalBoolParameter("StorageCompression", false)); 371 context.SetCompressionEnabled(Configuration::GetGlobalBoolParameter("StorageCompression", false));
338 context.SetStoreMD5ForAttachments(Configuration::GetGlobalBoolParameter("StoreMD5ForAttachments", true)); 372 context.SetStoreMD5ForAttachments(Configuration::GetGlobalBoolParameter("StoreMD5ForAttachments", true));
339 373
340 std::list<std::string> luaScripts; 374 LoadLuaScripts(context);
341 Configuration::GetGlobalListOfStringsParameter(luaScripts, "LuaScripts"); 375
342 for (std::list<std::string>::const_iterator 376 PluginsManager pluginsManager;
343 it = luaScripts.begin(); it != luaScripts.end(); ++it) 377 LoadPlugins(pluginsManager);
344 {
345 std::string path = Configuration::InterpretStringParameterAsPath(*it);
346 LOG(WARNING) << "Installing the Lua scripts from: " << path;
347 std::string script;
348 Toolbox::ReadFile(script, path);
349 context.GetLuaContext().Execute(script);
350 }
351
352 378
353 try 379 try
354 { 380 {
355 context.GetIndex().SetMaximumPatientCount(Configuration::GetGlobalIntegerParameter("MaximumPatientCount", 0)); 381 context.GetIndex().SetMaximumPatientCount(Configuration::GetGlobalIntegerParameter("MaximumPatientCount", 0));
356 } 382 }