Skip to content

Commit 29407b9

Browse files
Roman Donchenkoeldercrow
authored andcommitted
security_barrier_camera_demo: make InferRequestsContainer uncopyable
Cppcheck complains about a violation of the rule of three. I could add a real copy constructor; however, the assignment operator isn't really needed either, so instead I deleted them both and implemented an `assign` method, which is all the class really needs. This makes the non-default constructor unnecessary, so I removed it too.
1 parent abe2c0c commit 29407b9

File tree

1 file changed

+13
-16
lines changed
  • demos/security_barrier_camera_demo

1 file changed

+13
-16
lines changed

demos/security_barrier_camera_demo/main.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,19 @@ struct BboxAndDescr {
6565
};
6666

6767
struct InferRequestsContainer {
68-
explicit InferRequestsContainer(std::vector<InferRequest> inferRequests):
69-
actualInferRequests{inferRequests} {
70-
for (auto& ir : actualInferRequests) {
71-
inferRequests.push_back(ir);
72-
}
73-
}
7468
InferRequestsContainer() = default;
75-
InferRequestsContainer& operator=(const InferRequestsContainer& other) { // copy assignment
76-
if (this != &other) { // self-assignment check expected
77-
this->actualInferRequests = other.actualInferRequests;
78-
for (auto& ir : this->actualInferRequests) {
79-
this->inferRequests.container.push_back(ir);
80-
}
69+
InferRequestsContainer(const InferRequestsContainer&) = delete;
70+
InferRequestsContainer& operator=(const InferRequestsContainer&) = delete;
71+
72+
void assign(const std::vector<InferRequest>& inferRequests) {
73+
actualInferRequests = inferRequests;
74+
this->inferRequests.container.clear();
75+
76+
for (auto& ir : this->actualInferRequests) {
77+
this->inferRequests.container.push_back(ir);
8178
}
82-
return *this;
8379
}
80+
8481
std::vector<InferRequest> getActualInferRequests() {
8582
return actualInferRequests;
8683
}
@@ -126,9 +123,9 @@ struct Context { // stores all global data for tasks
126123
return detectionsProcessorsContext.vehicleAttributesClassifier.createInferRequest();});
127124
std::generate_n(std::back_inserter(lprInferRequests), nrecognizersireq, [&]{
128125
return detectionsProcessorsContext.lpr.createInferRequest();});
129-
detectorsInfers = InferRequestsContainer(detectorInferRequests);
130-
attributesInfers = InferRequestsContainer(attributesInferRequests);
131-
platesInfers = InferRequestsContainer(lprInferRequests);
126+
detectorsInfers.assign(detectorInferRequests);
127+
attributesInfers.assign(attributesInferRequests);
128+
platesInfers.assign(lprInferRequests);
132129
}
133130
struct {
134131
std::vector<std::shared_ptr<InputChannel>> inputChannels;

0 commit comments

Comments
 (0)