diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2016-01-04 16:00:05 +0100 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2016-02-01 13:58:14 +0100 |
commit | 4c9e549aa3d65c6b8c6b001895904cc82cb81a64 (patch) | |
tree | f85eb3e56b0a6e9a34fa9ea953672237b1e4151a /src/gprs_coding_scheme.cpp | |
parent | 0d05805b7612f5244077aaaa21bb1f28cbf146d9 (diff) |
edge: Add methods and operators to GprsCodingScheme
Add a few new operators and methods to support the use of
GprsCodingScheme instead of the plain integer currently used.
Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/gprs_coding_scheme.cpp')
-rw-r--r-- | src/gprs_coding_scheme.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/gprs_coding_scheme.cpp b/src/gprs_coding_scheme.cpp index 04eb3b6f..a4601039 100644 --- a/src/gprs_coding_scheme.cpp +++ b/src/gprs_coding_scheme.cpp @@ -120,3 +120,59 @@ GprsCodingScheme::HeaderType GprsCodingScheme::headerTypeData() const { return mcs_info[m_scheme].data_hdr; } + +void GprsCodingScheme::inc(Mode mode) +{ + if (!isCompatible(mode)) + /* This should not happen. TODO: Use assert? */ + return; + + Scheme new_cs(Scheme(m_scheme + 1)); + if (!GprsCodingScheme(new_cs).isCompatible(mode)) + /* Clipping, do not change the value */ + return; + + m_scheme = new_cs; +} + +void GprsCodingScheme::dec(Mode mode) +{ + if (!isCompatible(mode)) + /* This should not happen. TODO: Use assert? */ + return; + + Scheme new_cs(Scheme(m_scheme - 1)); + if (!GprsCodingScheme(new_cs).isCompatible(mode)) + /* Clipping, do not change the value */ + return; + + m_scheme = new_cs; +} + +void GprsCodingScheme::inc() +{ + if (isGprs() && m_scheme == CS4) + return; + + if (isEgprs() && m_scheme == MCS9) + return; + + if (!isValid()) + return; + + m_scheme = Scheme(m_scheme + 1); +} + +void GprsCodingScheme::dec() +{ + if (isGprs() && m_scheme == CS1) + return; + + if (isEgprs() && m_scheme == MCS1) + return; + + if (!isValid()) + return; + + m_scheme = Scheme(m_scheme - 1); +} |