Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 1232:f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Dec 2014 17:04:40 +0100 |
parents | a843ee8bb903 |
children | 40725595aaf0 |
comparison
equal
deleted
inserted
replaced
1231:703fcd797186 | 1232:f1c01451a8ee |
---|---|
170 | 170 |
171 | 171 |
172 | 172 |
173 struct OrthancPlugins::PImpl | 173 struct OrthancPlugins::PImpl |
174 { | 174 { |
175 typedef std::pair<std::string, _OrthancPluginProperty> Property; | |
176 | |
175 typedef std::pair<boost::regex*, OrthancPluginRestCallback> RestCallback; | 177 typedef std::pair<boost::regex*, OrthancPluginRestCallback> RestCallback; |
176 typedef std::list<RestCallback> RestCallbacks; | 178 typedef std::list<RestCallback> RestCallbacks; |
177 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks; | 179 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks; |
178 typedef std::list<OrthancPluginOnChangeCallback> OnChangeCallbacks; | 180 typedef std::list<OrthancPluginOnChangeCallback> OnChangeCallbacks; |
181 typedef std::map<Property, std::string> Properties; | |
179 | 182 |
180 ServerContext& context_; | 183 ServerContext& context_; |
181 RestCallbacks restCallbacks_; | 184 RestCallbacks restCallbacks_; |
182 OrthancRestApi* restApi_; | 185 OrthancRestApi* restApi_; |
183 OnStoredCallbacks onStoredCallbacks_; | 186 OnStoredCallbacks onStoredCallbacks_; |
186 _OrthancPluginRegisterStorageArea storageArea_; | 189 _OrthancPluginRegisterStorageArea storageArea_; |
187 boost::mutex callbackMutex_; | 190 boost::mutex callbackMutex_; |
188 SharedMessageQueue pendingChanges_; | 191 SharedMessageQueue pendingChanges_; |
189 boost::thread changeThread_; | 192 boost::thread changeThread_; |
190 bool done_; | 193 bool done_; |
194 Properties properties_; | |
191 | 195 |
192 PImpl(ServerContext& context) : | 196 PImpl(ServerContext& context) : |
193 context_(context), | 197 context_(context), |
194 restApi_(NULL), | 198 restApi_(NULL), |
195 hasStorageArea_(false), | 199 hasStorageArea_(false), |
1020 pimpl_->storageArea_ = p; | 1024 pimpl_->storageArea_ = p; |
1021 pimpl_->hasStorageArea_ = true; | 1025 pimpl_->hasStorageArea_ = true; |
1022 return true; | 1026 return true; |
1023 } | 1027 } |
1024 | 1028 |
1029 case _OrthancPluginService_SetProperty: | |
1030 { | |
1031 const _OrthancPluginSetProperty& p = | |
1032 *reinterpret_cast<const _OrthancPluginSetProperty*>(parameters); | |
1033 pimpl_->properties_[std::make_pair(p.plugin, p.property)] = p.value; | |
1034 return true; | |
1035 } | |
1036 | |
1025 default: | 1037 default: |
1026 return false; | 1038 return false; |
1027 } | 1039 } |
1028 } | 1040 } |
1029 | 1041 |
1135 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 1147 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
1136 } | 1148 } |
1137 | 1149 |
1138 return new PluginStorageArea(pimpl_->storageArea_);; | 1150 return new PluginStorageArea(pimpl_->storageArea_);; |
1139 } | 1151 } |
1152 | |
1153 | |
1154 | |
1155 const char* OrthancPlugins::GetProperty(const char* plugin, | |
1156 _OrthancPluginProperty property) const | |
1157 { | |
1158 PImpl::Property p = std::make_pair(plugin, property); | |
1159 PImpl::Properties::const_iterator it = pimpl_->properties_.find(p); | |
1160 | |
1161 if (it == pimpl_->properties_.end()) | |
1162 { | |
1163 return NULL; | |
1164 } | |
1165 else | |
1166 { | |
1167 return it->second.c_str(); | |
1168 } | |
1169 } | |
1140 } | 1170 } |