Skip to content

Commit

Permalink
Reactivate all GTpo tests.
Browse files Browse the repository at this point in the history
Remove last CamelCase names from GTpo.
Finish removing hEdge support.

Signed-off-by: cneben <benoit@destrat.io>
  • Loading branch information
cneben committed Jun 28, 2018
1 parent f22ac5f commit dc4a806
Show file tree
Hide file tree
Showing 39 changed files with 420 additions and 614 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
**20180628:**

- Upgrade the topology backend to GTpo 3 (a totally refactored GTpo): no major API changes from a user POV.
- Remove all restricted hyper edge support.

**20180602:**

Expand Down
4 changes: 2 additions & 2 deletions GTpo/src/adjacent_behaviour.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class group_adjacent_edges_behaviour : public group_behaviour<config_t>
using shared_group_t = std::shared_ptr<typename config_t::final_group_t>;

using group_t = typename config_t::final_group_t;
using weak_edges_t_search = typename config_t::template search_container_t< weak_edge_t >;
using weak_edges_search_t = typename config_t::template search_container_t< weak_edge_t >;

public:
void node_inserted( weak_node_t& weakNode ) noexcept;
Expand All @@ -86,7 +86,7 @@ class graph_group_adjacent_edges_behaviour : public graph_behaviour< config_t >

using weak_edge_t = std::weak_ptr<typename config_t::final_edge_t>;
using group_t = typename config_t::final_group_t;
using weak_edges_t_search = typename config_t::template search_container_t< weak_edge_t >;
using weak_edges_search_t = typename config_t::template search_container_t< weak_edge_t >;

