Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ docker build --build-arg BASE_TAG=base/bullseye --build-arg GIT_TAG=[...] -f etc
```

This will use `base/bullseye` as a base to build the SDK version provided in `GIT_TAG`,
which should be a tagged release version. The SDK will be cloned from
which should be a tagged release version. The SDK will be cloned from
https://github.com/viamrobotics/viam-cpp-sdk/. This is the recommended approach for
C++ module development, which should generally be done against a tagged release.

Expand All @@ -47,22 +47,22 @@ docker build --build-arg BASE_TAG=base/bullseye --build-arg REPO_SETUP=copy -f e
```

Note the use of the build argument `REPO_SETUP=copy`, which adds a Docker instruction
to copy the SDK repo from the current working directory, rather than cloning from
to copy the SDK repo from the current working directory, rather than cloning from
GitHub. This approach may make more sense for developing on the SDK itself, or if
your C++ SDK development relies on a localversion of the SDK.

The examples above illustrated the use of several `--build-arg` arguments, namely
`BASE_TAG`, `GIT_TAG`, and `REPO_SETUP`. Please see
`BASE_TAG`, `GIT_TAG`, and `REPO_SETUP`. Please see
[Dockerfile.sdk-build](etc/docker/Dockerfile.sdk-build) for a complete account of
all build arguments and their defaults.

