-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
280 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/** | ||
@file | ||
@author Alexander Sherikov | ||
@copyright 2017-2024 Alexander Sherikov, Licensed under the Apache License, Version 2.0. | ||
(see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0) | ||
@brief | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "common.h" | ||
|
||
|
||
namespace ariles2 | ||
{ | ||
/// @ingroup aggregate | ||
namespace aggregate | ||
{ | ||
template <class t_Visitor> | ||
class ARILES2_VISIBILITY_ATTRIBUTE ParametersWrapper | ||
{ | ||
public: | ||
typename t_Visitor::Parameters parameters_; | ||
|
||
public: | ||
ParametersWrapper(const bool override_parameters = true) : parameters_(override_parameters) | ||
{ | ||
} | ||
|
||
ParametersWrapper(const typename t_Visitor::Parameters ¶meters) : parameters_(parameters) | ||
{ | ||
} | ||
|
||
template < | ||
class t_IdType, | ||
typename = std::enable_if_t< | ||
std::is_same<t_IdType, t_Visitor>::value | ||
or std::is_base_of<t_IdType, typename t_Visitor::Parameters>::value>> | ||
typename t_Visitor::Parameters &get() | ||
{ | ||
return (parameters_); | ||
} | ||
|
||
template < | ||
class t_IdType, | ||
typename = std::enable_if_t< | ||
std::is_same<t_IdType, t_Visitor>::value | ||
or std::is_base_of<t_IdType, typename t_Visitor::Parameters>::value>> | ||
const typename t_Visitor::Parameters &get() const | ||
{ | ||
return (parameters_); | ||
} | ||
}; | ||
|
||
template <class... t_Visitors> | ||
class ARILES2_VISIBILITY_ATTRIBUTE Parameters; | ||
|
||
template <> | ||
class ARILES2_VISIBILITY_ATTRIBUTE Parameters<> | ||
{ | ||
public: | ||
Parameters(const bool){}; | ||
Parameters(){}; | ||
|
||
void get(){}; | ||
}; | ||
|
||
template <class t_Visitor, class... t_Visitors> | ||
class ARILES2_VISIBILITY_ATTRIBUTE Parameters<t_Visitor, t_Visitors...> : public ParametersWrapper<t_Visitor>, | ||
public Parameters<t_Visitors...> | ||
{ | ||
public: | ||
Parameters(const bool override_parameters = true) | ||
: ParametersWrapper<t_Visitor>(override_parameters), Parameters<t_Visitors...>(override_parameters) | ||
{ | ||
} | ||
|
||
template <class... t_Parameters> | ||
Parameters(const typename t_Visitor::Parameters ¶meters, t_Parameters &&...other_parameters) | ||
: ParametersWrapper<t_Visitor>(parameters) | ||
, Parameters<t_Visitors...>(std::forward<t_Parameters>(other_parameters)...) | ||
{ | ||
} | ||
|
||
template <class t_Parameters> | ||
Parameters(const t_Parameters ¶meters, const bool override_parameters = true) | ||
: ParametersWrapper<t_Visitor>(override_parameters) | ||
, Parameters<t_Visitors...>(parameters, override_parameters) | ||
{ | ||
} | ||
|
||
Parameters(const typename t_Visitor::Parameters ¶meters, const bool override_parameters = true) | ||
: ParametersWrapper<t_Visitor>(parameters), Parameters<t_Visitors...>(override_parameters) | ||
{ | ||
} | ||
|
||
using ParametersWrapper<t_Visitor>::get; | ||
using Parameters<t_Visitors...>::get; | ||
}; | ||
|
||
|
||
|
||
/* | ||
template <class t_Visitor> | ||
class ARILES2_VISIBILITY_ATTRIBUTE BaseVisitorWrapper | ||
{ | ||
public: | ||
t_Visitor visitor_; | ||
public: | ||
BaseVisitorWrapper() {}; | ||
template<class... t_Args> | ||
BaseVisitorWrapper(t_Args &&... args) : visitor_(std::forward<t_Args>(args)...) | ||
{ | ||
} | ||
template <class t_GetVisitor, typename = std::enable_if_t<std::is_same<t_GetVisitor, t_Visitor>::value>> | ||
t_Visitor &get() | ||
{ | ||
return (visitor_); | ||
} | ||
template <class t_GetVisitor, typename = std::enable_if_t<std::is_same<t_GetVisitor, t_Visitor>::value>> | ||
const t_Visitor &get() const | ||
{ | ||
return (visitor_); | ||
} | ||
}; | ||
*/ | ||
|
||
template <class... t_Visitors> | ||
class ARILES2_VISIBILITY_ATTRIBUTE BaseVisitor; | ||
|
||
template <> | ||
class ARILES2_VISIBILITY_ATTRIBUTE BaseVisitor<> | ||
{ | ||
}; | ||
|
||
template <class t_Visitor, class... t_Visitors> | ||
class ARILES2_VISIBILITY_ATTRIBUTE BaseVisitor<t_Visitor, t_Visitors...> : // public BaseVisitorWrapper<t_Visitor>, | ||
public BaseVisitor<t_Visitors...> | ||
{ | ||
}; | ||
|
||
|
||
template <class t_Derived, class... t_Visitors> | ||
class ARILES2_VISIBILITY_ATTRIBUTE Visitor | ||
: public BaseVisitor<t_Visitors...>, | ||
public visitor::Base<t_Derived, Parameters<t_Visitors...>> | ||
{ | ||
public: | ||
using Parameters = aggregate::Parameters<t_Visitors...>; | ||
}; | ||
} // namespace aggregate | ||
} // namespace ariles2 |
Oops, something went wrong.