本文整理汇总了C++中CDiskObjectPtr类的典型用法代码示例。如果您正苦于以下问题:C++ CDiskObjectPtr类的具体用法?C++ CDiskObjectPtr怎么用?C++ CDiskObjectPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CDiskObjectPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIconID
///////////////////////////////////////////////////////////////////////////////
// CUnitDiskUIHandler
///////////////////////////////////////////////////////////////////////////////
UINT CUnitDiskUIHandler::GetIconID(CDiskObjectPtr obj) const
{
ATLASSERT(dynamic_cast<CUnitDiskObject*>(obj.get()) != NULL);
CUnitDiskObjectPtr unitDisk =
boost::dynamic_pointer_cast<CUnitDiskObject>(obj);
CUnitDiskInfoHandlerPtr handler = unitDisk->GetInfoHandler();
if ( !obj->IsUsable() )
return IDI_ND_BADKEY;
if ( handler->IsHDD() )
{
if ( handler->IsBound() )
{
if ( handler->IsMaster() )
{
return IDI_ND_INUSE;
}
else
{
return IDI_ND_SLAVE;
}
}
else
{
return IDI_ND_INUSE;
}
}
else
{
// TODO : We need a new icon for this type(DVD, FLASH, MO.. ETC)
return IDI_ND_INUSE;
}
}
示例2: RebindMirror
void CMirrorWorkThread::RebindMirror()
{
// Get list of disks involved in the previous mirroring.
// NOTE : Because disks aggregated can also be mirrored,
// there can be more than two disks involved in the mirroring.
CDiskObjectPtr aggregationRoot;
aggregationRoot = m_pSource->GetParent();
while ( !aggregationRoot->GetParent()->IsRoot() )
{
aggregationRoot = aggregationRoot->GetParent();
}
// Mark all the bitmaps dirty.
m_pSource->OpenExclusive();
m_pDest->OpenExclusive();
m_pSource->MarkAllBitmap();
CUnitDiskInfoHandlerPtr pHandler = m_pSource->GetInfoHandler();
aggregationRoot->Rebind(
m_pDest,
pHandler->GetPosInBind() ^ 0x01
);
aggregationRoot->CommitDiskInfo(TRUE);
// Write binding information to the destination disk
m_pDest->Mirror(m_pSource);
m_pDest->CommitDiskInfo(TRUE);
m_bRebound = TRUE;
m_pSource->Close();
m_pDest->Close();
}
示例3: ENTER_CRITICAL_SECTION
void CMainFrame::OnCommand(UINT /*wNotifyCode*/, int wID, HWND /*hwndCtl*/)
{
ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);
// Commands which do not change the tree are sent to the object directly.
CTreeItem itemSelected = m_view.GetSelectedItem();
if ( itemSelected.IsNull() )
{
LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
return;
}
CDiskObjectPtr obj;
const CObjectUIHandler *phandler;
obj = m_mapObject[m_view.GetItemData(itemSelected)];
ATLASSERT( obj.get() != NULL );
phandler = CObjectUIHandler::GetUIHandler( obj );
phandler->OnCommand( obj, wID );
m_view.UpdateDiskObject( obj );
OnSelChanged(NULL);
LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
}
示例4: AddChild
///////////////////////////////////////////////////////////////////////////////
// CDiskObjectComposite
///////////////////////////////////////////////////////////////////////////////
void CDiskObjectComposite::AddChild(CDiskObjectPtr _this, CDiskObjectPtr child)
{
ATLASSERT( this == _this.get() );
child->SetParent(_this);
CDiskObjectList::push_back(child);
}
示例5: Visit
void CNBTreeView::Visit(CDiskObjectPtr o)
{
const CObjectUIHandler *pHandler = CObjectUIHandler::GetUIHandler(o);
switch ( m_nAction )
{
case NDASBINDVIEW_INSERT_OBJECT:
{
m_htiLast = CTreeViewCtrlEx::InsertItem(
pHandler->GetTitle(o),
pHandler->GetIconIndex(o),
pHandler->GetSelectedIconIndex(o),
m_htiParent,
TVI_LAST
);
m_htiLast.SetData( o->GetUniqueID() );
m_mapIDToTreeItem[o->GetUniqueID()] = m_htiLast;
Expand(m_htiParent, TVE_EXPAND);
}
break;
case NDASBINDVIEW_UPDATE_OBJECT:
{
CTreeItem htiUpdate = m_mapIDToTreeItem[o->GetUniqueID()];
htiUpdate.SetText( pHandler->GetTitle(o) );
htiUpdate.SetImage(
pHandler->GetIconIndex(o),
pHandler->GetSelectedIconIndex(o)
);
}
}
};
示例6: OnGetDispInfo
LRESULT CNBBindListViewCtrl::OnGetDispInfo(LPNMHDR lParam)
{
NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(lParam);
CDiskObjectPtr obj;
const CObjectUIHandler *phandler;
obj = m_mapObject[static_cast<UINT>(pDispInfo->item.lParam)];
ATLASSERT( obj.get() != NULL );
phandler = CObjectUIHandler::GetUIHandler( obj );
switch ( pDispInfo->item.iSubItem )
{
case 0: // Index
::_stprintf(
pDispInfo->item.pszText,
_T("%d"),
pDispInfo->item.iItem
);
break;
case 1: // Name
::_tcsncpy(
pDispInfo->item.pszText,
obj->GetTitle(),
pDispInfo->item.cchTextMax-1
);
break;
case 2: // ID
/*
::_tcsncpy(
pDispInfo->item.pszText,
phandler->GetStringID( obj ),
pDispInfo->item.cchTextMax-1
);
break;
case 3: // Size
*/
{
WTL::CString strSize;
strSize.FormatMessage(
IDS_LISTVIEW_SIZE_IN_GB,
phandler->GetSizeInMB( obj ) / 1024,
(phandler->GetSizeInMB( obj ) % 1024) / 10
);
::_tcsncpy(
pDispInfo->item.pszText,
strSize,
pDispInfo->item.cchTextMax-1
);
}
default:
break;
}
pDispInfo->item.pszText[pDispInfo->item.cchTextMax-1] = '\0';
return 0;
}
示例7: GetCommandSet
///////////////////////////////////////////////////////////////////////////////
// CUnsupportedDiskUIHandler
///////////////////////////////////////////////////////////////////////////////
CCommandSet CUnsupportedDiskUIHandler::GetCommandSet(CDiskObjectPtr obj) const
{
ATLASSERT( dynamic_cast<CUnitDiskObject*>(obj.get()) != NULL);
CCommandSet setCommand;
setCommand.push_back ( CCommand( IDM_TOOL_CLEARDIB,
(obj->GetAccessMask() & GENERIC_WRITE)
)
);
return setCommand;
}
示例8: OnClearDIB
BOOL CUnsupportedDiskUIHandler::OnClearDIB(CDiskObjectPtr obj) const
{
ATLASSERT( dynamic_cast<CUnitDiskObject*>(obj.get()) != NULL);
WTL::CString strWarning;
strWarning.FormatMessage(
IDS_UIHANDLER_CLEARDIB_CONFIRM,
obj->GetTitle()
);
WTL::CString strTitle;
strTitle.LoadString(IDS_APPLICATION);
if ( MessageBox(::GetFocus(), strWarning, strTitle, MB_YESNO | MB_ICONWARNING) != IDYES )
{
return TRUE;
}
CUnitDiskObjectPtr unitDisk =
boost::dynamic_pointer_cast<CUnitDiskObject>(obj);
if ( !unitDisk->CanAccessExclusive() )
{
WTL::CString strMsg;
strMsg.LoadString( IDS_FAIL_TO_ACCESS_EXCLUSIVELY );
MessageBox(
::GetFocus(),
strMsg,
strTitle,
MB_OK | MB_ICONWARNING
);
return TRUE;
}
try {
unitDisk->Open( TRUE );
unitDisk->Initialize( unitDisk );
unitDisk->CommitDiskInfo();
unitDisk->Close();
}
catch( CNDASException & )
{
unitDisk->Close();
WTL::CString strMsg;
strMsg.LoadString ( IDS_UIHANDLER_CLEARDIB_FAIL );
MessageBox(
::GetFocus(),
strMsg,
strTitle,
MB_OK | MB_ICONERROR
);
return TRUE;
}
WTL::CString strMsg;
strMsg.LoadString( IDS_UIHANDLER_CLEARDIB_SUCCESS );
return TRUE;
}
示例9: DeleteDiskObject
void CNBListViewCtrl::DeleteDiskObject(CDiskObjectPtr o)
{
int nItemCount = CListViewCtrl::GetItemCount();
for (int i=0; i < nItemCount; i++ )
{
if ( GetItemData(i) == o->GetUniqueID() )
{
CListViewCtrl::DeleteItem( i );
break;
}
}
m_mapObject.erase( o->GetUniqueID() );
}
示例10: Initialize
void CUnitDiskObject::Initialize(CDiskObjectPtr _this)
{
ATLASSERT( this == _this.get() );
m_pHandler->Initialize(
boost::dynamic_pointer_cast<CUnitDiskObject>(_this)
);
}
示例11: UnBind
CDiskObjectList CLanUnitDiskObject::UnBind(CDiskObjectPtr _this)
{
ATLASSERT( this == _this.get() );
CDiskObjectList listUnbound;
// If the disk is aggregated, the MBR block of the disk should be cleaned
// to prevent unexpected behavior of disks after unbinding.
CDataSector dataSector( SECTOR_MBR_COUNT );
dataSector.SetLocation( 0 );
if ( m_pHandler->IsBoundAndNotSingleMirrored() )
{
try{
dataSector.WriteAccept( &m_session );
}
catch( CNDASException &e )
{
NDAS_THROW_EXCEPTION_CHAIN_STR(
CDiskException,
CDiskException::ERROR_FAIL_TO_INITIALIZE,
_T("Fail to clean MBR"),
e);
}
}
// Clear bind information
m_pHandler->UnBind(
boost::dynamic_pointer_cast<CUnitDiskObject>(_this)
);
listUnbound.push_back(_this);
return listUnbound;
}
示例12: GetSizeInMB
UINT CObjectUIHandler::GetSizeInMB(CDiskObjectPtr obj) const
{
_int64 nSize;
nSize = obj->GetUserSectorCount() / ( 1024 / NDAS_BLOCK_SIZE ) / 1024;
/* KB per sector */ /* MB per KB */
return static_cast<UINT>(nSize);
}
示例13: FindDiskObjectItem
int CNBListViewCtrl::FindDiskObjectItem(CDiskObjectPtr o)
{
LVFINDINFO info;
info.flags = LVFI_PARAM;
info.lParam = o->GetUniqueID();
return CListViewCtrl::FindItem(&info, -1);
}
示例14: InsertDiskObject
void CNBTreeView::InsertDiskObject(CDiskObjectPtr o, CDiskObjectPtr parent)
{
if ( parent.get() == NULL )
{
m_htiParent = TVI_ROOT;
m_htiLast = m_htiParent;
}
else
{
m_htiParent = m_mapIDToTreeItem[parent->GetUniqueID()];
if ( m_htiParent.IsNull() )
m_htiParent = TVI_ROOT;
m_htiLast = m_htiParent;
}
m_nAction = NDASBINDVIEW_INSERT_OBJECT;
o->Accept( o, this );
}
示例15: ATLASSERT
BOOL CRAID4DiskUIHandler::OnRecover(CDiskObjectPtr obj) const
{
ATLASSERT( dynamic_cast<CRAID4DiskObject*>(obj.get()) != NULL );
CRAID4DiskObjectPtr raid4Disk =
boost::dynamic_pointer_cast<CRAID4DiskObject>(obj);
if(!raid4Disk->IsDirty())
{
WTL::CString strMsg;
strMsg.LoadString(IDS_WARNING_NOT_NEED_RECOVER );
WTL::CString strTitle;
strTitle.LoadString(IDS_APPLICATION);
MessageBox(
::GetFocus(),
strMsg,
strTitle,
MB_OK | MB_ICONERROR
);
return TRUE;
}
std::list<CDiskObjectPtr>::iterator it;
CUnitDiskObjectPtr pUnitDisk;
it = raid4Disk->begin();
INT32 iDirty;
for(iDirty = raid4Disk->GetDirtyDisk(); iDirty > 0; iDirty--)
it++;
pUnitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*it);
CRecoverDlg dlgRecover(FALSE, IDS_LOGDEV_TYPE_DISK_RAID4, IDS_RECOVERDLG_TASK_RECOVER);
dlgRecover.SetMemberDevice(pUnitDisk);
dlgRecover.DoModal();
CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
BOOL bResults = HixChangeNotify.Initialize();
if(bResults)
{
NDAS_UNITDEVICE_ID unitDeviceId;
for(it = raid4Disk->begin(); it != raid4Disk->end(); ++it)
{
pUnitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*it);
CopyMemory(unitDeviceId.DeviceId.Node,
pUnitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
sizeof(unitDeviceId.DeviceId.Node));
unitDeviceId.UnitNo =
pUnitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
HixChangeNotify.Notify(unitDeviceId);
}
}
return TRUE;
}