## Building Documentation Locally for Testing
The C++ sdk uses [Doxygen](https://www.doxygen.nl/) to generate documentation.
An automated workflow will generate and update our documentation on each merge,
and publish it to [cpp.viam.dev](https://cpp.viam.dev).
and publish it to [cpp.viam.dev](https://cpp.viam.dev).

Generating documentation locally to observe changes while developing with the
C++ SDK is simple.
C++ SDK is simple.
First, make sure doxygen is installed, e.g.,
```
(on mac) brew install doxygen
Expand Down Expand Up @@ -91,10 +91,10 @@ quickly as possible.
## A note on logging

Users should only interact with logging via the macros, classes, and functions in
[`viam/sdk/log/logging.hpp`](src/viam/sdk/log/logging.hpp). Logging is
[`viam/sdk/log/logging.hpp`](src/viam/sdk/log/logging.hpp). Logging is
implemented using Boost.Log, but this is an implementation detail subject
to change without warning. In particular, using Boost.Log macros such as
`BOOST_LOG_TRIVIAL` or `BOOST_LOG_SEV` is undefined behavior which will likely
`BOOST_LOG_TRIVIAL` or `BOOST_LOG_SEV` is undefined behavior which will likely
fail to output log messages.

## License
Expand Down
6 changes: 3 additions & 3 deletions src/viam/examples/modules/complex/gizmo/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ API API::traits<Gizmo>::api() {
return {"viam", "component", "gizmo"};
}

Gizmo::Gizmo(std::string name) : Component(std::move(name)){};
Gizmo::Gizmo(std::string name) : Component(std::move(name)) {}

/* Gizmo server methods */

GizmoServer::GizmoServer(std::shared_ptr<ResourceManager> manager)
: ResourceServer(std::move(manager)){};
: ResourceServer(std::move(manager)) {}

grpc::Status GizmoServer::DoOne(grpc::ServerContext* context,
const DoOneRequest* request,
Expand Down Expand Up @@ -170,7 +170,7 @@ grpc::Status GizmoServer::DoTwo(::grpc::ServerContext* context,
/* Gizmo client methods */

GizmoClient::GizmoClient(std::string name, std::shared_ptr<grpc::Channel> channel)
: Gizmo(std::move(name)), stub_(GizmoService::NewStub(channel)), channel_(std::move(channel)){};
: Gizmo(std::move(name)), stub_(GizmoService::NewStub(channel)), channel_(std::move(channel)) {}

bool GizmoClient::do_one(std::string arg1) {
return make_client_helper(this, *stub_, &StubType::DoOne)
Expand Down
4 changes: 2 additions & 2 deletions src/viam/examples/modules/complex/gizmo/impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ using namespace viam::sdk;
// `validate` method that checks config validity.
class MyGizmo : public Gizmo, public Reconfigurable {
public:
MyGizmo(std::string name, std::string arg1) : Gizmo(std::move(name)), arg1_(std::move(arg1)){};
MyGizmo(std::string name, std::string arg1) : Gizmo(std::move(name)), arg1_(std::move(arg1)) {}
MyGizmo(const Dependencies& deps, const ResourceConfig& cfg) : Gizmo(cfg.name()) {
this->reconfigure(deps, cfg);
};
}
void reconfigure(const Dependencies& deps, const ResourceConfig& cfg) override;
static std::vector<std::string> validate(ResourceConfig cfg);

Expand Down
6 changes: 3 additions & 3 deletions src/viam/examples/modules/complex/summation/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ API API::traits<Summation>::api() {
return {"viam", "service", "summation"};
}

Summation::Summation(std::string name) : Service(std::move(name)){};
Summation::Summation(std::string name) : Service(std::move(name)) {}

/* Summation server methods */

SummationServer::SummationServer(std::shared_ptr<ResourceManager> manager)
: ResourceServer(std::move(manager)){};
: ResourceServer(std::move(manager)) {}

grpc::Status SummationServer::Sum(grpc::ServerContext* context,
const SumRequest* request,
Expand Down Expand Up @@ -58,7 +58,7 @@ grpc::Status SummationServer::Sum(grpc::ServerContext* context,
SummationClient::SummationClient(std::string name, std::shared_ptr<grpc::Channel> channel)
: Summation(std::move(name)),
stub_(SummationService::NewStub(channel)),
channel_(std::move(channel)){};
channel_(std::move(channel)) {}

double SummationClient::sum(std::vector<double> numbers) {
return make_client_helper(this, *stub_, &StubType::Sum)
Expand Down
4 changes: 2 additions & 2 deletions src/viam/examples/modules/complex/summation/impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ using namespace viam::sdk;
class MySummation : public Summation, public Reconfigurable {
public:
MySummation(std::string name, bool subtract)
: Summation(std::move(name)), subtract_(subtract){};
: Summation(std::move(name)), subtract_(subtract) {}
MySummation(const Dependencies& deps, const ResourceConfig& cfg) : Summation(cfg.name()) {
this->reconfigure(deps, cfg);
};
}
void reconfigure(const Dependencies& deps, const ResourceConfig& cfg) override;
static std::vector<std::string> validate(ResourceConfig cfg);

Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/components/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bool operator==(const Base::properties& lhs, const Base::properties& rhs) {
lhs.turning_radius_meters == rhs.turning_radius_meters;
}

Base::Base(std::string name) : Component(std::move(name)){};
Base::Base(std::string name) : Component(std::move(name)) {}

} // namespace sdk
} // namespace viam
2 changes: 1 addition & 1 deletion src/viam/sdk/components/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ API API::traits<Board>::api() {
return {kRDK, kComponent, "board"};
}

Board::Board(std::string name) : Component(std::move(name)){};
Board::Board(std::string name) : Component(std::move(name)) {}

bool operator==(const Board::status& lhs, const Board::status& rhs) {
return (lhs.analog_reader_values == rhs.analog_reader_values &&
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/components/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ std::string Camera::normalize_mime_type(const std::string& str) {
return mime_type;
}

Camera::Camera(std::string name) : Component(std::move(name)){};
Camera::Camera(std::string name) : Component(std::move(name)) {}

bool operator==(const Camera::point_cloud& lhs, const Camera::point_cloud& rhs) {
return lhs.mime_type == rhs.mime_type && lhs.pc == rhs.pc;
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/components/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ API API::traits<Encoder>::api() {
return {kRDK, kComponent, "encoder"};
}

Encoder::Encoder(std::string name) : Component(std::move(name)){};
Encoder::Encoder(std::string name) : Component(std::move(name)) {}

bool operator==(const Encoder::position& lhs, const Encoder::position& rhs) {
return (lhs.value == rhs.value && lhs.type == rhs.type);
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/components/generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ API API::traits<GenericComponent>::api() {
return {kRDK, kComponent, "generic"};
}

GenericComponent::GenericComponent(std::string name) : Component(std::move(name)){};
GenericComponent::GenericComponent(std::string name) : Component(std::move(name)) {}

} // namespace sdk
} // namespace viam
2 changes: 1 addition & 1 deletion src/viam/sdk/components/motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ API API::traits<Motor>::api() {
return {kRDK, kComponent, "motor"};
}

Motor::Motor(std::string name) : Component(std::move(name)){};
Motor::Motor(std::string name) : Component(std::move(name)) {}

bool operator==(const Motor::power_status& lhs, const Motor::power_status& rhs) {
return (lhs.is_on == rhs.is_on && lhs.power_pct == rhs.power_pct);
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/components/movement_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MovementSensor : public Component {
virtual std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) = 0;

protected:
explicit MovementSensor(std::string name) : Component(std::move(name)){};
explicit MovementSensor(std::string name) : Component(std::move(name)) {}
};

template <>
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/components/power_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class PowerSensor : public Component {
virtual ProtoStruct do_command(const ProtoStruct& command) = 0;

protected:
explicit PowerSensor(std::string name) : Component(std::move(name)){};
explicit PowerSensor(std::string name) : Component(std::move(name)) {}
};

template <>
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/components/private/camera_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CameraClient : public Camera {
// avoid use of this constructor outside of tests.
CameraClient(std::string name,
std::unique_ptr<viam::component::camera::v1::CameraService::StubInterface> stub)
: Camera(std::move(name)), stub_(std::move(stub)){};
: Camera(std::move(name)), stub_(std::move(stub)) {}

private:
using StubType = viam::component::camera::v1::CameraService::StubInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/components/private/generic_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GenericComponentClient : public GenericComponent {
GenericComponentClient(
std::string name,
std::unique_ptr<viam::component::generic::v1::GenericService::StubInterface> stub)
: GenericComponent(std::move(name)), stub_(std::move(stub)){};
: GenericComponent(std::move(name)), stub_(std::move(stub)) {}

private:
using StubType = viam::component::generic::v1::GenericService::StubInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/components/sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Sensor : public Component {
virtual ProtoStruct get_readings(const ProtoStruct& extra) = 0;

protected:
explicit Sensor(std::string name) : Component(std::move(name)){};
explicit Sensor(std::string name) : Component(std::move(name)) {}
};

template <>
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/components/servo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Servo : public Component, public Stoppable {
virtual std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) = 0;

protected:
explicit Servo(std::string name) : Component(std::move(name)){};
explicit Servo(std::string name) : Component(std::move(name)) {}
};

template <>
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/resource/resource_server_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ResourceServer {
const std::shared_ptr<ResourceManager>& resource_manager() const;

protected:
ResourceServer(std::shared_ptr<ResourceManager> manager) : manager_(manager){};
ResourceServer(std::shared_ptr<ResourceManager> manager) : manager_(manager) {}

private:
std::shared_ptr<ResourceManager> manager_;
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/services/generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ API API::traits<GenericService>::api() {
return {kRDK, kService, "generic"};
}

GenericService::GenericService(std::string name) : Service(std::move(name)){};
GenericService::GenericService(std::string name) : Service(std::move(name)) {}

} // namespace sdk
} // namespace viam
2 changes: 1 addition & 1 deletion src/viam/sdk/services/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace viam {
namespace sdk {

Motion::Motion(std::string name) : Service(std::move(name)){};
Motion::Motion(std::string name) : Service(std::move(name)) {}

API Motion::api() const {
return API::get<Motion>();
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/services/private/generic_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GenericServiceClient : public GenericService {
GenericServiceClient(
std::string name,
std::unique_ptr<viam::service::generic::v1::GenericService::StubInterface> stub)
: GenericService(std::move(name)), stub_(std::move(stub)){};
: GenericService(std::move(name)), stub_(std::move(stub)) {}

private:
using StubType = viam::service::generic::v1::GenericService::StubInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/services/private/mlmodel_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ::grpc::Status MLModelServiceServer::Infer(
<< static_cast<ut>(tensor_type);
return helper.fail(::grpc::INVALID_ARGUMENT, message.str().c_str());
}
inputs.emplace(tensor_pair.first, std::move(tensor));
inputs.emplace(input.name, std::move(tensor));
} else {
// Normal case: multiple tensors, do metadata checks
// If there are extra tensors in the inputs that not found in the metadata,
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/camera_mocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MockCamera : public Camera {
std::vector<GeometryConfig> get_geometries(const sdk::ProtoStruct& extra) override;
properties get_properties() override;
static std::shared_ptr<MockCamera> get_mock_camera();
MockCamera(std::string name) : Camera(std::move(name)){};
MockCamera(std::string name) : Camera(std::move(name)) {}

private:
Camera::intrinsic_parameters intrinsic_parameters_;
Expand Down
4 changes: 2 additions & 2 deletions src/viam/sdk/tests/mocks/generic_mocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace viam::sdk;

class MockGenericComponent : public GenericComponent {
public:
MockGenericComponent(std::string name) : GenericComponent(std::move(name)){};
MockGenericComponent(std::string name) : GenericComponent(std::move(name)) {}
ProtoStruct do_command(const ProtoStruct& command) override;

static std::shared_ptr<MockGenericComponent> get_mock_generic();
Expand All @@ -26,7 +26,7 @@ class MockGenericComponent : public GenericComponent {

class MockGenericService : public GenericService {
public:
MockGenericService(std::string name) : GenericService(std::move(name)){};
MockGenericService(std::string name) : GenericService(std::move(name)) {}
ProtoStruct do_command(const ProtoStruct& command) override;

static std::shared_ptr<MockGenericService> get_mock_generic();
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/mock_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MockBase : public sdk::Base {
bool peek_stop_called;
sdk::ProtoStruct peek_do_command_command;

MockBase(std::string name) : Base(std::move(name)){};
MockBase(std::string name) : Base(std::move(name)) {}
};

} // namespace base
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/mock_board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace board {

using namespace viam::sdk;

MockBoard::MockBoard(std::string name) : Board(std::move(name)){};
MockBoard::MockBoard(std::string name) : Board(std::move(name)) {}

void MockBoard::set_gpio(const std::string& pin, bool high, const ProtoStruct&) {
this->peek_pin = pin;
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/mock_encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MockEncoder : public viam::sdk::Encoder {
viam::sdk::ProtoStruct do_command(const viam::sdk::ProtoStruct& command) override;
static std::shared_ptr<MockEncoder> get_mock_encoder();

MockEncoder(std::string name) : Encoder(std::move(name)){};
MockEncoder(std::string name) : Encoder(std::move(name)) {}

// For testing purposes only.
bool peek_reset_position_called;
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/mock_motion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class MockMotion : public sdk::Motion {
std::shared_ptr<sdk::WorldState> peek_world_state;

MockMotion(std::string name)
: sdk::Motion(std::move(name)), current_location(init_fake_pose()){};
: sdk::Motion(std::move(name)), current_location(init_fake_pose()) {}
};

} // namespace motion
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/mock_motor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MockMotor : public Motor {
static std::shared_ptr<MockMotor> get_mock_motor();
virtual std::vector<sdk::GeometryConfig> get_geometries(const sdk::ProtoStruct& extra) override;

MockMotor(std::string name) : Motor(std::move(name)){};
MockMotor(std::string name) : Motor(std::move(name)) {}

using Motor::get_geometries;
using Motor::get_position;
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/mock_movement_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MockMovementSensor : public sdk::MovementSensor {
std::unordered_map<std::string, float> peek_accuracy;
sdk::ProtoStruct peek_do_command_command;

MockMovementSensor(std::string name) : MovementSensor(std::move(name)){};
MockMovementSensor(std::string name) : MovementSensor(std::move(name)) {}
};

} // namespace movementsensor
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/mock_power_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MockPowerSensor : public sdk::PowerSensor {
sdk::PowerSensor::current peek_current;
double peek_power;

MockPowerSensor(std::string name) : PowerSensor(std::move(name)){};
MockPowerSensor(std::string name) : PowerSensor(std::move(name)) {}
};

} // namespace powersensor
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/mock_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MockSensor : public sdk::Sensor {
static std::shared_ptr<MockSensor> get_mock_sensor();
std::vector<sdk::GeometryConfig> get_geometries(const sdk::ProtoStruct& extra) override;

MockSensor(std::string name) : Sensor(std::move(name)){};
MockSensor(std::string name) : Sensor(std::move(name)) {}
};

} // namespace sensor
Expand Down
2 changes: 1 addition & 1 deletion src/viam/sdk/tests/mocks/mock_servo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MockServo : public Servo {
static std::shared_ptr<MockServo> get_mock_servo();
virtual std::vector<sdk::GeometryConfig> get_geometries(const sdk::ProtoStruct& extra) override;

MockServo(std::string name) : Servo(std::move(name)){};
MockServo(std::string name) : Servo(std::move(name)) {}

using Servo::get_geometries;
using Servo::get_position;
Expand Down
Loading