comparison Framework/Loaders/OracleScheduler.cpp @ 1299:c38c89684d83 broker

replacing std::auto_ptr by std::unique_ptr
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Mar 2020 17:21:24 +0100
parents 0ca50d275b9a
children 474360793956
comparison
equal deleted inserted replaced
1297:6ab03e429f06 1299:c38c89684d83
28 class OracleScheduler::ReceiverPayload : public Orthanc::IDynamicObject 28 class OracleScheduler::ReceiverPayload : public Orthanc::IDynamicObject
29 { 29 {
30 private: 30 private:
31 Priority priority_; 31 Priority priority_;
32 boost::weak_ptr<IObserver> receiver_; 32 boost::weak_ptr<IObserver> receiver_;
33 std::auto_ptr<IOracleCommand> command_; 33 std::unique_ptr<IOracleCommand> command_;
34 34
35 public: 35 public:
36 ReceiverPayload(Priority priority, 36 ReceiverPayload(Priority priority,
37 boost::weak_ptr<IObserver> receiver, 37 boost::weak_ptr<IObserver> receiver,
38 IOracleCommand* command) : 38 IOracleCommand* command) :
66 66
67 class OracleScheduler::ScheduledCommand : public boost::noncopyable 67 class OracleScheduler::ScheduledCommand : public boost::noncopyable
68 { 68 {
69 private: 69 private:
70 boost::weak_ptr<IObserver> receiver_; 70 boost::weak_ptr<IObserver> receiver_;
71 std::auto_ptr<IOracleCommand> command_; 71 std::unique_ptr<IOracleCommand> command_;
72 72
73 public: 73 public:
74 ScheduledCommand(boost::shared_ptr<IObserver> receiver, 74 ScheduledCommand(boost::shared_ptr<IObserver> receiver,
75 IOracleCommand* command) : 75 IOracleCommand* command) :
76 receiver_(receiver), 76 receiver_(receiver),
101 { 101 {
102 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 102 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
103 } 103 }
104 else 104 else
105 { 105 {
106 std::auto_ptr<IOracleCommand> wrapped(command_->Clone()); 106 std::unique_ptr<IOracleCommand> wrapped(command_->Clone());
107 dynamic_cast<OracleCommandBase&>(*wrapped).AcquirePayload(new ReceiverPayload(priority, receiver_, command_.release())); 107 dynamic_cast<OracleCommandBase&>(*wrapped).AcquirePayload(new ReceiverPayload(priority, receiver_, command_.release()));
108 return wrapped.release(); 108 return wrapped.release();
109 } 109 }
110 } 110 }
111 }; 111 };
196 CheckInvariants(); 196 CheckInvariants();
197 197
198 Queue::iterator item = queue.begin(); 198 Queue::iterator item = queue.begin();
199 assert(item != queue.end()); 199 assert(item != queue.end());
200 200
201 std::auto_ptr<ScheduledCommand> command(dynamic_cast<ScheduledCommand*>(item->second)); 201 std::unique_ptr<ScheduledCommand> command(dynamic_cast<ScheduledCommand*>(item->second));
202 queue.erase(item); 202 queue.erase(item);
203 203
204 if (command.get() != NULL) 204 if (command.get() != NULL)
205 { 205 {
206 /** 206 /**
520 520
521 void OracleScheduler::Schedule(boost::shared_ptr<IObserver> receiver, 521 void OracleScheduler::Schedule(boost::shared_ptr<IObserver> receiver,
522 int priority, 522 int priority,
523 IOracleCommand* command /* Takes ownership */) 523 IOracleCommand* command /* Takes ownership */)
524 { 524 {
525 std::auto_ptr<ScheduledCommand> pending(new ScheduledCommand(receiver, dynamic_cast<IOracleCommand*>(command))); 525 std::unique_ptr<ScheduledCommand> pending(new ScheduledCommand(receiver, dynamic_cast<IOracleCommand*>(command)));
526 526
527 /** 527 /**
528 * Safeguard to remember that a new "Handle()" method and a call 528 * Safeguard to remember that a new "Handle()" method and a call
529 * to "scheduler->Register()" must be implemented for each 529 * to "scheduler->Register()" must be implemented for each
530 * possible oracle command. 530 * possible oracle command.