2018-11-29 01:41:36 +01:00
|
|
|
/* -*- c++ -*- */
|
|
|
|
/*
|
|
|
|
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018, Libre Space Foundation <http://librespacefoundation.org/>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_SATNOGS_SHIFT_REG_H
|
|
|
|
#define INCLUDED_SATNOGS_SHIFT_REG_H
|
|
|
|
|
|
|
|
#include <satnogs/api.h>
|
|
|
|
#include <deque>
|
2018-12-03 00:42:14 +01:00
|
|
|
#include <ostream>
|
|
|
|
|
2019-09-12 15:25:10 +02:00
|
|
|
namespace gr {
|
|
|
|
namespace satnogs {
|
2018-11-29 01:41:36 +01:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Implements a bit shift register
|
|
|
|
*
|
|
|
|
*/
|
2019-09-12 15:25:10 +02:00
|
|
|
class SATNOGS_API shift_reg {
|
2018-11-29 01:41:36 +01:00
|
|
|
public:
|
2019-09-12 15:25:10 +02:00
|
|
|
shift_reg(size_t len);
|
|
|
|
~shift_reg();
|
2018-11-29 01:41:36 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
reset();
|
|
|
|
|
|
|
|
void
|
|
|
|
set();
|
|
|
|
|
|
|
|
size_t
|
|
|
|
len() const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
size() const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
count();
|
|
|
|
|
|
|
|
shift_reg
|
2019-09-12 15:25:10 +02:00
|
|
|
operator|(const shift_reg &rhs);
|
2018-11-29 01:41:36 +01:00
|
|
|
|
|
|
|
shift_reg
|
2019-09-12 15:25:10 +02:00
|
|
|
operator&(const shift_reg &rhs);
|
2018-11-29 01:41:36 +01:00
|
|
|
|
|
|
|
shift_reg
|
2019-09-12 15:25:10 +02:00
|
|
|
operator^(const shift_reg &rhs);
|
2018-11-29 01:41:36 +01:00
|
|
|
|
2019-09-12 15:25:10 +02:00
|
|
|
shift_reg &
|
2018-11-29 01:41:36 +01:00
|
|
|
operator>>=(bool bit);
|
|
|
|
|
2019-09-12 15:25:10 +02:00
|
|
|
bool &
|
2018-11-29 01:41:36 +01:00
|
|
|
operator[](size_t pos);
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator[](size_t pos) const;
|
|
|
|
|
2019-09-12 15:25:10 +02:00
|
|
|
shift_reg &
|
2018-11-29 01:41:36 +01:00
|
|
|
operator<<=(bool bit);
|
|
|
|
|
|
|
|
void
|
|
|
|
push_front(bool bit);
|
|
|
|
|
|
|
|
void
|
|
|
|
push_back(bool bit);
|
|
|
|
|
|
|
|
bool
|
|
|
|
front();
|
|
|
|
|
|
|
|
bool
|
|
|
|
back();
|
|
|
|
|
2019-09-12 15:25:10 +02:00
|
|
|
friend std::ostream &
|
|
|
|
operator<<(std::ostream &os, const shift_reg ®);
|
2018-11-29 01:41:36 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
const size_t d_len;
|
|
|
|
std::deque<bool> d_reg;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace satnogs
|
|
|
|
} // namespace gr
|
|
|
|
|
|
|
|
#endif /* INCLUDED_SATNOGS_SHIFT_REG_H */
|
|
|
|
|