コード例 #1
0
int main(){

	SmartPtr<int> sPtr;
	sPtr.Reset(new int(999));

	cout << "Dislaying content of Smart Ptr:[" << *sPtr << "]" << endl;

	SmartPtr<char> charPtr(new char('R'));
	cout << "Char Smart Pointer:[" << *charPtr << "]" << endl;

	SmartPtr<int> iSPtr = sPtr;
	cout << "Copy Contructor of int Smart Ptr:[" << *iSPtr << "]" << endl;

	SmartPtr<int> isPtr2(sPtr);
	cout << "Copy Assignment of int Smart Ptr:[" << *isPtr2 << "]" << endl;

#if 0
	std::shared_ptr<int> foo;
	cout << "empty shared ptr:[" << *foo << endl;
#endif // 0

	//Followign code will fail as the smart pointer is empty, whic is the case for shared ptr as well
	SmartPtr<int> isPtr3;
	isPtr3 = isPtr2;
	cout << "Copy Assignment of int Smart Ptr:[" << *isPtr3 << "]" << endl;
	//_getche();
	return 0;
}
コード例 #2
0
BOOL CSampleCGB::HasMediaType(IPin *pPin, REFGUID majorType )
{
	if(!pPin)
	{
		return FALSE;
	}

	SmartPtr<IEnumMediaTypes> pMediaTypes;
	HRESULT hr = pPin->EnumMediaTypes(&pMediaTypes);
	if(FAILED(hr))return FALSE;

	hr = pMediaTypes->Reset();
	if(FAILED(hr))return FALSE;

	ULONG cFetched;
	AM_MEDIA_TYPE* pTempMediaType;
	while(S_OK == pMediaTypes->Next(1,&pTempMediaType,&cFetched))
	{
		if(::IsEqualGUID(pTempMediaType->majortype,majorType))
		{
			DeleteMediaType(pTempMediaType);
			return TRUE;
		}
		DeleteMediaType(pTempMediaType);
	}
	return FALSE;
}
コード例 #3
0
HRESULT CSampleCGB::FindMPEG2Pin( IBaseFilter *pFilter, IPin** ppPin )
{
	if(!pFilter)return E_INVALIDARG;

	SmartPtr<IEnumPins> pEnumPins;
	HRESULT hr = pFilter->EnumPins(&pEnumPins);
	if(FAILED(hr))return hr;
	SmartPtr<IPin> pTempPin;
	ULONG fetched;
	PIN_DIRECTION dir;

	hr = pEnumPins->Reset();

	while(pTempPin.Release(),S_OK == pEnumPins->Next(1,&pTempPin,&fetched))
	{
		hr = pTempPin->QueryDirection(&dir);
		if(FAILED(hr) || PINDIR_INPUT == dir)
		{
			continue;
		}
		if(IsMPEG2Pin(pTempPin))
		{
			(*ppPin) = pTempPin.Detach();
			return S_OK;
		}
	}
	return E_FAIL;
}
コード例 #4
0
BOOL CSampleCGB::IsMPEG2Pin( IPin *pPin )
{
	if(!pPin)return FALSE;
	SmartPtr<IEnumMediaTypes> pMediaTypes;
	HRESULT hr = pPin->EnumMediaTypes(&pMediaTypes);
	if(FAILED(hr))return FALSE;
	hr = pMediaTypes->Reset();
	if(FAILED(hr))return FALSE;


	ULONG fetched;
	AM_MEDIA_TYPE* pTempMediaType;

	while(S_OK == pMediaTypes->Next(1,&pTempMediaType,&fetched))
	{
		if(
			(
			::IsEqualGUID(pTempMediaType->majortype,MEDIATYPE_Video) ||
			::IsEqualGUID(pTempMediaType->majortype,MEDIATYPE_Stream)
			)
			&&
			(
			::IsEqualGUID(pTempMediaType->subtype,MEDIASUBTYPE_MPEG2_VIDEO) ||
			::IsEqualGUID(pTempMediaType->subtype,MEDIASUBTYPE_MPEG2_PROGRAM)
			)
			)
		{
			DeleteMediaType(pTempMediaType);
			return TRUE;
		}
		DeleteMediaType(pTempMediaType);
	}
	return FALSE;
}
コード例 #5
0
ファイル: SampleCGB.cpp プロジェクト: bai-lu-sz/KineCT
HRESULT 
ISampleCaptureGraphBuilder::FindAudioPin( 
                                IBaseFilter *pFilter, 
                                IPin **ppPin  )
{
    if( !pFilter )
    {
        return E_POINTER;
    }

    SmartPtr<IEnumPins> pEnumPins;
    HRESULT hr = pFilter->EnumPins( &pEnumPins );
    if( FAILED( hr ) )
    {
        return hr;
    }

    SmartPtr<IPin>   pTempPin;
    ULONG           fetched;
    hr = pEnumPins->Reset( );

    while( pTempPin.Release(), S_OK == pEnumPins->Next( 1, &pTempPin, &fetched ) )
    {
        if( IsAudioPin( pTempPin ) )
        {
            (*ppPin) = pTempPin.Detach();
            return S_OK;
        }
    }
    return E_FAIL;
}
コード例 #6
0
ファイル: SampleCGB.cpp プロジェクト: bai-lu-sz/KineCT
//
//  search the encoder that has this special medium
//  video == TRUE -- look for a video pin
//  video == FALSE -- look for a audio pin  
//
HRESULT ISampleCaptureGraphBuilder::FindPin( 
            IBaseFilter *pFilter, 
            const REGPINMEDIUM& regPinMedium, 
            PIN_DIRECTION direction, 
            BOOL video,             
            IPin **ppPin)
{
    if( !pFilter )
    {
        return E_POINTER;
    }

    SmartPtr<IEnumPins> pEnumPins;
    HRESULT hr = pFilter->EnumPins( &pEnumPins );
    if( FAILED( hr ) )
    {
        return hr;
    }
    
    SmartPtr<IPin>   pTempPin;
    ULONG           fetched;
    REGPINMEDIUM    regPinMediumTemp;
    PIN_DIRECTION   dir;

    hr = pEnumPins->Reset( );
    while( pTempPin.Release(), S_OK == pEnumPins->Next( 1, &pTempPin, &fetched ) )
    {
        ASSERT( pTempPin );

        hr = pTempPin->QueryDirection( &dir );
        if( FAILED( hr ) || dir != direction )
        {
            continue;
        }

        hr = GetMedium( pTempPin, regPinMediumTemp );
        if( FAILED( hr ) )
        {
            continue;
        }

        if( !IsVideoPin( pTempPin ) )
        {
            continue;
        }

        if( ::IsEqualGUID( regPinMediumTemp.clsMedium, regPinMedium.clsMedium  ) &&
            regPinMediumTemp.dw1 == regPinMedium.dw1 )
        {
            (*ppPin) = pTempPin.Detach();
            return S_OK;
        }
    }

    return E_FAIL;
}
コード例 #7
0
ファイル: Asteroids.cpp プロジェクト: DominikWidomski/Cpp
SmartPtr<GameObject> Asteroids::CreateExplosion()
{
    Animation *anim_ptr = AnimationManager::GetInstance().GetAnimationByName("explosion");
    SmartPtr<Sprite> explosion_sprite = new Sprite(anim_ptr->GetWidth(), anim_ptr->GetHeight(), anim_ptr);
    explosion_sprite->SetLoopAnimation(false);
    SmartPtr<GameObject> explosion = new Explosion();
    explosion->SetSprite(explosion_sprite);
    explosion->Reset();
    return explosion;
}
コード例 #8
0
ファイル: SampleCGB.cpp プロジェクト: bai-lu-sz/KineCT
//
//  Loop through every media type supported by this pin
//  to see if there is one which can be considered MPEG2
//
BOOL ISampleCaptureGraphBuilder::IsMPEG2Pin( IPin *pPin )
{
    if( !pPin )
    {
        return FALSE;   // NULL pointer
    }
    
    SmartPtr<IEnumMediaTypes> pMediaTypes;
    HRESULT hr = pPin->EnumMediaTypes( &pMediaTypes );
    if( FAILED( hr ) )
    {
        return FALSE;
    }

    hr = pMediaTypes->Reset();
    if( FAILED( hr ) )
    {
        return FALSE;
    }

    ULONG           fetched;
    AM_MEDIA_TYPE   *mediaType;
    while( S_OK == pMediaTypes->Next( 1, &mediaType, &fetched ) )
    {
        if( 
            (
                ::IsEqualGUID( mediaType->majortype, MEDIATYPE_Video ) ||
                ::IsEqualGUID( mediaType->majortype, MEDIATYPE_Stream ) 
            )
            &&
            (
                ::IsEqualGUID( mediaType->subtype, MEDIASUBTYPE_MPEG2_VIDEO ) ||
                ::IsEqualGUID( mediaType->subtype,  MEDIASUBTYPE_MPEG2_PROGRAM )
            )
        )
        {
            DeleteMediaType( mediaType );
            return TRUE;
        }
        DeleteMediaType( mediaType );
    }

    return FALSE;
}
コード例 #9
0
HRESULT CSampleCGB::FindAudioPin( IBaseFilter *pFilter, IPin **ppPin )
{
	if(!pFilter)return E_POINTER;

	SmartPtr<IEnumPins> pEnumPins;
	HRESULT hr = pFilter->EnumPins(&pEnumPins);
	if(FAILED(hr))return hr;

	SmartPtr<IPin> pTempPin;
	ULONG cFetched;
	hr = pEnumPins->Reset();
	if(FAILED(hr))return hr;

	while(pTempPin.Release(),pEnumPins->Next(1,&pTempPin,&cFetched))
	{
		if(IsAudioPin(pTempPin))
		{
			*ppPin = pTempPin.Detach();
			return S_OK;
		}
	}
	return E_FAIL;
}
コード例 #10
0
ファイル: SampleCGB.cpp プロジェクト: bai-lu-sz/KineCT
BOOL ISampleCaptureGraphBuilder::HasMediaType(IPin *pPin,  REFGUID majorType )
{
    if( !pPin )
    {
        return FALSE;
    }

    SmartPtr<IEnumMediaTypes> pMediaTypes;
    HRESULT hr = pPin->EnumMediaTypes( &pMediaTypes );
    if( FAILED( hr ) )
    {
        return FALSE;
    }

    hr = pMediaTypes->Reset();
    if( FAILED( hr ) )
    {
        return FALSE;
    }

    ULONG           fetched;
    AM_MEDIA_TYPE   *mediaType;

    while( S_OK == pMediaTypes->Next( 1, &mediaType, &fetched ) )
    {
        if( ::IsEqualGUID( mediaType->majortype, majorType ) )
        {
            DeleteMediaType( mediaType );
            return TRUE;
        }
        DeleteMediaType( mediaType );
    }

    return FALSE;

}