comparison OrthancServer/Scheduler/ServerJob.cpp @ 1000:13e230bbd882 lua-scripting

rename filter to command
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 04 Jul 2014 14:14:14 +0200
parents f0ac3a53ccf2
children 26642cecd36d
comparison
equal deleted inserted replaced
999:db18c071fbd7 1000:13e230bbd882
38 38
39 namespace Orthanc 39 namespace Orthanc
40 { 40 {
41 void ServerJob::CheckOrdering() 41 void ServerJob::CheckOrdering()
42 { 42 {
43 std::map<ServerFilterInstance*, unsigned int> index; 43 std::map<ServerCommandInstance*, unsigned int> index;
44 44
45 unsigned int count = 0; 45 unsigned int count = 0;
46 for (std::list<ServerFilterInstance*>::const_iterator 46 for (std::list<ServerCommandInstance*>::const_iterator
47 it = filters_.begin(); it != filters_.end(); it++) 47 it = filters_.begin(); it != filters_.end(); it++)
48 { 48 {
49 index[*it] = count++; 49 index[*it] = count++;
50 } 50 }
51 51
52 for (std::list<ServerFilterInstance*>::const_iterator 52 for (std::list<ServerCommandInstance*>::const_iterator
53 it = filters_.begin(); it != filters_.end(); it++) 53 it = filters_.begin(); it != filters_.end(); it++)
54 { 54 {
55 const std::list<ServerFilterInstance*>& nextFilters = (*it)->GetNextFilters(); 55 const std::list<ServerCommandInstance*>& nextCommands = (*it)->GetNextCommands();
56 56
57 for (std::list<ServerFilterInstance*>::const_iterator 57 for (std::list<ServerCommandInstance*>::const_iterator
58 next = nextFilters.begin(); next != nextFilters.end(); next++) 58 next = nextCommands.begin(); next != nextCommands.end(); next++)
59 { 59 {
60 if (index.find(*next) == index.end() || 60 if (index.find(*next) == index.end() ||
61 index[*next] <= index[*it]) 61 index[*next] <= index[*it])
62 { 62 {
63 // You must reorder your calls to "ServerJob::AddFilter" 63 // You must reorder your calls to "ServerJob::AddCommand"
64 throw OrthancException("Bad ordering of filters in a job"); 64 throw OrthancException("Bad ordering of filters in a job");
65 } 65 }
66 } 66 }
67 } 67 }
68 } 68 }
69 69
70 70
71 size_t ServerJob::Submit(SharedMessageQueue& target, 71 size_t ServerJob::Submit(SharedMessageQueue& target,
72 ServerFilterInstance::IListener& listener) 72 ServerCommandInstance::IListener& listener)
73 { 73 {
74 if (submitted_) 74 if (submitted_)
75 { 75 {
76 // This job has already been submitted 76 // This job has already been submitted
77 throw OrthancException(ErrorCode_BadSequenceOfCalls); 77 throw OrthancException(ErrorCode_BadSequenceOfCalls);
79 79
80 CheckOrdering(); 80 CheckOrdering();
81 81
82 size_t size = filters_.size(); 82 size_t size = filters_.size();
83 83
84 for (std::list<ServerFilterInstance*>::iterator 84 for (std::list<ServerCommandInstance*>::iterator
85 it = filters_.begin(); it != filters_.end(); it++) 85 it = filters_.begin(); it != filters_.end(); it++)
86 { 86 {
87 target.Enqueue(*it); 87 target.Enqueue(*it);
88 } 88 }
89 89
102 } 102 }
103 103
104 104
105 ServerJob::~ServerJob() 105 ServerJob::~ServerJob()
106 { 106 {
107 for (std::list<ServerFilterInstance*>::iterator 107 for (std::list<ServerCommandInstance*>::iterator
108 it = filters_.begin(); it != filters_.end(); it++) 108 it = filters_.begin(); it != filters_.end(); it++)
109 { 109 {
110 delete *it; 110 delete *it;
111 } 111 }
112 } 112 }
113 113
114 114
115 ServerFilterInstance& ServerJob::AddFilter(IServerFilter* filter) 115 ServerCommandInstance& ServerJob::AddCommand(IServerCommand* filter)
116 { 116 {
117 if (submitted_) 117 if (submitted_)
118 { 118 {
119 throw OrthancException(ErrorCode_BadSequenceOfCalls); 119 throw OrthancException(ErrorCode_BadSequenceOfCalls);
120 } 120 }
121 121
122 filters_.push_back(new ServerFilterInstance(filter, jobId_)); 122 filters_.push_back(new ServerCommandInstance(filter, jobId_));
123 123
124 return *filters_.back(); 124 return *filters_.back();
125 } 125 }
126 } 126 }