Skip to content

Commit 6b48665

Browse files
authored
chore: remove dead code from VehicleActionBuilder (#49)
- Remove unused buildVehicleAction() and completeVehicleActionEncoding() - Make getBuilders() inline in header to eliminate duplicate implementation
1 parent d386458 commit 6b48665

2 files changed

Lines changed: 3 additions & 68 deletions

File tree

include/message_builders.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,13 @@ namespace TeslaBLE
2020
public:
2121
using BuilderFunction = int(*)(CarServer_VehicleAction&, const void*);
2222

23-
/**
24-
* @brief Build a vehicle action message
25-
* @param action_type The type of action to build
26-
* @param action_data Optional data for the action (can be nullptr for simple actions)
27-
* @param output_buffer Buffer to write the encoded message
28-
* @param output_length Pointer to size variable that will contain the output length
29-
* @return Error code (0 on success)
30-
*/
31-
static int buildVehicleAction(
32-
pb_size_t action_type,
33-
const void* action_data,
34-
pb_byte_t* output_buffer,
35-
size_t* output_length);
36-
3723
/**
3824
* @brief Get the map of builders for direct access
3925
* @return Reference to the builders map
4026
*/
41-
static const std::unordered_map<pb_size_t, BuilderFunction>& getBuilders();
27+
static const std::unordered_map<pb_size_t, BuilderFunction>& getBuilders() {
28+
return builders_;
29+
}
4230

4331
private:
4432
// Builder functions for different action types

src/message_builders.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88

99
namespace TeslaBLE
1010
{
11-
// Helper function to complete the encoding - will be moved to Client class
12-
static int completeVehicleActionEncoding(
13-
CarServer_Action& action,
14-
pb_byte_t* output_buffer,
15-
size_t* output_length)
16-
{
17-
// For now, return error to indicate incomplete implementation
18-
// This will be completed when we integrate with Client class
19-
return TeslaBLE_Status_E_ERROR_INTERNAL;
20-
}
2111

2212
// Forward declarations of builder functions
2313
static int buildChargingSetLimit(CarServer_VehicleAction& action, const void* data);
@@ -75,49 +65,6 @@ namespace TeslaBLE
7565
{CarServer_VehicleAction_hvacBioweaponModeAction_tag, buildHvacBioweaponMode}
7666
};
7767

78-
int VehicleActionBuilder::buildVehicleAction(
79-
pb_size_t action_type,
80-
const void* action_data,
81-
pb_byte_t* output_buffer,
82-
size_t* output_length)
83-
{
84-
// Validate input parameters
85-
int result = validateInputParameters(output_buffer, output_length);
86-
if (result != TeslaBLE_Status_E_OK) {
87-
return result;
88-
}
89-
90-
// Find the appropriate builder
91-
auto it = builders_.find(action_type);
92-
if (it == builders_.end()) {
93-
LOG_ERROR("Unsupported vehicle action type: %d", action_type);
94-
return TeslaBLE_Status_E_ERROR_INVALID_PARAMS;
95-
}
96-
97-
// Create the action structure
98-
CarServer_Action action = CarServer_Action_init_default;
99-
action.which_action_msg = CarServer_Action_vehicleAction_tag;
100-
101-
CarServer_VehicleAction vehicle_action = CarServer_VehicleAction_init_default;
102-
vehicle_action.which_vehicle_action_msg = action_type;
103-
104-
// Build the specific action
105-
result = it->second(vehicle_action, action_data);
106-
if (result != TeslaBLE_Status_E_OK) {
107-
return result;
108-
}
109-
110-
action.action_msg.vehicleAction = vehicle_action;
111-
112-
// Complete the encoding using the helper function
113-
return completeVehicleActionEncoding(action, output_buffer, output_length);
114-
}
115-
116-
const std::unordered_map<pb_size_t, VehicleActionBuilder::BuilderFunction>&
117-
VehicleActionBuilder::getBuilders() {
118-
return builders_;
119-
}
120-
12168
// Builder implementations
12269
int VehicleActionBuilder::buildChargingSetLimit(CarServer_VehicleAction& action, const void* data)
12370
{

0 commit comments

Comments
 (0)