Skip to content
Snippets Groups Projects
Commit d5628da3 authored by Raghunandan Netrapalli Madhusudhan's avatar Raghunandan Netrapalli Madhusudhan
Browse files

Remove obselete files

parent e32ac083
No related branches found
No related tags found
No related merge requests found
Pipeline #70690 passed
/********************************************************************************
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
#pragma once
//! \file
//! \brief Function object used to tell a search node graph in what order it should be traversed
#include <set>
#include "Node.h"
#include "OsiQueryLibrary/Types/Enum.h" // Traversal
#include "OsiQueryLibrary/Utility/Compare.h"
namespace osiql {
//! Function object that can be passed to Node methods
//! to determine in what order its successor nodes are traversed.
//!
//! It maintains a set of nodes and pops the first element when invoked.
//! The nodes returned by the given selector are added to the queue.
//! If there are no elements left in the queue, a nullptr is returned.
//!
//! \tparam Comparator How the upcoming nodes are ordered
//! \tparam T Traversal direction of the traversed nodes
//! \tparam Scope Lane or Road. Scope of the traversed nodes
template <typename Comparator, Traversal T = Traversal::Forward, typename Scope = Road>
struct NextNode
{
constexpr NextNode(const Node<T, Scope> &root);
template <typename Selector = ConnectedNodes<T>>
const Node<T, Scope> *operator()(Selector && = {});
private:
std::set<const Node<T, Scope> *, Comparator> queue;
};
//! Function object that compares the depth of two nodes when invoked.
//! In the case of equality, their pointer addresses are compared.
//!
//! \tparam Comparator Binary functor such as std::less<> or std::greater<>
template <typename Comparator>
struct CompareDepth
{
template <Traversal T, typename Scope>
constexpr bool operator()(const Node<T, Scope> *, const Node<T, Scope> *) const;
};
//! Function object that compares the end distance of two nodes when invoked.
//! In the case of equality, their pointer addresses are compared.
//!
//! \tparam Comparator Binary functor such as std::less<> or std::greater<>
template <typename Comparator>
struct CompareEndDistance
{
template <Traversal T, typename Scope>
constexpr bool operator()(const Node<T, Scope> *, const Node<T, Scope> *) const;
};
namespace detail {
template <Order>
struct NextNodeComparator;
template <>
struct NextNodeComparator<Order::BreadthFirst>
{
using type = CompareDepth<std::less<>>;
};
template <>
struct NextNodeComparator<Order::DepthFirst>
{
using type = CompareDepth<std::greater<>>;
};
template <>
struct NextNodeComparator<Order::MinDistance>
{
using type = CompareEndDistance<std::less<>>;
};
template <>
struct NextNodeComparator<Order::MaxDistance>
{
using type = CompareEndDistance<std::greater<>>;
};
} // namespace detail
//! The corresponding comparator type to the given search node graph traversal value
//!
//! \tparam Order The type of traversal
template <Order O>
using NextNodeComparator = typename detail::NextNodeComparator<O>::type;
} // namespace osiql
/********************************************************************************
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
#pragma once
#include "NextNode.h"
#include "Node.h"
namespace osiql {
template <typename Comparator, Traversal T, typename Scope>
constexpr NextNode<Comparator, T, Scope>::NextNode(const Node<T, Scope> &root) :
queue{&root}
{
}
template <typename Comparator, Traversal T, typename Scope>
template <typename Selector>
const Node<T, Scope> *NextNode<Comparator, T, Scope>::operator()(Selector &&selector)
{
if (queue.empty())
{
return nullptr;
}
const auto iterator{queue.begin()};
const Node<T, Scope> *node{*iterator};
queue.erase(iterator);
for (const auto &child : selector(*node))
{
queue.emplace(child.get());
}
return node;
}
template <typename Comparator>
template <Traversal T, typename Scope>
constexpr bool CompareDepth<Comparator>::operator()(const Node<T, Scope> *a, const Node<T, Scope> *b) const
{
if (a->depth == b->depth)
{
return a < b;
}
return Comparator{}(a->depth, b->depth);
}
template <typename Comparator>
template <Traversal T, typename Scope>
constexpr bool CompareEndDistance<Comparator>::operator()(const Node<T, Scope> *a, const Node<T, Scope> *b) const
{
const double endDistanceA{a->distance + a->GetLength()};
const double endDistanceB{b->distance + b->GetLength()};
if (endDistanceA == endDistanceB)
{
return a < b;
}
return Comparator{}(endDistanceA, endDistanceB);
}
} // namespace osiql
/********************************************************************************
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
#pragma once
//! \file
//! \brief Adds the function objects ConnectedNodes which returns the connected nodes of the node it is
//! invoked on, and NextNode, which is used to tell a node graph in what order it should be traversed
#include <set>
#include "OsiQueryLibrary/Types/Enum.h" // Traversal
#include "OsiQueryLibrary/Utility/Compare.h"
#include "OsiQueryLibrary/Utility/Get.tpp"
namespace osiql {
template <Traversal, typename>
struct Node;
struct Depth
{
};
OSIQL_SET_RETURN_TYPE(Depth, size_t)
OSIQL_GET(Depth, depth, GetDepth());
//! Function object returning the connected nodes of a given node when invoked.
//!
//! \tparam Traversal The direction of the connection
template <Traversal, typename Predicate = Return<true>>
struct ConnectedNodes
{
//! Returns the connected nodes of the given node that satisfy this class's predicates
//!
//! \tparam T Traversal direction of the give node
//! \tparam Scope Lane or Road. The scope of the given node
//! \return Vector of shared pointers of constant nodes. Reference if this class has no predicates
template <Traversal T, typename Scope>
constexpr decltype(auto) operator()(const Node<T, Scope> &) const;
Predicate predicate;
};
//! Function object that can be passed to Node methods
//! to determine in what order its successor nodes are traversed.
//!
//! It maintains a set of nodes and pops the first element when invoked.
//! The nodes returned by the given selector are added to the queue.
//! If there are no elements left in the queue, a nullptr is returned.
//!
//! \tparam Comparator How the upcoming nodes are ordered. Receives two Node pointers
//! and returns whether the first compares as less than the second.
//! \tparam NodeType A node with a certain traversal direction and scope type
template <typename Comparator, typename NodeType>
struct NextNode
{
const NodeType *operator()();
template <typename Nodes>
const NodeType *operator()(Nodes &&);
private:
std::set<const NodeType *, Comparator> queue;
};
} // namespace osiql
/********************************************************************************
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
#pragma once
#include "Utilities.h"
#include "Node.h"
namespace osiql {
template <Traversal X, typename Predicate>
template <Traversal T, typename Scope>
constexpr decltype(auto) ConnectedNodes<X, Predicate>::operator()(const Node<T, Scope> &node) const
{
return node.template GetConnectedNodes<X>(predicate);
}
template <typename Comparator, typename NodeType>
const NodeType *NextNode<Comparator, NodeType>::operator()()
{
if (queue.empty())
{
return nullptr;
}
const auto iterator{queue.begin()};
const NodeType *node{*iterator};
queue.erase(iterator);
return node;
}
template <typename Comparator, typename NodeType>
template <typename Nodes>
const NodeType *NextNode<Comparator, NodeType>::operator()(Nodes &&nodes)
{
for (const auto &node : nodes)
{
queue.emplace(&get<NodeType>(node));
}
return this->operator()();
}
} // namespace osiql
/********************************************************************************
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
#pragma once
#include "OsiQueryLibrary/Utility/Get.tpp"
#include "OsiQueryLibrary/Utility/Has.h"
namespace osiql {
//! An association between two types paired with a distance
//! denoting where that association occurs
//!
//! \tparam T
//! \tparam U
template <typename T, typename U>
struct Relation : Aggregate<const T *, const U *>
{
Relation(Aggregate<const T *, const U *>, double);
template <typename A, typename B, REQUIRES(std::is_constructible_v<Aggregate<const T *, const U *>, const A *, const B *>)>
Relation(const A &a, const B &b, double distance) :
Aggregate<const T *, const U *>{&a, &b}, distance{distance}
{
}
double distance;
};
template <typename T1, typename U1, typename T2, typename U2>
constexpr bool operator<(const Relation<T1, U1> &, const Relation<T2, U2> &);
template <typename T1, typename U1, typename T2, typename U2>
constexpr bool operator==(const Relation<T1, U1> &, const Relation<T2, U2> &);
template <typename T1, typename U1, typename T2, typename U2>
constexpr bool operator>(const Relation<T1, U1> &, const Relation<T2, U2> &);
} // namespace osiql
namespace osiql {
template <typename T, typename U>
Relation<T, U>::Relation(Aggregate<const T *, const U *> aggregate, double distance) :
Aggregate<const T *, const U *>{aggregate}, distance{distance}
{
}
template <typename T1, typename U1, typename T2, typename U2>
constexpr bool operator<(const Relation<T1, U1> &a, const Relation<T2, U2> &b)
{
return a.distance < b.distance;
}
template <typename T1, typename U1, typename T2, typename U2>
constexpr bool operator==(const Relation<T1, U1> &a, const Relation<T2, U2> &b)
{
return (a.template Get<T1>() == b.template Get<T2>()) && (a.template Get<U1>() == b.template Get<U2>());
}
template <typename T1, typename U1, typename T2, typename U2>
constexpr bool operator>(const Relation<T1, U1> &a, const Relation<T2, U2> &b)
{
return a.distance < b.distance;
}
} // namespace osiql
/********************************************************************************
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
#pragma once
#include "Aggregate.h"
namespace osiql {
//! Function object that returns whether an input
//! satisfies all of this object's predicates
//!
//! \tparam Predicate Invocable with signature bool(const auto&&) const
template <typename... Predicate>
struct Conjunction : Aggregate<Predicate...>
{
using Aggregate<Predicate...>::Aggregate;
//! Returns whether each predicate satisfies the given input.
//! Terminates as soon as a predicate returns false.
//!
//! \tparam Value
//! \return Whether each predicate satisfies the given input.
template <typename Value>
constexpr bool operator()(Value &&) const;
};
//! Function object that returns whether an input
//! satisfies any of this object's predicates
//!
//! \tparam Predicate Invocable with signature bool(const auto&&) const
template <typename... Predicate>
struct Disjunction : Aggregate<Predicate...>
{
using Aggregate<Predicate...>::Aggregate;
//! Returns whether any predicate satisfies the given input.
//! Terminates as soon as a predicate returns true.
//!
//! \tparam Value
//! \return Whether any predicate satisfies the given input.
template <typename Value>
constexpr bool operator()(Value &&) const;
};
} // namespace osiql
/********************************************************************************
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
#pragma once
#include "Expression.h"
namespace osiql {
template <typename... Predicate>
template <typename Value>
constexpr bool Conjunction<Predicate...>::operator()(Value &&value) const
{
return (Has<Predicate>::template Get<Predicate>()(value) && ...);
}
template <typename... Predicate>
template <typename Value>
constexpr bool Disjunction<Predicate...>::operator()(Value &&value) const
{
return (Has<Predicate>::template Get<Predicate>()(value) || ...);
}
} // namespace osiql
/********************************************************************************
* Copyright (c) 2023-2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
#pragma once
#include "XYZ.h"
#include "Common.h"
#include "Is.h"
namespace osiql {
template <size_t I, typename T>
constexpr decltype(auto) At(const T &t)
{
if constexpr (I == 0)
{
return X{}(t);
}
else if constexpr (I == 1)
{
return Y{}(t);
}
else if constexpr (I == 2)
{
return Z{}(t);
}
else
{
return 0.0;
}
}
template <typename T>
constexpr size_t Dimensions()
{
return Is<X>::in<T> ? Is<Y>::in<T> ? Is<Z>::in<T> ? 3 : 2 : 1 : 0;
}
template <typename T>
constexpr size_t Dimensions(const T &)
{
return Dimensions<T>();
}
} // namespace osiql
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment