本文整理汇总了C++中CAutoPtr类的典型用法代码示例。如果您正苦于以下问题:C++ CAutoPtr类的具体用法?C++ CAutoPtr怎么用?C++ CAutoPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAutoPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Add
void CPacketQueue::Add(CAutoPtr<Packet> p)
{
CAutoLock cAutoLock(this);
if(p)
{
m_size += p->GetDataSize();
if(p->bAppendable && !p->bDiscontinuity && !p->pmt
&& p->rtStart == Packet::INVALID_TIME
&& !IsEmpty() && GetTail()->rtStart != Packet::INVALID_TIME)
{
Packet* tail = GetTail();
int oldsize = tail->GetCount();
int newsize = tail->GetCount() + p->GetCount();
tail->SetCount(newsize, max(1024, newsize)); // doubles the reserved buffer size
memcpy(tail->GetData() + oldsize, p->GetData(), p->GetCount());
/*
GetTail()->Append(*p); // too slow
*/
return;
}
}
AddTail(p);
}
示例2: cAutoLockF
HRESULT CBaseSplitterFilter::DeleteOutputs()
{
m_rtDuration = 0;
m_pRetiredOutputs.RemoveAll();
CAutoLock cAutoLockF(this);
if(m_State != State_Stopped) return VFW_E_NOT_STOPPED;
while(m_pOutputs.GetCount())
{
CAutoPtr<CBaseSplitterOutputPin> pPin = m_pOutputs.RemoveHead();
if(IPin* pPinTo = pPin->GetConnected()) pPinTo->Disconnect();
pPin->Disconnect();
// we can't just let it be deleted now, something might have AddRefed on it (graphedit...)
m_pRetiredOutputs.AddTail(pPin);
}
CAutoLock cAutoLockPM(&m_csPinMap);
m_pPinMap.RemoveAll();
CAutoLock cAutoLockMT(&m_csmtnew);
m_mtnew.RemoveAll();
RemoveAll();
ResRemoveAll();
ChapRemoveAll();
m_fontinst.UninstallFonts();
m_pSyncReader.Release();
return S_OK;
}
示例3: TAG_METHOD_IMPL
TAG_METHOD_IMPL(CWSDLBindingParser, OnOperation)
{
TRACE_PARSE_ENTRY();
CWSDLBinding * pCurr = GetBinding();
if (pCurr != NULL)
{
CAutoPtr<CWSDLPortTypeOperation> spElem;
spElem.Attach( new CWSDLPortTypeOperation );
if (spElem != NULL)
{
SetXMLElementInfo(spElem, pCurr, GetLocator());
CAutoPtr<CWSDLOperationParser> p( new CWSDLOperationParser(GetReader(), this, GetLevel(), spElem) );
if (p)
{
if (g_ParserList.AddHead(p) != NULL)
{
if (SUCCEEDED(p.Detach()->GetAttributes(pAttributes)))
{
if (pCurr->AddOperation(spElem) != NULL)
{
spElem.Detach();
return S_OK;
}
}
}
}
}
}
EmitErrorHr(E_OUTOFMEMORY);
return E_FAIL;
}
示例4: eav_get_packet
int CEASpliterFilter::eav_get_packet( int size)
{
AVPacket *pkt = (AVPacket *)m_pkt;
//int ret= av_new_packet(pkt, size);
//if(ret<0)
// return ret;
pkt->pos= m_pFile->GetPos();//url_ftell(s);
//ret= m_pFile->ByteRead( pkt->data, size);
//get_buffer(s, pkt->data, size);
//if(ret<=0)
// av_free_packet(pkt);
//else{
pkt->size= size;
CAutoPtr<Packet> p;
p.Attach(new Packet());
p->TrackNumber = pkt->stream_index;
p->rtStart = pkt->pts;
p->rtStop = p->rtStart + pkt->duration;
p->bSyncPoint = pkt->flags;
p->SetCount(size);
m_pFile->ByteRead(p->GetData(), p->GetCount());
HRESULT hr = DeliverPacket(p);
//}
return (hr == S_OK);
}
示例5: OPCException
void COPCItem::getProperties(const CAtlArray<CPropertyDescription> &propsToRead, ATL::CAutoPtrArray<SPropertyValue> &propsRead){
unsigned noProperties = (DWORD)propsToRead.GetCount();
VARIANT *pValues = NULL;
HRESULT *pErrors = NULL;
DWORD *pPropertyIDs = new DWORD[noProperties];
for (unsigned i = 0; i < noProperties; i++){
pPropertyIDs[i] = propsToRead.GetAt(i).id;
}
propsRead.RemoveAll();
propsRead.SetCount(noProperties);
USES_CONVERSION;
HRESULT res = group.getServer().getPropertiesInterface()->GetItemProperties(T2OLE(name), noProperties, pPropertyIDs, &pValues, &pErrors);
delete []pPropertyIDs;
if (FAILED(res)){
throw OPCException("Failed to restrieve property values", res);
}
for (unsigned i = 0; i < noProperties; i++){
CAutoPtr<SPropertyValue> v;
if (!FAILED(pErrors[i])){
v.Attach(new SPropertyValue(propsToRead[i], pValues[i]));
}
propsRead[i]=v;
}
COPCClient::comFree(pErrors);
COPCClient::comFreeVariant(pValues, noProperties);
}
示例6: SendKey
bool CDVDSession::SendKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData)
{
CAutoPtr<DVD_COPY_PROTECT_KEY> key;
switch (KeyType) {
case DvdChallengeKey:
key.Attach((DVD_COPY_PROTECT_KEY*)DEBUG_NEW BYTE[DVD_CHALLENGE_KEY_LENGTH]);
key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
Reverse(key->KeyData, pKeyData, 10);
break;
case DvdBusKey2:
key.Attach((DVD_COPY_PROTECT_KEY*)DEBUG_NEW BYTE[DVD_BUS_KEY_LENGTH]);
key->KeyLength = DVD_BUS_KEY_LENGTH;
Reverse(key->KeyData, pKeyData, 5);
break;
default:
break;
}
if (!key) {
return false;
}
key->SessionId = m_session;
key->KeyType = KeyType;
key->KeyFlags = 0;
DWORD BytesReturned;
return !!DeviceIoControl(m_hDrive, IOCTL_DVD_SEND_KEY, key, key->KeyLength, NULL, 0, &BytesReturned, NULL);
}
示例7: cAutoLock
CAutoPtr<Packet> CPacketQueue::Remove()
{
CAutoLock cAutoLock(this);
ASSERT(__super::GetCount() > 0);
CAutoPtr<Packet> p = RemoveHead();
if(p) m_size -= p->GetDataSize();
return p;
}
示例8: ReadTestPRES2
void ReadTestPRES2()
{
unsigned long dwTotalTickCount = KLSTD::GetSysTickCount();
KLPRES_CreateEventsStorageServer(
L"Test server",
L"Test product",
L"Test version",
L"c:\\test\\jrnl\\slowdata\\events.xml",
L"c:\\test\\jrnl\\slowdata\\events" );
printf( "\nPRES Server created, %d msec...", KLSTD::GetSysTickCount() - dwTotalTickCount );
//ComponentId compId( L"Test product", L"5.0.0.0", L"", L"Test instance" );
CAutoPtr<EventsStorage> pEventsStorage;
KLPRES_CreateEventsStorageProxy( L"Test server",
ComponentId(),
ComponentId(),
& pEventsStorage,
true );
printf( "\nPRES Proxy created, %d msec...", KLSTD::GetSysTickCount() - dwTotalTickCount );
printf( "\nStart to iterate subscriptions..." );
pEventsStorage->ResetSubscriptionsIterator( ComponentId() );
int nSubscr = 0;
int nPausedSubscr = 0;
std::wstring sID;
vector<wstring> vectPausedSubscr;
do
{
CPointer<SubscriptionInfo> pSI;
if (! pEventsStorage->GetNextSubscription( & pSI, sID) ) break;
nSubscr++;
if( pSI->bPaused )
{
vectPausedSubscr.push_back( sID );
nPausedSubscr++;
}
printf( "\n...%ls, paused: %d", sID.c_str(), int(pSI->bPaused) );
}
while(true);
printf( "\nFinish, %d msec, %d subscriptions, %d paused...",
KLSTD::GetSysTickCount() - dwTotalTickCount,
nSubscr,
nPausedSubscr );
//pEventsStorage->ResumeSubscription( vectPausedSubscr[10] );
/* for( int i = 0; i < vectPausedSubscr.size(); i++ )
{
pEventsStorage->ResumeSubscription( vectPausedSubscr[i] );
pEventsStorage->PauseSubscription( vectPausedSubscr[i] );
} */
}
示例9: Child
CAutoPtr<CMatroskaNode> CMatroskaNode::GetFirstBlock()
{
CAutoPtr<CMatroskaNode> pNode = Child();
do {
if (pNode->m_id == 0xA0 || pNode->m_id == 0xA3) {
return pNode;
}
} while (pNode->Next());
return CAutoPtr<CMatroskaNode>();
}
示例10: AddValue
void AddValue(
KLPAR::Params* pParams,
KLPAR::ValuesFactory* pFactory,
std::wstring& strName,
std::wstring& strVal)
{
CAutoPtr<KLPAR::StringValue> pValue;
pFactory->CreateStringValue(&pValue);
pValue->SetValue(strVal.c_str());
pParams->AddValue(strName, pValue);
};
示例11: get_saveflag
void get_saveflag(Params* pParams, bool& bSaveFlag)
{
CAutoPtr<IntValue> pIntValue;
pParams->GetValue(c_szwSyncType, (Value**)&pIntValue);
KLPAR_CHKTYPE(pIntValue, INT_T, c_szwSyncType);
if(pIntValue->GetValue() != 3)
KLSTD_THROW(STDE_CANCELED);
CAutoPtr<BoolValue> pSaveFlag;
pParams->GetValue(c_szwSyncSaveFlag, (Value**)&pSaveFlag);
KLPAR_CHKTYPE(pSaveFlag, BOOL_T, c_szwSyncSaveFlag);
bSaveFlag=pSaveFlag->GetValue();
};
示例12: AddNodes
static void AddNodes(Params* pParams, ValuesFactory* pFactory, int nLevels, int nVars, int nNodes, long *pSum)
{
AddVars(pParams, pFactory, nVars, pSum);
if(nLevels > 0){
for(int i=0; i < nNodes; ++i){
CAutoPtr<ParamsValue> pParamsValue;
pFactory->CreateParamsValue(&pParamsValue);
pParams->AddValue(genRandString(8), pParamsValue);
if(pSum)++(*pSum);
AddNodes(pParamsValue->GetValue(), pFactory, nLevels-1, nVars, nNodes, pSum);
};
};
};
示例13: put_sections
static void put_sections(sections_list_t& sections, Params** ppParams, bool bEOF)
{
KL_TMEASURE_BEGIN(L"put_sections", 4)
KLPAR_CreateParams(ppParams);
CAutoPtr<ValuesFactory> pFactory;
KLPAR_CreateValuesFactory(&pFactory);
CAutoPtr<IntValue> pIntValue;
KLPAR::CreateValue(2, &pIntValue);
CAutoPtr<ArrayValue> pArray;
pFactory->CreateArrayValue(&pArray);
(*ppParams)->AddValue(c_szwSyncType, pIntValue);
(*ppParams)->AddValue(c_szwSyncSections, pArray);
{
CAutoPtr<BoolValue> pEOF;
KLPAR::CreateValue(bEOF, &pEOF);
(*ppParams)->AddValue(c_szwSyncEOF, pEOF);
};
pArray->SetSize(sections.size());
int i=0;
for(sections_list_t::iterator it=sections.begin(); it!=sections.end(); ++it, ++i)
{
section_data_t& sec=*it;
CAutoPtr<Params> pTmpParams;
KLPAR_CreateParams(&pTmpParams);
{
CAutoPtr<ParamsValue> pParamsValue;
KLPAR::CreateValue(pTmpParams, &pParamsValue);
pArray->SetAt(i, pParamsValue);
};
CAutoPtr<StringValue> pProduct, pVersion, pSection;
CAutoPtr<IntValue> pAction;
CAutoPtr<ParamsValue> pContents;
CAutoPtr<Params> pContentsParams;
if(sec.pContents)
sec.pContents->Clone(&pContentsParams);//@todo really need clone ?
KLPAR::CreateValue(sec.wstrProduct.c_str(), &pProduct);
KLPAR::CreateValue(sec.wstrVersion.c_str(), &pVersion);
KLPAR::CreateValue(sec.wstrSection.c_str(), &pSection);
KLPAR::CreateValue((long)sec.nAction, &pAction);
KLPAR::CreateValue(pContentsParams, &pContents);
;
pTmpParams->AddValue(c_szwSyncProduct, pProduct);
pTmpParams->AddValue(c_szwSyncVersion, pVersion);
pTmpParams->AddValue(c_szwSyncSection, pSection);
pTmpParams->AddValue(c_szwSyncAction, pAction);
pTmpParams->AddValue(c_szwSyncContents, pContents);
};
KL_TMEASURE_END()
};
示例14: howLongWaitMs
void CSplashScreen::hide()
{
if (m_nDelay<=0 || m_startTime.toULong() == 0)
return;
long nWaitMs = howLongWaitMs();
m_startTime = CTimeInterval();
if ( nWaitMs <= 0 )
return;
CAutoPtr<IRhoClassFactory> ptrFactory = createClassFactory();
CAutoPtr<IRhoThreadImpl> ptrThread = ptrFactory->createThreadImpl();
ptrThread->sleep(nWaitMs);
}
示例15: ParsePage
HRESULT CDVBSub::ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtr<DVB_PAGE>& pPage)
{
HRESULT hr = S_OK;
WORD wEnd = (WORD)gb.GetPos() + wSegLength;
int nPos = 0;
pPage.Attach (DNew DVB_PAGE());
pPage->PageTimeOut = gb.ReadByte();
pPage->PageVersionNumber = (BYTE)gb.BitRead(4);
pPage->PageState = (BYTE)gb.BitRead(2);
pPage->RegionCount = 0;
gb.BitRead(2); // Reserved
while (gb.GetPos() < wEnd)
{
if (nPos < MAX_REGIONS)
{
pPage->Regions[nPos].Id = gb.ReadByte();
gb.ReadByte(); // Reserved
pPage->Regions[nPos].HorizAddr = gb.ReadShort();
pPage->Regions[nPos].VertAddr = gb.ReadShort();
pPage->RegionCount++;
}
nPos++;
}
return S_OK;
}