Skip to content

Commit

Permalink
Fix loggers.
Browse files Browse the repository at this point in the history
  • Loading branch information
mamaheux committed Jan 15, 2024
1 parent 5f8b3f7 commit d9de3e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ HbbaLite hbba(desireSet,
// Add desires to the set.
```

#### Strategy State Logger
#### Strategy State Logger Usage
To log the strategy state changed of the strategy, you can use the `RosLogStrategyStateLogger` class.

```cpp
Expand All @@ -338,8 +338,8 @@ HbbaLite hbba(desireSet,
// Add desires to the set.
```
#### Filter State Logger
To log the filter state changed of the strategy, you can use the `RosLogStrategyStateLogger` class.
#### Filter State Logger Usage
To log the filter state changed of the strategy, you can use the `RosLogFilterPoolDecorator` class.
```cpp
constexpr bool WAIT_FOR_SERVICE = true;
Expand All @@ -348,7 +348,7 @@ auto desireSet = make_shared<DesireSet>(); // Create the desire set.
// Create the filter pool useful to change the filter states.
// If WAIT_FOR_SERVICE is true, the pool will wait until the service become available.
auto rosFilterPool = make_unique<RosFilterPool>(nodeHandle, WAIT_FOR_SERVICE);
auto filterPoos = make_shared<RosLogFilterPoolDecorator>(move(rosFilterPool));
auto filterPool = make_shared<RosLogFilterPoolDecorator>(move(rosFilterPool));
vector<unique_ptr<BaseStrategy>> strategies;
// Add the strategies related to the application into the vector.
Expand Down
3 changes: 2 additions & 1 deletion include/hbba_lite/core/Strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ inline bool operator!=(const FilterConfiguration& a, const FilterConfiguration&

class FilterPool
{
std::unordered_map<std::string, int> m_countsByName;

protected:
std::unordered_map<std::string, FilterType> m_typesByName;
std::unordered_map<std::string, int> m_countsByName;
std::unordered_map<std::string, FilterConfiguration> m_lastFilterConfigurationByName;

std::recursive_mutex m_mutex;
Expand Down
2 changes: 2 additions & 0 deletions src/hbba_lite_cpp/core/RosFilterPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ RosLogFilterPoolDecorator::RosLogFilterPoolDecorator(unique_ptr<FilterPool> filt

void RosLogFilterPoolDecorator::add(const std::string& name, FilterType type)
{
lock_guard<recursive_mutex> lock(m_mutex);
FilterPool::add(name, type);
m_filterPool->add(name, type);
}

Expand Down

0 comments on commit d9de3e2

Please sign in to comment.