Skip to content

Commit

Permalink
Merge branch 'refactor/polishing'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikRafacz committed Jan 19, 2021
2 parents 0b3d5ba + 6cfcf8b commit 32d2074
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 156 deletions.
8 changes: 4 additions & 4 deletions inst/include/tidysq/ProtoSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ namespace tidysq {

template<typename INTERNAL, typename PROTO>
class ProtoSequence {
typename TypeBinder<INTERNAL, PROTO>::ProtoSequenceContentStorageType content_;
typename util::TypeBinder<INTERNAL, PROTO>::ProtoSequenceContentStorageType content_;
public:
typedef typename PROTO::ProtoSequenceElementType ElementType;
typedef typename TypeBinder<INTERNAL, PROTO>::ProtoSequenceContentStorageType ContentStorageType;
typedef typename TypeBinder<INTERNAL, PROTO>::ProtoSequenceContentAccessType AccessType;
typedef typename TypeBinder<INTERNAL, PROTO>::ProtoSequenceContentConstAccessType ConstAccessType;
typedef typename util::TypeBinder<INTERNAL, PROTO>::ProtoSequenceContentStorageType ContentStorageType;
typedef typename util::TypeBinder<INTERNAL, PROTO>::ProtoSequenceContentAccessType AccessType;
typedef typename util::TypeBinder<INTERNAL, PROTO>::ProtoSequenceContentConstAccessType ConstAccessType;

explicit ProtoSequence(const ContentStorageType &content) :
content_(content) {};
Expand Down
4 changes: 2 additions & 2 deletions inst/include/tidysq/ProtoSequenceInputInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace tidysq {
template<typename INTERNAL, typename PROTO, bool SIMPLE>
class ProtoSequenceInputInterpreter {
typedef typename TypeBinder<INTERNAL, PROTO>::ProtoSequenceContentStorageType ContentStorageType;
typedef typename util::TypeBinder<INTERNAL, PROTO>::ProtoSequenceContentStorageType ContentStorageType;
typedef typename PROTO::ProtoSequenceElementType ElementType;
typedef typename ContentStorageType::const_iterator ContentConstIteratorType;

Expand Down Expand Up @@ -85,7 +85,7 @@ namespace tidysq {

template<typename INTERNAL>
class ProtoSequenceInputInterpreter<INTERNAL, STRING_PT, false> {
typedef typename TypeBinder<INTERNAL, STRING_PT>::ProtoSequenceContentStorageType ContentStorageType;
typedef typename util::TypeBinder<INTERNAL, STRING_PT>::ProtoSequenceContentStorageType ContentStorageType;
typedef ElementStringMultichar ElementType;
typedef typename ContentStorageType::const_iterator ContentConstIteratorType;

Expand Down
4 changes: 2 additions & 2 deletions inst/include/tidysq/ProtoSq.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ namespace tidysq {

template<typename INTERNAL, typename PROTO>
class ProtoSq {
typename TypeBinder<INTERNAL, PROTO>::ProtoSqContentStorageType content_;
typename util::TypeBinder<INTERNAL, PROTO>::ProtoSqContentStorageType content_;
Alphabet alphabet_;
public:
typedef ProtoSequence<INTERNAL, PROTO> ElementType;
typedef typename TypeBinder<INTERNAL, PROTO>::ProtoSqContentStorageType ContentStorageType;
typedef typename util::TypeBinder<INTERNAL, PROTO>::ProtoSqContentStorageType ContentStorageType;

ProtoSq(const ContentStorageType &content, const Alphabet &alphabet) :
content_(content),
Expand Down
32 changes: 16 additions & 16 deletions inst/include/tidysq/Proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace tidysq {
template<typename INTERNAL, typename PROTO, bool PACKED, bool CONST>
struct AccessTypeToElementMapper {
inline static auto map(
typename UniversalTypeBinder<INTERNAL, PROTO, PACKED, CONST>::ProtoOrNotSqContentAccessType element_access
) -> typename UniversalTypeBinder<INTERNAL, PROTO, PACKED, CONST>::ProtoOrNotSequenceType {
typename util::UniversalTypeBinder<INTERNAL, PROTO, PACKED, CONST>::ProtoOrNotSqContentAccessType element_access
) -> typename util::UniversalTypeBinder<INTERNAL, PROTO, PACKED, CONST>::ProtoOrNotSequenceType {
return element_access;
}
};
Expand All @@ -22,18 +22,18 @@ namespace tidysq {
template<typename PROTO, bool CONST>
struct AccessTypeToElementMapper<RCPP_IT, PROTO, IS_UNPACKED, CONST> {
inline static auto map(
typename UniversalTypeBinder<RCPP_IT, PROTO, IS_UNPACKED, CONST>::ProtoOrNotSqContentAccessType element_access
) -> typename UniversalTypeBinder<RCPP_IT, PROTO, IS_UNPACKED, CONST>::ProtoOrNotSequenceType {
typename util::UniversalTypeBinder<RCPP_IT, PROTO, IS_UNPACKED, CONST>::ProtoOrNotSqContentAccessType element_access
) -> typename util::UniversalTypeBinder<RCPP_IT, PROTO, IS_UNPACKED, CONST>::ProtoOrNotSequenceType {
return tidysq::ProtoSequence<RCPP_IT, PROTO>(
typename TypeBinder<RCPP_IT, PROTO>::ProtoSequenceContentStorageType(element_access));
typename util::TypeBinder<RCPP_IT, PROTO>::ProtoSequenceContentStorageType(element_access));
}
};

template<typename PROTO, bool CONST>
struct AccessTypeToElementMapper<RCPP_IT, PROTO, IS_PACKED, CONST> {
inline static auto map(
typename UniversalTypeBinder<RCPP_IT, PROTO, IS_PACKED, CONST>::ProtoOrNotSqContentAccessType element_access
) -> typename UniversalTypeBinder<RCPP_IT, PROTO, IS_PACKED, CONST>::ProtoOrNotSequenceType {
typename util::UniversalTypeBinder<RCPP_IT, PROTO, IS_PACKED, CONST>::ProtoOrNotSqContentAccessType element_access
) -> typename util::UniversalTypeBinder<RCPP_IT, PROTO, IS_PACKED, CONST>::ProtoOrNotSequenceType {
Rcpp::RawVector ret(element_access);
return tidysq::Sequence<RCPP_IT>(ret, Rcpp::IntegerVector(ret.attr("original_length"))[0]);
}
Expand All @@ -42,8 +42,8 @@ namespace tidysq {
template<typename INTERNAL, typename PROTO, bool PACKED>
struct AccessTypeAssigner {
inline static void assign(
typename UniversalTypeBinder<INTERNAL, PROTO, PACKED, IS_NONCONST>::ProtoOrNotSqContentAccessType &element_access,
typename UniversalTypeBinder<INTERNAL, PROTO, PACKED, IS_NONCONST>::ProtoOrNotSequenceType element
typename util::UniversalTypeBinder<INTERNAL, PROTO, PACKED, IS_NONCONST>::ProtoOrNotSqContentAccessType &element_access,
typename util::UniversalTypeBinder<INTERNAL, PROTO, PACKED, IS_NONCONST>::ProtoOrNotSequenceType element
) {
element_access = element;
}
Expand All @@ -52,8 +52,8 @@ namespace tidysq {
template<typename PROTO>
struct AccessTypeAssigner<RCPP_IT, PROTO, IS_PACKED> {
inline static void assign(
typename UniversalTypeBinder<RCPP_IT, PROTO, IS_PACKED, IS_NONCONST>::ProtoOrNotSqContentAccessType &element_access,
typename UniversalTypeBinder<RCPP_IT, PROTO, IS_PACKED, IS_NONCONST>::ProtoOrNotSequenceType element
typename util::UniversalTypeBinder<RCPP_IT, PROTO, IS_PACKED, IS_NONCONST>::ProtoOrNotSqContentAccessType &element_access,
typename util::UniversalTypeBinder<RCPP_IT, PROTO, IS_PACKED, IS_NONCONST>::ProtoOrNotSequenceType element
) {
Rcpp::RawVector content = element.content();
content.attr("original_length") = element.original_length();
Expand All @@ -64,18 +64,18 @@ namespace tidysq {
template<typename PROTO>
struct AccessTypeAssigner<RCPP_IT, PROTO, IS_UNPACKED> {
inline static void assign(
typename UniversalTypeBinder<RCPP_IT, PROTO, IS_UNPACKED, IS_NONCONST>::ProtoOrNotSqContentAccessType &element_access,
typename UniversalTypeBinder<RCPP_IT, PROTO, IS_UNPACKED, IS_NONCONST>::ProtoOrNotSequenceType element
typename util::UniversalTypeBinder<RCPP_IT, PROTO, IS_UNPACKED, IS_NONCONST>::ProtoOrNotSqContentAccessType &element_access,
typename util::UniversalTypeBinder<RCPP_IT, PROTO, IS_UNPACKED, IS_NONCONST>::ProtoOrNotSequenceType element
) {
element_access = element.content();
}
};

template<typename INTERNAL, typename PROTO, bool PACKED, bool CONST>
class BasicElementProxy {
typedef typename UniversalTypeBinder<INTERNAL, PROTO, PACKED, CONST>::ProtoOrNotSqContentAccessType ElementAccessType;
typedef typename UniversalTypeBinder<INTERNAL, PROTO, PACKED, CONST>::ProtoOrNotSequenceType ElementType;
typedef typename UniversalTypeBinder<INTERNAL, PROTO, PACKED, CONST>::ProtoOrNotSqType ContainerType;
typedef typename util::UniversalTypeBinder<INTERNAL, PROTO, PACKED, CONST>::ProtoOrNotSqContentAccessType ElementAccessType;
typedef typename util::UniversalTypeBinder<INTERNAL, PROTO, PACKED, CONST>::ProtoOrNotSequenceType ElementType;
typedef typename util::UniversalTypeBinder<INTERNAL, PROTO, PACKED, CONST>::ProtoOrNotSqType ContainerType;

ElementAccessType contained_element_access_;

Expand Down
12 changes: 6 additions & 6 deletions inst/include/tidysq/Rcpp-import.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ namespace tidysq {
ignore_case);
}

inline Sq<RCPP_IT> import_from_R(const Rcpp::List &sq,
const Letter &NA_letter = constants::DEFAULT_NA_LETTER) {
inline Sq<RCPP_IT> import_sq_from_R(const Rcpp::List &sq,
const Letter &NA_letter = constants::DEFAULT_NA_LETTER) {
if (!sq.hasAttribute("alphabet")) throw std::invalid_argument("Sq object should have 'alphabet' attribute.");
Rcpp::StringVector alphabet = sq.attr("alphabet");
return Sq<RCPP_IT>(sq, import_alphabet_from_R(alphabet, NA_letter));
}

template<typename PROTO>
ProtoSq<RCPP_IT, PROTO> import_proto_from_R(const typename ProtoSq<RCPP_IT, PROTO>::ContentStorageType &proto,
const Rcpp::StringVector &alphabet,
const Letter &NA_letter = constants::DEFAULT_NA_LETTER,
const bool &ignore_case = constants::DEFAULT_IGNORE_CASE) {
ProtoSq<RCPP_IT, PROTO> import_proto_sq_from_R(const typename ProtoSq<RCPP_IT, PROTO>::ContentStorageType &proto,
const Rcpp::StringVector &alphabet,
const Letter &NA_letter = constants::DEFAULT_NA_LETTER,
const bool &ignore_case = constants::DEFAULT_IGNORE_CASE) {
return ProtoSq<RCPP_IT, PROTO>(proto,
import_alphabet_from_R(alphabet, NA_letter, ignore_case));
}
Expand Down
2 changes: 1 addition & 1 deletion inst/include/tidysq/internal/obtain_alphabet.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace tidysq::internal {
}

template<typename INTERNAL, bool SIMPLE>
std::set<Letter> obtain_alphabet(const typename TypeBinder<INTERNAL, STRING_PT>::ProtoSqListConstructorType &x,
std::set<Letter> obtain_alphabet(const typename util::TypeBinder<INTERNAL, STRING_PT>::ProtoSqListConstructorType &x,
const LenSq sample_size,
const Letter &NA_letter,
const bool ignore_case) {
Expand Down
Loading

0 comments on commit 32d2074

Please sign in to comment.