class//Nucleotide

由於「轉錄」所以以生物學的DNA轉錄RNA的隱喻命名,DNA的元素正是Nucleotide。
在此是DNA各個元素,記載著人描述量測項目的方式。

在此記錄的各種資訊都是給人看的。
量測點、背景顏色、參數串
運算子的內容,也是配合軟體運作而制作的特殊運算。

最特別的就是參數串,以浪費空間式的各別定義每一個記憶體空間的單獨使用
std::vector<int> m_Parameters;  //裝真正的參數,其中一個或者有用到的位址有值,其它裝-1。
CString m_paraStr;  //描述(每一個參數只有一個描述)

Nucleotide.h 

#ifndef NUCLEOTIDE_H
#define NUCLEOTIDE_H

#include <vector>

enum PointTotal  { Pn1 = 1, ..., NoPn = 999 };
enum ColorType   { NoColor = 0, ..., White, Red, Green, Blue, Dark };
enum ParaOfPara  { PA_FEover = 0, PA_FElength, ..., PA_Max };
enum FEtype      { FT_1overN = 0, FT_Ncm };

class Nucleotide
{
//建解構子
public:
    Nucleotide(const ColorType& _C = NoColor, const PointTotal& _P = NoPn, 
               const int& _N1 = -1, 
               const int& _N2 = -1, 
               const int& _N3 = -1 );
    ~Nucleotide();

//該項目共幾點    
private:
    PointTotal  m_MsrPointTotal;
public:
                void SetMsrPointTotal(const PointTotal& pn);
    const PointTotal GetMsrPointTotal()    const;
    const    CString GetStrMsrPointTotal() const;

//背景顏色
private:
    ColorType m_BkColor;
public:
               void SetBackColor(const ColorType& clr);
    const ColorType GetBackColor()    const;
    const   CString GetStrBackColor() const;

//參數串
private:
             CString m_paraStr;
    std::vector<int> m_Parameters;
public:
             void SetPara(const ParaOfPara&, const int&);
    const     int GetPara(const ParaOfPara&) const;
    const CString GetStrPara() const;

//運算子
    const BOOL operator==(const Nucleotide& vNucl) const;
          void operator= (const Nucleotide& vNucl);
    const BOOL equalMsrPtTotal(const Nucleotide& vCar) const;
    const BOOL equalBackColor(const Nucleotide& vCar) const;
    const BOOL equalParameter(const Nucleotide& vCar) const;

    const CString ShowMe() const;
};
#endif

Nucleotide.cpp

檢查參數

檢查vector長度應該是否相同(必須相同),並且檢查每一個的參數是否相同
參數內容,只好一個一個檢查。降低if裡的邏輯複雜度。
利用enum提高for迴圈的可讀性
const BOOL Nucleotide::equalParameter(const Nucleotide& vCar) const
{
    BOOL b(TRUE);
    if (vCar.m_Parameters.size() == m_Parameters.size())
        for ( int i = 0; i < PA_Max; ++i)
            if (vCar.m_Parameters[i] != m_Parameters[i])
                b = FALSE;
    else
        ASSERT(0);

    return b;
}

文章分類維度