Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test linking issues on Windows #10

Merged
merged 6 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

find_package(ament_cmake_python REQUIRED)
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_ros REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcutils)
find_package(builtin_interfaces REQUIRED)
find_package(sensor_msgs REQUIRED)

include_directories(include)
add_library(${PROJECT_NAME} SHARED src/connection.cpp)
add_library(${PROJECT_NAME} src/connection.cpp)
if(WIN32)
target_compile_definitions(${PROJECT_NAME}
PRIVATE "MESSAGE_FILTERS_BUILDING_DLL")
endif()
target_include_directories(${PROJECT_NAME} PUBLIC include)

ament_target_dependencies(${PROJECT_NAME}
"rclcpp"
"rcutils"
Expand All @@ -34,8 +39,8 @@ install(
)

install(
DIRECTORY "include/"
DESTINATION include
DIRECTORY "include/"
DESTINATION include
)

find_package(python_cmake_module REQUIRED)
Expand All @@ -62,7 +67,6 @@ if(BUILD_TESTING)
target_link_libraries(${PROJECT_NAME}-test_simple ${PROJECT_NAME})
endif()


ament_add_gtest(${PROJECT_NAME}-msg_cache_unittest test/msg_cache_unittest.cpp)
if(TARGET ${PROJECT_NAME}-msg_cache_unittest)
target_link_libraries(${PROJECT_NAME}-msg_cache_unittest ${PROJECT_NAME})
Expand Down
26 changes: 12 additions & 14 deletions include/message_filters/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/

#ifndef MESSAGE_FILTERS_CACHE_H_
#define MESSAGE_FILTERS_CACHE_H_
#ifndef MESSAGE_FILTERS__CACHE_H_
#define MESSAGE_FILTERS__CACHE_H_

#include <deque>
#include <memory>
#include <functional>

#include <rclcpp/rclcpp.hpp>

#include "connection.h"
#include "simple_filter.h"
#include "message_traits.h"
#include "message_filters/connection.h"
#include "message_filters/simple_filter.h"
#include "message_filters/message_traits.h"

namespace message_filters
{
Expand Down Expand Up @@ -208,13 +208,13 @@ class Cache : public SimpleFilter<M>

std::lock_guard<std::mutex> lock(cache_lock_);
// Find the starting index. (Find the first index after [or at] the start of the interval)
unsigned int start_index = cache_.size()-1;
size_t start_index = cache_.size() - 1;
while(start_index > 0 &&
mt::TimeStamp<M>::value(*cache_[start_index].getMessage()) > start)
{
start_index--;
}
unsigned int end_index = start_index;
size_t end_index = start_index;
while(end_index < cache_.size()-1 &&
mt::TimeStamp<M>::value(*cache_[end_index].getMessage()) < end)
{
Expand All @@ -223,7 +223,7 @@ class Cache : public SimpleFilter<M>

std::vector<MConstPtr> interval_elems;
interval_elems.reserve(end_index - start_index + 1) ;
for (unsigned int i=start_index; i<=end_index; i++)
for (size_t i=start_index; i<=end_index; i++)
{
interval_elems.push_back(cache_[i].getMessage()) ;
}
Expand Down Expand Up @@ -272,12 +272,12 @@ class Cache : public SimpleFilter<M>

MConstPtr out ;

int i=cache_.size()-1 ;
size_t i=cache_.size()-1 ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes the condition in the while loop (i>=0) obsolete. When cache_ is empty a rollover would occur.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll go back and verify anywhere that I made signedness changes.

int elem_index = -1 ;
while (i>=0 &&
mt::TimeStamp<M>::value(*cache_[i].getMessage()) > time)
{
elem_index = i ;
elem_index = static_cast<int>(i) ;
i-- ;
}

Expand Down Expand Up @@ -336,8 +336,6 @@ class Cache : public SimpleFilter<M>

Connection incoming_connection_;
};
} // namespace message_filters;

}


#endif /* MESSAGE_FILTERS_CACHE_H_ */
#endif // MESSAGE_FILTERS__CACHE_H_
16 changes: 8 additions & 8 deletions include/message_filters/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/

#ifndef MESSAGE_FILTERS_CHAIN_H
#define MESSAGE_FILTERS_CHAIN_H

#include "simple_filter.h"
#include "pass_through.h"
#ifndef MESSAGE_FILTERS__CHAIN_H
#define MESSAGE_FILTERS__CHAIN_H

#include <vector>

#include "message_filters/simple_filter.h"
#include "message_filters/pass_through.h"

namespace message_filters
{
/**
Expand Down Expand Up @@ -165,7 +165,7 @@ class Chain : public ChainBase, public SimpleFilter<M>
filter->connectInput(*filters_.back().passthrough);
}

uint32_t count = filters_.size();
size_t count = filters_.size();
filters_.push_back(info);
return count;
}
Expand Down Expand Up @@ -249,6 +249,6 @@ class Chain : public ChainBase, public SimpleFilter<M>
Connection incoming_connection_;
Connection last_filter_connection_;
};
}
} // namespace message_filters

#endif // MESSAGE_FILTERS_CHAIN_H
#endif // MESSAGE_FILTERS__CHAIN_H_
23 changes: 12 additions & 11 deletions include/message_filters/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/

#ifndef MESSAGE_FILTERS_CONNECTION_H
#define MESSAGE_FILTERS_CONNECTION_H
#ifndef MESSAGE_FILTERS__CONNECTION_H_
#define MESSAGE_FILTERS__CONNECTION_H_

#include <functional>
#include <memory>
#include "macros.h"

#include "message_filters/visibility_control.h"

namespace message_filters
{
Expand All @@ -54,24 +55,24 @@ class noncopyable
/**
* \brief Encapsulates a connection from one filter to another (or to a user-specified callback)
*/
class MESSAGE_FILTERS_DECL Connection
class Connection
{
public:
typedef std::function<void(void)> VoidDisconnectFunction;
typedef std::function<void(const Connection&)> WithConnectionDisconnectFunction;
Connection() {}
Connection(const VoidDisconnectFunction& func);
using VoidDisconnectFunction = std::function<void(void)>;
using WithConnectionDisconnectFunction = std::function<void(const Connection&)>;
MESSAGE_FILTERS_PUBLIC Connection() {}
MESSAGE_FILTERS_PUBLIC Connection(const VoidDisconnectFunction& func);

/**
* \brief disconnects this connection
*/
void disconnect();
MESSAGE_FILTERS_PUBLIC void disconnect();

private:
VoidDisconnectFunction void_disconnect_;
WithConnectionDisconnectFunction connection_disconnect_;
};

}
} // namespace message_filters

