comparison Framework/Oracle/ThreadedOracle.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 7ec8fea061b9
children 257f2c9a02ac
comparison
equal deleted inserted replaced
1297:6ab03e429f06 1299:c38c89684d83
30 { 30 {
31 class ThreadedOracle::Item : public Orthanc::IDynamicObject 31 class ThreadedOracle::Item : public Orthanc::IDynamicObject
32 { 32 {
33 private: 33 private:
34 boost::weak_ptr<IObserver> receiver_; 34 boost::weak_ptr<IObserver> receiver_;
35 std::auto_ptr<IOracleCommand> command_; 35 std::unique_ptr<IOracleCommand> command_;
36 36
37 public: 37 public:
38 Item(boost::weak_ptr<IObserver> receiver, 38 Item(boost::weak_ptr<IObserver> receiver,
39 IOracleCommand* command) : 39 IOracleCommand* command) :
40 receiver_(receiver), 40 receiver_(receiver),
64 private: 64 private:
65 class Item 65 class Item
66 { 66 {
67 private: 67 private:
68 boost::weak_ptr<IObserver> receiver_; 68 boost::weak_ptr<IObserver> receiver_;
69 std::auto_ptr<SleepOracleCommand> command_; 69 std::unique_ptr<SleepOracleCommand> command_;
70 boost::posix_time::ptime expiration_; 70 boost::posix_time::ptime expiration_;
71 71
72 public: 72 public:
73 Item(boost::weak_ptr<IObserver> receiver, 73 Item(boost::weak_ptr<IObserver> receiver,
74 SleepOracleCommand* command) : 74 SleepOracleCommand* command) :
152 }; 152 };
153 153
154 154
155 void ThreadedOracle::Step() 155 void ThreadedOracle::Step()
156 { 156 {
157 std::auto_ptr<Orthanc::IDynamicObject> object(queue_.Dequeue(100)); 157 std::unique_ptr<Orthanc::IDynamicObject> object(queue_.Dequeue(100));
158 158
159 if (object.get() != NULL) 159 if (object.get() != NULL)
160 { 160 {
161 Item& item = dynamic_cast<Item&>(*object); 161 Item& item = dynamic_cast<Item&>(*object);
162 162
163 if (item.GetCommand().GetType() == IOracleCommand::Type_Sleep) 163 if (item.GetCommand().GetType() == IOracleCommand::Type_Sleep)
164 { 164 {
165 SleepOracleCommand& command = dynamic_cast<SleepOracleCommand&>(item.GetCommand()); 165 SleepOracleCommand& command = dynamic_cast<SleepOracleCommand&>(item.GetCommand());
166 166
167 std::auto_ptr<SleepOracleCommand> copy(new SleepOracleCommand(command.GetDelay())); 167 std::unique_ptr<SleepOracleCommand> copy(new SleepOracleCommand(command.GetDelay()));
168 168
169 if (command.HasPayload()) 169 if (command.HasPayload())
170 { 170 {
171 copy->AcquirePayload(command.ReleasePayload()); 171 copy->AcquirePayload(command.ReleasePayload());
172 } 172 }
410 410
411 411
412 bool ThreadedOracle::Schedule(boost::shared_ptr<IObserver> receiver, 412 bool ThreadedOracle::Schedule(boost::shared_ptr<IObserver> receiver,
413 IOracleCommand* command) 413 IOracleCommand* command)
414 { 414 {
415 std::auto_ptr<Item> item(new Item(receiver, command)); 415 std::unique_ptr<Item> item(new Item(receiver, command));
416 416
417 { 417 {
418 boost::mutex::scoped_lock lock(mutex_); 418 boost::mutex::scoped_lock lock(mutex_);
419 419
420 if (state_ == State_Running) 420 if (state_ == State_Running)