bpp-seq3  3.0.0
AbstractSequenceContainer.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_SEQ_CONTAINER_ABSTRACTSEQUENCECONTAINER_H
6 #define BPP_SEQ_CONTAINER_ABSTRACTSEQUENCECONTAINER_H
7 
8 #include <Bpp/Exceptions.h>
9 
10 #include "../Alphabet/Alphabet.h"
11 #include "../Sequence.h"
12 #include "../Commentable.h"
13 #include "SequenceContainer.h"
14 
15 namespace bpp
16 {
22 template<class SequenceType, class HashType = std::string>
24  public virtual TemplateSequenceContainerInterface<SequenceType, HashType>,
25  public SimpleCommentable
26 {
27 protected:
31  std::shared_ptr<const Alphabet> alphabet_;
32 
33 public:
41  AbstractTemplateSequenceContainer(std::shared_ptr<const Alphabet> alphabet) :
43  {}
44 
53  AbstractTemplateSequenceContainer(std::shared_ptr<const Alphabet> alphabet, const Comments& comments) :
54  SimpleCommentable(comments),
56  {}
57 
60  {}
61 
63  {
65  alphabet_ = sc.alphabet_;
66  return *this;
67  }
68 
77  {}
78 
85  {
86  alphabet_ = sc.getAlphabet();
88 
89  return *this;
90  }
91 
93 
94 public:
95  const Alphabet& alphabet() const override
96  {
97  if (!alphabet_) throw Exception("AbstractSequenceContainer::alphabet() : no associated alphabet.");
98  return *alphabet_;
99  }
100 
101  std::shared_ptr<const Alphabet> getAlphabet() const override { return alphabet_; }
102 };
103 } // end of namespace bpp.
104 #endif // BPP_SEQ_CONTAINER_ABSTRACTSEQUENCECONTAINER_H
Partial implementation of the SequenceContainer interface.
std::shared_ptr< const Alphabet > alphabet_
The container's alphabet.
AbstractTemplateSequenceContainer & operator=(const AbstractTemplateSequenceContainer< SequenceType, HashType > &sc)
AbstractTemplateSequenceContainer(const TemplateSequenceContainerInterface< SequenceType, HashType > &sc)
Copy constructor from any SequenceContainer object.
AbstractTemplateSequenceContainer & operator=(const TemplateSequenceContainerInterface< SequenceType, HashType > &sc)
Assignation operator from any SequenceContainer object.
AbstractTemplateSequenceContainer(std::shared_ptr< const Alphabet > alphabet, const Comments &comments)
This constructor initializes the alphabet pointer and the comments field.
AbstractTemplateSequenceContainer(std::shared_ptr< const Alphabet > alphabet)
This constructor initializes the alphabet pointer.
const Alphabet & alphabet() const override
Get the container's alphabet.
std::shared_ptr< const Alphabet > getAlphabet() const override
Get a pointer toward the container's alphabet.
AbstractTemplateSequenceContainer(const AbstractTemplateSequenceContainer< SequenceType, HashType > &sc)
The Alphabet interface.
Definition: Alphabet.h:99
virtual const Comments & getComments() const =0
Get the comments.
const Comments & getComments() const override
Get the comments.
Definition: Commentable.h:79
SimpleCommentable & operator=(const SimpleCommentable &com)
Definition: Commentable.h:65
void setComments(const Comments &comments) override
Set the comments.
Definition: Commentable.h:86
The SequenceContainer interface.
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
Get a pointer toward the container's alphabet.
This alphabet is used to deal NumericAlphabet.
std::vector< std::string > Comments
Declaration of Comments type.
Definition: Commentable.h:21