123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- #include "stdafx.h"
- #include "PropItem.h"
-
- namespace OTSMODEL {
-
- // CPropItem
- // constructor
- CPropItem::CPropItem()
- {
- // initialization
- Init();
- }
- // copy constructor
- CPropItem::CPropItem(const CPropItem& a_oSource)
- {
- // can't copy itself
- if (&a_oSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(a_oSource);
- }
- CPropItem::CPropItem(CPropItem* a_poSource)
- {
- // input check
- ASSERT(a_poSource);
- if (!a_poSource)
- {
- return;
- }
- // can't copy itself
- if (a_poSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(*a_poSource);
- }
- // =operator
- CPropItem& CPropItem::operator=(const CPropItem& a_oSource)
- {
- // cleanup
- Cleanup();
- // copy the class data over
- Duplicate(a_oSource);
- // return class
- return *this;
- }
- // destructor
- CPropItem::~CPropItem()
- {
- // cleanup
- Cleanup();
- }
- // class function
- // public
- // set sample parameter
- void CPropItem::SetSmplParameter(OTS_SAMPLE_PROP_GRID_ITEMS a_nSmplId, OTS_ITEM_TYPES a_nType, BOOL a_bReadOnly, BOOL a_bShow)
- {
- m_nSmplId = a_nSmplId;
- m_nType = a_nType;
- m_bReadOnly = a_bReadOnly;
- m_bShow = a_bShow;
- }
- // set report parameter
- void CPropItem::SetReportParameter(OTS_RETORT_PROP_GRID_ITEMS a_nReportId, OTS_ITEM_TYPES a_nType, BOOL a_bReadOnly)
- {
- m_nReportId = a_nReportId;
- m_nType = a_nType;
- m_bReadOnly = a_bReadOnly;
- }
-
- // protected
- // cleanup
- void CPropItem::Cleanup()
- {
- }
- // initialization
- void CPropItem::Init()
- {
- m_strName = _T("");
- m_strDescription = _T("");
- m_nSmplId = OTS_SAMPLE_PROP_GRID_ITEMS::INVALID;
- m_nReportId = OTS_RETORT_PROP_GRID_ITEMS::INVALID;
- m_nType = OTS_ITEM_TYPES::INVALID;
- m_bReadOnly = FALSE;
- m_bShow = TRUE;
- }
- // duplication
- void CPropItem::Duplicate(const CPropItem& a_oSource)
- {
- // initialization
- Init();
- // copy data over
- m_strName = a_oSource.m_strName;
- m_strDescription = a_oSource.m_strDescription;
- m_nSmplId = a_oSource.m_nSmplId;
- m_nReportId = a_oSource.m_nReportId;
- m_nType = a_oSource.m_nType;
- m_bReadOnly = a_oSource.m_bReadOnly;
- m_bShow = a_oSource.m_bShow;
- }
- // CPropItemGrp
- CPropItemGrp::CPropItemGrp()
- {
- // initialization
- Init();
- }
- // copy constructor
- CPropItemGrp::CPropItemGrp(const CPropItemGrp& a_oSource)
- {
- // can't copy itself
- if (&a_oSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(a_oSource);
- }
- CPropItemGrp::CPropItemGrp(CPropItemGrp* a_poSource)
- {
- // input check
- ASSERT(a_poSource);
- if (!a_poSource)
- {
- return;
- }
- // can't copy itself
- if (a_poSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(*a_poSource);
- }
- // =operator
- CPropItemGrp& CPropItemGrp::operator=(const CPropItemGrp& a_oSource)
- {
- // cleanup
- Cleanup();
- // copy the class data over
- Duplicate(a_oSource);
- // return class
- return *this;
- }
- // destructor
- CPropItemGrp::~CPropItemGrp()
- {
- // clean up
- Cleanup();
- }
- // class function
- // public
- // items list
- void CPropItemGrp::SetItemsList(CPropItemsList& a_listPropItems)
- {
- m_listPropItems.clear();
- for (auto poPropItem : a_listPropItems)
- {
- CPropItemPtr poPropItemNew(new CPropItem(poPropItem.get()));
- m_listPropItems.push_back(poPropItemNew);
- }
- }
- void CPropItemGrp::GetItemsIdRange(OTS_SAMPLE_PROP_GRID_ITEMS& a_nPropItemIdMin, OTS_SAMPLE_PROP_GRID_ITEMS& a_nPropItemIdMax)
- {
- a_nPropItemIdMin = a_nPropItemIdMax = OTS_SAMPLE_PROP_GRID_ITEMS::INVALID;
- if (m_listPropItems.size() > 0)
- {
- a_nPropItemIdMin = a_nPropItemIdMax = m_listPropItems[0]->GetSmplItemId();
- for (auto poPropItem : m_listPropItems)
- {
- a_nPropItemIdMin = (OTS_SAMPLE_PROP_GRID_ITEMS)min((int)a_nPropItemIdMin, (int)poPropItem->GetSmplItemId());
- a_nPropItemIdMax = (OTS_SAMPLE_PROP_GRID_ITEMS)max((int)a_nPropItemIdMax, (int)poPropItem->GetSmplItemId());
- }
- }
- }
- // protected
- // cleanup
- void CPropItemGrp::Cleanup()
- {
- m_listPropItems.clear();
- }
- // initialization
- void CPropItemGrp::Init()
- {
- m_strName = _T("");
- m_listPropItems.clear();
- }
- // duplication
- void CPropItemGrp::Duplicate(const CPropItemGrp& a_oSource)
- {
- // initialization
- Init();
- // copy data over
- m_strName = a_oSource.m_strName;
- for (auto poPropItem : a_oSource.m_listPropItems)
- {
- CPropItemPtr poPropItemNew(new CPropItem(poPropItem.get()));
- m_listPropItems.push_back(poPropItemNew);
- }
- }
- }
|