Mercurial > hg > orthanc
comparison OrthancServer/OrthancFindRequestHandler.cpp @ 2617:912a767911b0 jobs
back to a single Lua context
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 22 May 2018 12:45:34 +0200 |
parents | 2f3007bf0708 |
children | d4fd4614f275 |
comparison
equal
deleted
inserted
replaced
2616:2f3007bf0708 | 2617:912a767911b0 |
---|---|
45 #include <boost/regex.hpp> | 45 #include <boost/regex.hpp> |
46 | 46 |
47 | 47 |
48 namespace Orthanc | 48 namespace Orthanc |
49 { | 49 { |
50 static LuaScripting& GetLuaScripting(ServerContext& context) | |
51 { | |
52 // Returns a singleton Lua context | |
53 static boost::mutex mutex_; | |
54 static std::auto_ptr<LuaScripting> lua_; | |
55 | |
56 boost::mutex::scoped_lock lock(mutex_); | |
57 | |
58 if (lua_.get() == NULL) | |
59 { | |
60 LOG(INFO) << "Initializing Lua for OrthancFindRequestHandler"; | |
61 lua_.reset(new LuaScripting(context)); | |
62 lua_->LoadGlobalConfiguration(); | |
63 } | |
64 | |
65 return *lua_; | |
66 } | |
67 | |
68 | |
69 static void GetChildren(std::list<std::string>& target, | 50 static void GetChildren(std::list<std::string>& target, |
70 ServerIndex& index, | 51 ServerIndex& index, |
71 const std::list<std::string>& source) | 52 const std::list<std::string>& source) |
72 { | 53 { |
73 target.clear(); | 54 target.clear(); |
503 const std::string& remoteAet, | 484 const std::string& remoteAet, |
504 const std::string& calledAet) | 485 const std::string& calledAet) |
505 { | 486 { |
506 static const char* LUA_CALLBACK = "IncomingFindRequestFilter"; | 487 static const char* LUA_CALLBACK = "IncomingFindRequestFilter"; |
507 | 488 |
508 LuaScripting::Lock lock(GetLuaScripting(context_)); | 489 LuaScripting::Lock lock(context_.GetLuaScripting()); |
490 | |
509 if (!lock.GetLua().IsExistingFunction(LUA_CALLBACK)) | 491 if (!lock.GetLua().IsExistingFunction(LUA_CALLBACK)) |
510 { | 492 { |
511 return false; | 493 return false; |
512 } | 494 } |
513 else | 495 else |