bpp-seq3  3.0.0
NamedContainer.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_NAMEDCONTAINER_H
6 #define BPP_SEQ_CONTAINER_NAMEDCONTAINER_H
7 
8 #include <Bpp/Clonable.h>
9 
10 // From the STL:
11 #include <string>
12 
13 namespace bpp
14 {
21 template<class T>
23  public virtual Clonable
24 {
25 public:
28 
29 protected:
36  virtual const std::shared_ptr<T> getObject(const std::string& name) const = 0;
37 
38  virtual std::shared_ptr<T> getObject(const std::string& name) = 0;
39 
40  virtual const T& object(const std::string& name) const = 0;
41 
42  virtual T& object(const std::string& name) = 0;
43 
52  virtual bool hasObject(const std::string& name) const = 0;
53 
60  virtual std::shared_ptr<T> removeObject(const std::string& name) = 0;
61 
68  virtual void deleteObject(const std::string& name) = 0;
69 
76  virtual std::vector<std::string> getObjectNames() const = 0;
77 
78 public:
85  virtual size_t getSize() const = 0;
86 
91  virtual void clear() = 0;
92 };
93 } // end of namespace bpp.
94 #endif // BPP_SEQ_CONTAINER_NAMEDCONTAINER_H
A Container template for objects that are accessible through names.
virtual std::vector< std::string > getObjectNames() const =0
Get all the names of the objects in the container.
virtual T & object(const std::string &name)=0
virtual bool hasObject(const std::string &name) const =0
Check if a object with a given name is present in the container.
virtual const std::shared_ptr< T > getObject(const std::string &name) const =0
Retrieve an object from the container.
virtual size_t getSize() const =0
Get the number of objects in the container.
virtual const T & object(const std::string &name) const =0
virtual std::shared_ptr< T > removeObject(const std::string &name)=0
Extract and remove a object from the container.
virtual std::shared_ptr< T > getObject(const std::string &name)=0
virtual void clear()=0
Delete all objects in the container.
virtual void deleteObject(const std::string &name)=0
Remove a object from the container.
This alphabet is used to deal NumericAlphabet.