#endif // MESSAGE_FILTERS_CONNECTION_H
#endif // MESSAGE_FILTERS__CONNECTION_H_
44 changes: 0 additions & 44 deletions include/message_filters/macros.h

This file was deleted.

11 changes: 6 additions & 5 deletions include/message_filters/message_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef RCLCPP_MESSAGE_EVENT_H
#define RCLCPP_MESSAGE_EVENT_H
#ifndef MESSAGE_FILTERS__MESSAGE_EVENT_H_
#define MESSAGE_FILTERS__MESSAGE_EVENT_H_

#include <rclcpp/rclcpp.hpp>
#include <type_traits>
#include <memory>

#include <rclcpp/rclcpp.hpp>

#ifndef RCUTILS_ASSERT
// TODO(tfoote) remove this after it's implemented upstream
// https://github.com/ros2/rcutils/pull/112
Expand Down Expand Up @@ -235,7 +236,7 @@ class MessageEvent

template<typename M> const std::string MessageEvent<M>::s_unknown_publisher_string_("unknown_publisher");

} // namespace message_filters

}
#endif // MESSAGE_FILTERS__MESSAGE_EVENT_H_

#endif // RCLCPP_MESSAGE_EVENT_H
12 changes: 7 additions & 5 deletions include/message_filters/message_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef ROSLIB_MESSAGE_TRAITS_H
#define ROSLIB_MESSAGE_TRAITS_H
#ifndef MESSAGE_FILTERS__MESSAGE_TRAITS_H_
#define MESSAGE_FILTERS__MESSAGE_TRAITS_H_

#include <type_traits>

#include <rclcpp/rclcpp.hpp>

namespace message_filters
Expand Down Expand Up @@ -67,7 +68,8 @@ struct TimeStamp<M, typename std::enable_if<HasHeader<M>::value>::type >
}
};

} // namespace message_traits
} // namespace message_filters
} // namespace message_traits
} // namespace message_filters

#endif // MESSAGE_FILTERS__MESSAGE_TRAITS_H_

#endif // ROSLIB_MESSAGE_TRAITS_H
17 changes: 9 additions & 8 deletions include/message_filters/null_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/

#ifndef MESSAGE_FILTERS_NULL_TYPES_H
#define MESSAGE_FILTERS_NULL_TYPES_H
#ifndef MESSAGE_FILTERS__NULL_TYPES_H_
#define MESSAGE_FILTERS__NULL_TYPES_H_

#include "connection.h"
#include <memory>

#include "message_filters/message_traits.h"
#include <rclcpp/rclcpp.hpp>
#include <memory>

#include "message_filters/connection.h"
#include "message_filters/message_traits.h"

namespace message_filters
{
Expand Down Expand Up @@ -75,7 +76,7 @@ struct TimeStamp<message_filters::NullType>
return rclcpp::Time();
}
};
}
}
} // namespace message_traits
} // namespace message_filters

#endif // MESSAGE_FILTERS_NULL_TYPES_H
#endif // MESSAGE_FILTERS__NULL_TYPES_H_
11 changes: 6 additions & 5 deletions include/message_filters/parameter_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef MESSAGE_FILTERS_PARAMETER_ADAPTER_H
#define MESSAGE_FILTERS_PARAMETER_ADAPTER_H
#ifndef MESSAGE_FILTERS__PARAMETER_ADAPTER_H_
#define MESSAGE_FILTERS__PARAMETER_ADAPTER_H_

#include "message_event.h"
#include <memory>
#include <type_traits>

#include "message_filters/message_event.h"

namespace message_filters
{

Expand Down Expand Up @@ -173,6 +174,6 @@ struct ParameterAdapter<const MessageEvent<M>& >
}
};

}
} // namespace message_filters

#endif // MESSAGE_FILTERS_PARAMETER_ADAPTER_H
#endif // MESSAGE_FILTERS__PARAMETER_ADAPTER_H_
12 changes: 6 additions & 6 deletions include/message_filters/pass_through.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/

#ifndef MESSAGE_FILTERS_PASSTHROUGH_H
#define MESSAGE_FILTERS_PASSTHROUGH_H

#include "simple_filter.h"
#ifndef MESSAGE_FILTERS__PASS_THROUGH_H_
#define MESSAGE_FILTERS__PASS_THROUGH_H_

#include <vector>

#include "message_filters/simple_filter.h"

namespace message_filters
{
/**
Expand Down Expand Up @@ -87,6 +87,6 @@ class PassThrough : public SimpleFilter<M>
Connection incoming_connection_;
};

} // namespace message_filters
} // namespace message_filters

#endif // MESSAGE_FILTERS_PASSTHROUGH_H
#endif // MESSAGE_FILTERS__PASS_THROUGH_H_
Loading