Skip to content

Commit 4358c29

Browse files
committed
remove stop if stoppable
1 parent d04368a commit 4358c29

File tree

3 files changed

+2
-24
lines changed

3 files changed

+2
-24
lines changed

src/viam/sdk/module/service.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@ struct ModuleService::ServiceImpl : viam::module::v1::ModuleService::Service {
124124
}
125125

126126
// if the type isn't reconfigurable by default, replace it
127-
try {
128-
Stoppable::stop_if_stoppable(res);
129-
} catch (const std::exception& err) {
130-
VIAM_SDK_LOG(error) << "unable to stop resource: " << err.what();
127+
if (auto stoppable = std::dynamic_pointer_cast<Stoppable>(res)) {
128+
stoppable->stop();
131129
}
132130

133131
const std::shared_ptr<const ModelRegistration> reg =

src/viam/sdk/resource/stoppable.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,5 @@ namespace sdk {
66
Stoppable::~Stoppable() = default;
77
Stoppable::Stoppable() = default;
88

9-
void Stoppable::stop_if_stoppable(const std::shared_ptr<Resource>& resource,
10-
const ProtoStruct& extra) {
11-
auto stoppable_res = std::dynamic_pointer_cast<Stoppable>(resource);
12-
if (stoppable_res) {
13-
stoppable_res->stop(extra);
14-
}
15-
}
16-
179
} // namespace sdk
1810
} // namespace viam

src/viam/sdk/resource/stoppable.hpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@ class Stoppable {
1717
return stop({});
1818
}
1919

20-
/// @brief Stops a Resource if it is Stoppable.
21-
/// @param resource The Resource to stop.
22-
/// @param extra Extra arguments to pass to the resource's `stop` method.
23-
static void stop_if_stoppable(const std::shared_ptr<Resource>& resource,
24-
const ProtoStruct& extra);
25-
26-
/// @brief Stops a Resource if it is Stoppable.
27-
/// @param resource The Resource to stop.
28-
inline static void stop_if_stoppable(const std::shared_ptr<Resource>& resource) {
29-
return stop_if_stoppable(resource, {});
30-
}
31-
3220
protected:
3321
explicit Stoppable();
3422
};

0 commit comments

Comments
 (0)