public:
void edge_inserted( weak_edge_t& weakEdge ) noexcept;
Expand Down
54 changes: 27 additions & 27 deletions GTpo/src/adjacent_behaviour.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ void group_adjacent_edges_behaviour<config_t>::node_inserted( weak_node_t& we
{
shared_node_t node = weakNode.lock();
if ( node ) {
auto group = std::static_pointer_cast<gtpo::group<config_t>>(node->getGroup().lock());
auto group = std::static_pointer_cast<gtpo::group<config_t>>(node->get_group().lock());
if ( group ) {
for ( const auto& inEdge : node->getInEdges() ) // Add all node in/out edges to adjacent edge set
config_t::template container_adapter<weak_edges_t_search>::insert( inEdge, group->getAdjacentEdges() );
for ( const auto& outEdge : node->getOutEdges() )
config_t::template container_adapter<weak_edges_t_search>::insert( outEdge, group->getAdjacentEdges() );
for ( const auto& inEdge : node->get_in_edges() ) // Add all node in/out edges to adjacent edge set
config_t::template container_adapter<weak_edges_search_t>::insert( inEdge, group->get_adjacent_edges() );
for ( const auto& outEdge : node->get_out_edges() )
config_t::template container_adapter<weak_edges_search_t>::insert( outEdge, group->get_adjacent_edges() );
}
}
}
Expand All @@ -57,28 +57,28 @@ void group_adjacent_edges_behaviour<config_t>::node_removed( weak_node_t& wea
{
auto node = weakNode.lock();
if ( node ) {
auto group = std::static_pointer_cast<gtpo::group<config_t>>(node->getGroup().lock());
auto group = std::static_pointer_cast<gtpo::group<config_t>>(node->get_group().lock());
if ( group ) {
// Remove all node in/out edges from group adjacent edge set
// Except if this edge "other" src or dst is still part of the group
for ( const auto& inWeakEdge : node->getInEdges() ) {
for ( const auto& inWeakEdge : node->get_in_edges() ) {
using weak_edge_t = std::weak_ptr<typename config_t::final_edge_t>;
using weak_edges_t_search = typename config_t::template search_container_t< weak_edge_t >;
using weak_edges_search_t = typename config_t::template search_container_t< weak_edge_t >;
auto inEdge = inWeakEdge.lock();
if ( inEdge ) {
auto inEdgeSrc = inEdge->getSrc().lock();
auto inEdgeSrc = inEdge->get_src().lock();
if ( inEdgeSrc &&
inEdgeSrc->getGroup().lock().get() != group.get() )
config_t::template container_adapter<weak_edges_t_search>::remove( inWeakEdge, group->getAdjacentEdges() );
inEdgeSrc->get_group().lock().get() != group.get() )
config_t::template container_adapter<weak_edges_search_t>::remove( inWeakEdge, group->get_adjacent_edges() );
}
}
for ( const auto& outWeakEdge : node->getOutEdges() ) {
for ( const auto& outWeakEdge : node->get_out_edges() ) {
auto outEdge = outWeakEdge.lock();
if ( outEdge ) {
auto outEdgeDst = outEdge->getDst().lock();
auto outEdgeDst = outEdge->get_dst().lock();
if ( outEdgeDst &&
outEdgeDst->getGroup().lock().get() != group.get() )
config_t::template container_adapter<weak_edges_t_search>::remove( outWeakEdge, group->getAdjacentEdges() );
outEdgeDst->get_group().lock().get() != group.get() )
config_t::template container_adapter<weak_edges_search_t>::remove( outWeakEdge, group->get_adjacent_edges() );
}
}
}
Expand All @@ -93,17 +93,17 @@ void graph_group_adjacent_edges_behaviour<config_t>::edge_inserted( weak_edge
auto edge = weakEdge.lock();
if ( edge != nullptr ) {
// If either src or dst is inside a group, add edge to group adjacent edge set
auto src = edge->getSrc().lock();
auto src = edge->get_src().lock();
if ( src != nullptr ) {
auto srcGroup = std::static_pointer_cast<group_t>(src->getGroup().lock());
auto srcGroup = std::static_pointer_cast<group_t>(src->get_group().lock());
if ( srcGroup != nullptr )
config_t::template container_adapter<weak_edges_t_search>::insert( weakEdge, srcGroup->getAdjacentEdges() );
config_t::template container_adapter<weak_edges_search_t>::insert( weakEdge, srcGroup->get_adjacent_edges() );
}
auto dst = edge->getDst().lock();
auto dst = edge->get_dst().lock();
if ( dst != nullptr ) {
auto dstGroup = std::static_pointer_cast<group_t>(dst->getGroup().lock());
auto dstGroup = std::static_pointer_cast<group_t>(dst->get_group().lock());
if ( dstGroup != nullptr )
config_t::template container_adapter<weak_edges_t_search>::insert( weakEdge, dstGroup->getAdjacentEdges() );
config_t::template container_adapter<weak_edges_search_t>::insert( weakEdge, dstGroup->get_adjacent_edges() );
}
}
}
Expand All @@ -114,17 +114,17 @@ void graph_group_adjacent_edges_behaviour<config_t>::edge_removed( weak_edge_
auto edge = weakEdge.lock();
if ( edge ) {
// If either src or dst is inside a group, remove edge from group adjacent edge set
auto src = edge->getSrc().lock();
auto src = edge->get_src().lock();
if ( src != nullptr ) {
auto srcGroup = std::static_pointer_cast<group_t>(src->getGroup().lock());
auto srcGroup = std::static_pointer_cast<group_t>(src->get_group().lock());
if ( srcGroup != nullptr )
config_t::template container_adapter<weak_edges_t_search>::remove( weakEdge, srcGroup->getAdjacentEdges() );
config_t::template container_adapter<weak_edges_search_t>::remove( weakEdge, srcGroup->get_adjacent_edges() );
}
auto dst = edge->getDst().lock();
auto dst = edge->get_dst().lock();
if ( dst != nullptr ) {
auto dstGroup = std::static_pointer_cast<group_t>(dst->getGroup().lock());
auto dstGroup = std::static_pointer_cast<group_t>(dst->get_group().lock());
if ( dstGroup != nullptr )
config_t::template container_adapter<weak_edges_t_search>::remove( weakEdge, dstGroup->getAdjacentEdges() );
config_t::template container_adapter<weak_edges_search_t>::remove( weakEdge, dstGroup->get_adjacent_edges() );
}
}
}
Expand Down
69 changes: 20 additions & 49 deletions GTpo/src/edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,19 @@ class edge : public config_t::edge_base,
{
/*! \name Edge Construction *///-------------------------------------------
//@{
friend graph<config_t>; // graph need access to setGraph()
friend graph<config_t>; // graph need access to set_graph()
public:
using graph_t = graph<config_t>;

using weak_node_t = std::weak_ptr<typename config_t::final_node_t>;
using shared_node_t = std::shared_ptr<typename config_t::final_node_t>;
using weak_node_t = std::weak_ptr<typename config_t::final_node_t>;
using shared_node_t = std::shared_ptr<typename config_t::final_node_t>;

using weak_edge_t = std::weak_ptr<typename config_t::final_edge_t>;
using shared_edge_t = std::shared_ptr<typename config_t::final_edge_t>;
using weak_edge_t = std::weak_ptr<typename config_t::final_edge_t>;
using shared_edge_t = std::shared_ptr<typename config_t::final_edge_t>;

edge() noexcept : config_t::edge_base{} {}
explicit edge( const weak_node_t& src, const weak_node_t& dst ) :
config_t::edge_base{}, _src{ src }, _dst{ dst } { }
explicit edge( const weak_node_t& src, const weak_edge_t& hDst ) :
config_t::edge_base{}, _src{ src }, _hDst{ hDst } { }
~edge() {
if ( _graph != nullptr )
std::cerr << "gtpo::edge<>::~edge(): Warning: an edge has been deleted before beeing " <<
Expand All @@ -96,10 +94,10 @@ class edge : public config_t::edge_base,
edge(const edge& ) = delete;

public:
inline graph_t* getGraph() noexcept { return _graph; }
inline const graph_t* getGraph() const noexcept { return _graph; }
inline graph_t* get_graph() noexcept { return _graph; }
inline const graph_t* get_graph() const noexcept { return _graph; }
private:
void setGraph( graph_t* graph ) { _graph = graph; }
void set_graph( graph_t* graph ) { _graph = graph; }
public:
graph_t* _graph{ nullptr };
//@}
Expand All @@ -109,11 +107,11 @@ class edge : public config_t::edge_base,
//@{
public:
//! Get the edge current serializable property (false=not serializable, for example a control node).
inline auto getSerializable( ) const -> bool { return _serializable; }
//! Shortcut to getSerializable().
inline auto isSerializable( ) const -> bool { return getSerializable(); }
inline auto get_serializable( ) const -> bool { return _serializable; }
//! Shortcut to get_serializable().
inline auto is_serializable( ) const -> bool { return get_serializable(); }
//! Change the edge serializable property (it will not trigger an edge changed call in graph behaviour).
inline auto setSerializable( bool serializable ) -> void { _serializable = serializable; }
inline auto set_serializable( bool serializable ) -> void { _serializable = serializable; }
private:
//! Edge serializable property (default to true ie serializable).
bool _serializable = true;
Expand All @@ -123,42 +121,15 @@ class edge : public config_t::edge_base,
/*! \name Source / Destination Management *///-----------------------------
//@{
public:
inline auto setSrc( weak_node_t src ) noexcept -> void { _src = src; }
inline auto setDst( weak_node_t dst ) noexcept -> void { _dst = dst; }
inline auto getSrc( ) noexcept -> weak_node_t& { return _src; }
inline auto getSrc( ) const noexcept -> const weak_node_t& { return _src; }
inline auto getDst( ) noexcept -> weak_node_t& { return _dst; }
inline auto getDst( ) const noexcept -> const weak_node_t& { return _dst; }
inline auto set_src( weak_node_t src ) noexcept -> void { _src = src; }
inline auto set_dst( weak_node_t dst ) noexcept -> void { _dst = dst; }
inline auto get_src( ) noexcept -> weak_node_t& { return _src; }
inline auto get_src( ) const noexcept -> const weak_node_t& { return _src; }
inline auto get_dst( ) noexcept -> weak_node_t& { return _dst; }
inline auto get_dst( ) const noexcept -> const weak_node_t& { return _dst; }
private:
weak_node_t _src;
weak_node_t _dst;
//@}
//-------------------------------------------------------------------------

/*! \name Restricted Hyper Edge Management *///----------------------------
//@{
public:
using weak_edges_t = typename config_t::template edge_container_t< weak_edge_t >;
using weak_node_ts = typename config_t::template node_container_t< weak_node_t >;

inline auto setHDst( weak_edge_t hDst ) noexcept -> void { _hDst = hDst; }
inline auto getHDst() const noexcept -> const weak_edge_t& { return _hDst; }
inline auto getInHEdges() const noexcept -> const weak_edges_t& { return _inHEdges; }
inline auto addInHEdge( weak_edge_t inHEdge ) -> void;
inline auto removeInHEdge( weak_edge_t inHEdge ) -> void;
inline auto getInHDegree() const noexcept -> int { return static_cast<int>( _inHEdges.size() ); }

inline auto getInHNodes() const noexcept -> const weak_node_ts& { return _inHNodes; }

protected:
inline auto getInHEdges() noexcept -> weak_edges_t& { return _inHEdges; }
private:
//! Restricted hyper edge destination (ie this edge target another edge as destination).
weak_edge_t _hDst;
//! Restricted in hyper edges (ie an in hyper edge with this edge as a destination).
weak_edges_t _inHEdges;
//! Restricted hyper in nodes (ie all source node for in restricted hyper edges).
weak_node_ts _inHNodes;
weak_node_t _src;
weak_node_t _dst;
//@}
//-------------------------------------------------------------------------
};
Expand Down
29 changes: 0 additions & 29 deletions GTpo/src/edge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,5 @@

namespace gtpo { // ::gtpo

/* edge Restricted Hyper Edge Management *///-------------------------------
template <class config_t>
auto edge<config_t>::addInHEdge( weak_edge_t inHEdge ) -> void
{
if ( inHEdge.expired() )
throw gtpo::bad_topology_error( "gtpo::edge<>::addInHEdge(): Error: Input hyper edge is null." );
shared_edge_t inHEdgePtr{ inHEdge.lock() };
if ( inHEdgePtr != nullptr ) {
if ( inHEdgePtr->getHDst().expired() )
inHEdgePtr->setHDst( this->shared_from_this() );
config_t::template container_adapter< weak_edges_t >::insert( inHEdge, _inHEdges );
if ( !inHEdgePtr->getSrc().expired() )
config_t::template container_adapter< weak_node_ts >::insert( inHEdgePtr->getSrc(), _inHNodes );
}
}

template < class config_t >
auto edge<config_t>::removeInHEdge( weak_edge_t inHEdge ) -> void
{
if ( inHEdge.expired() )
return; // Do not throw, removing a null inHEdge let edge in a perfectely valid state
shared_edge_t inHEdgePtr{ inHEdge.lock() };
if ( inHEdgePtr != nullptr ) {
inHEdgePtr->setHDst( shared_edge_t{} );
config_t::template container_adapter< weak_edges_t >::remove( inHEdge, _inHEdges );
config_t::template container_adapter< weak_node_ts >::remove( inHEdgePtr->getSrc(), _inHNodes );
}
}
//-----------------------------------------------------------------------------

} // ::gtpo
Loading

0 comments on commit dc4a806

Please sign in to comment.