Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 628e31a

Browse files
committed
add alias KeyValueVector
1 parent db41a7e commit 628e31a

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

include/behaviortree_cpp/basic_types.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22

33
#include <iostream>
44
#include <vector>
5-
#include <sstream>
65
#include <unordered_map>
7-
#include <unordered_set>
86
#include <typeinfo>
97
#include <functional>
108
#include <chrono>
11-
#include <memory>
129
#include <string_view>
1310
#include <utility>
1411
#include <variant>
1512
#include <vector>
16-
#include <optional>
1713

1814
#include "behaviortree_cpp/utils/safe_any.hpp"
1915
#include "behaviortree_cpp/exceptions.h"
@@ -63,6 +59,9 @@ enum class PortDirection
6359

6460
using StringView = std::string_view;
6561

62+
// vector of key/value pairs
63+
using KeyValueVector = std::vector<std::pair<std::string, std::string>>;
64+
6665
/**
6766
* convertFromString is used to convert a string into a custom type.
6867
*
@@ -447,7 +446,7 @@ struct has_static_method_metadata : std::false_type
447446
template <typename T>
448447
struct has_static_method_metadata<
449448
T, typename std::enable_if<
450-
std::is_same<decltype(T::metadata()), std::vector<std::pair<std::string, std::string>>>::value>::type>
449+
std::is_same<decltype(T::metadata()), KeyValueVector>::value>::type>
451450
: std::true_type
452451
{
453452
};

include/behaviortree_cpp/bt_factory.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <functional>
2121
#include <memory>
2222
#include <unordered_map>
23-
#include <unordered_set>
2423
#include <set>
2524
#include <utility>
2625
#include <vector>
@@ -428,7 +427,7 @@ class BehaviorTreeFactory
428427
/// Add metadata to a specific manifest. This metadata will be added
429428
/// to <TreeNodesModel> with the function writeTreeNodesModelXML()
430429
void addMetadataToManifest(const std::string& node_id,
431-
const std::vector<std::pair<std::string, std::string>>& metadata);
430+
const KeyValueVector& metadata);
432431

433432
/**
434433
* @brief Add an Enum to the scripting language.

include/behaviortree_cpp/tree_node.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@
1313

1414
#pragma once
1515

16-
#include <condition_variable>
1716
#include <exception>
18-
#include <mutex>
1917
#include <map>
2018
#include <utility>
21-
#include <vector>
2219

2320
#include "behaviortree_cpp/utils/signal.h"
2421
#include "behaviortree_cpp/basic_types.h"
@@ -40,7 +37,7 @@ struct TreeNodeManifest
4037
NodeType type;
4138
std::string registration_ID;
4239
PortsList ports;
43-
std::vector<std::pair<std::string, std::string>> metadata;
40+
KeyValueVector metadata;
4441
};
4542

4643
using PortsRemapping = std::unordered_map<std::string, std::string>;

src/bt_factory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ Tree BehaviorTreeFactory::createTree(const std::string& tree_name,
436436
}
437437

438438
void BehaviorTreeFactory::addMetadataToManifest(const std::string& node_id,
439-
const std::vector<std::pair<std::string, std::string>>& metadata)
439+
const KeyValueVector& metadata)
440440
{
441441
auto it = _p->manifests.find(node_id);
442442
if (it == _p->manifests.end())

tests/gtest_factory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ TEST(BehaviorTreeReload, ReloadSameTree)
391391
}
392392
}
393393

394-
std::vector<std::pair<std::string, std::string>> makeTestMetadata()
394+
KeyValueVector makeTestMetadata()
395395
{
396396
return {
397397
std::make_pair<std::string, std::string>("foo", "hello"),
@@ -413,7 +413,7 @@ class ActionWithMetadata : public SyncActionNode
413413
return {};
414414
}
415415

416-
static std::vector<std::pair<std::string, std::string>> metadata() {
416+
static KeyValueVector metadata() {
417417
return makeTestMetadata();
418418
}
419419
};

0 commit comments

Comments
 (0)