kaori
A C++ library for barcode extraction and matching
Loading...
Searching...
No Matches
BarcodePool.hpp
Go to the documentation of this file.
1#ifndef KAORI_BARCODE_POOL_HPP
2#define KAORI_BARCODE_POOL_HPP
3
4#include <vector>
5#include <string>
6
13namespace kaori {
14
26
31 BarcodePool(std::vector<const char*> barcode_pool, size_t barcode_length) : pool(std::move(barcode_pool)), length(barcode_length) {}
32
38 BarcodePool(const std::vector<std::string>& barcode_pool) {
39 if (barcode_pool.size()) {
40 length = barcode_pool.front().size();
41 pool.reserve(barcode_pool.size());
42 for (const auto& x : barcode_pool) {
43 if (x.size() != length) {
44 throw std::runtime_error("sequences for a given variable region should be of a constant length");
45 }
46 pool.push_back(x.c_str());
47 }
48 }
49 }
50
54 std::vector<const char*> pool;
55
59 size_t length = 0;
60
64 size_t size() const {
65 return pool.size();
66 }
67
72 const char* operator[](size_t i) const {
73 return pool[i];
74 }
75};
76
77}
78
79#endif
Namespace for the kaori barcode-matching library.
Definition BarcodePool.hpp:13
Pool of barcode sequences for a variable region.
Definition BarcodePool.hpp:21
size_t length
Definition BarcodePool.hpp:59
BarcodePool()
Definition BarcodePool.hpp:25
BarcodePool(std::vector< const char * > barcode_pool, size_t barcode_length)
Definition BarcodePool.hpp:31
size_t size() const
Definition BarcodePool.hpp:64
BarcodePool(const std::vector< std::string > &barcode_pool)
Definition BarcodePool.hpp:38
std::vector< const char * > pool
Definition BarcodePool.hpp:54
const char * operator[](size_t i) const
Definition BarcodePool.hpp:72