Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerIndex.cpp @ 4561:02510325d869 db-changes
removed function wrappers for transactions in ServerIndex
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Mar 2021 18:45:48 +0100 |
parents | 929409e40008 |
children | e19f11e08226 |
comparison
equal
deleted
inserted
replaced
4560:929409e40008 | 4561:02510325d869 |
---|---|
2323 } | 2323 } |
2324 }; | 2324 }; |
2325 } | 2325 } |
2326 | 2326 |
2327 | 2327 |
2328 class ServerIndex::ReadOnlyWrapper : public IReadOnlyOperations | |
2329 { | |
2330 private: | |
2331 ReadOnlyFunction func_; | |
2332 | |
2333 public: | |
2334 explicit ReadOnlyWrapper(ReadOnlyFunction func) : | |
2335 func_(func) | |
2336 { | |
2337 assert(func_ != NULL); | |
2338 } | |
2339 | |
2340 virtual void Apply(ReadOnlyTransaction& transaction) ORTHANC_OVERRIDE | |
2341 { | |
2342 func_(transaction); | |
2343 } | |
2344 }; | |
2345 | |
2346 | |
2347 class ServerIndex::ReadWriteWrapper : public IReadWriteOperations | |
2348 { | |
2349 private: | |
2350 ReadWriteFunction func_; | |
2351 | |
2352 public: | |
2353 explicit ReadWriteWrapper(ReadWriteFunction func) : | |
2354 func_(func) | |
2355 { | |
2356 assert(func_ != NULL); | |
2357 } | |
2358 | |
2359 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE | |
2360 { | |
2361 func_(transaction); | |
2362 } | |
2363 }; | |
2364 | |
2365 | |
2366 void ServerIndex::ApplyInternal(IReadOnlyOperations* readOperations, | 2328 void ServerIndex::ApplyInternal(IReadOnlyOperations* readOperations, |
2367 IReadWriteOperations* writeOperations) | 2329 IReadWriteOperations* writeOperations) |
2368 { | 2330 { |
2369 if ((readOperations == NULL && writeOperations == NULL) || | 2331 if ((readOperations == NULL && writeOperations == NULL) || |
2370 (readOperations != NULL && writeOperations != NULL)) | 2332 (readOperations != NULL && writeOperations != NULL)) |
2429 throw; | 2391 throw; |
2430 } | 2392 } |
2431 } | 2393 } |
2432 } | 2394 } |
2433 } | 2395 } |
2396 | |
2434 | 2397 |
2435 void ServerIndex::Apply(IReadOnlyOperations& operations) | 2398 void ServerIndex::Apply(IReadOnlyOperations& operations) |
2436 { | 2399 { |
2437 ApplyInternal(&operations, NULL); | 2400 ApplyInternal(&operations, NULL); |
2438 } | 2401 } |
2439 | 2402 |
2403 | |
2440 void ServerIndex::Apply(IReadWriteOperations& operations) | 2404 void ServerIndex::Apply(IReadWriteOperations& operations) |
2441 { | 2405 { |
2442 ApplyInternal(NULL, &operations); | 2406 ApplyInternal(NULL, &operations); |
2443 } | 2407 } |
2444 | 2408 |
2445 void ServerIndex::Apply(ReadOnlyFunction func) | |
2446 { | |
2447 ReadOnlyWrapper wrapper(func); | |
2448 Apply(wrapper); | |
2449 } | |
2450 | |
2451 void ServerIndex::Apply(ReadWriteFunction func) | |
2452 { | |
2453 ReadWriteWrapper wrapper(func); | |
2454 Apply(wrapper); | |
2455 } | |
2456 | |
2457 | 2409 |
2458 bool ServerIndex::ExpandResource(Json::Value& target, | 2410 bool ServerIndex::ExpandResource(Json::Value& target, |
2459 const std::string& publicId, | 2411 const std::string& publicId, |
2460 ResourceType level) | 2412 ResourceType level) |
2461 { | 2413 { |