예제 #1
0
파일: main.cpp 프로젝트: degarashi/TwilveQt
int main(int argc, char *argv[]) {
	QApplication a(argc, argv);
	// 翻訳ファイルをセットする
	QString c_code = QLocale::system().name().split("_")[0];
	QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf8"));
	// :Qtライブラリ
	QTranslator trQ, trMe;
	trQ.load("qt_" + c_code,
			 QLibraryInfo::location(QLibraryInfo::TranslationsPath));
	a.installTranslator(&trQ);
	// :MyApp
	trMe.load(qApp->applicationDirPath() + "/../translate/tr_" + c_code);
	a.installTranslator(&trMe);

	std::unique_ptr<TwqNet> pNet(new TwqNet(nullptr));
	std::unique_ptr<TwqUser> pUser(new TwqUser(nullptr));
	std::unique_ptr<TwqTweet> pTweet(new TwqTweet(nullptr));
	std::unique_ptr<TwqResource> pRes(new TwqResource);

	TwqMain w;
	w.show();
	try {
		return a.exec();
	} catch(const ExceptionBase& e) {
		QMessageBox::warning(&w, QApplication::tr("unknown error"),
							 QApplication::tr("unhandled exception throwed\n%1").arg(e.whatQs()));
	}
	return 1;
}
    ResourcePtr IResourceManager::RemoveResource(const ResourceHandle& Handle)
    {
        for( auto& GrItr : m_mGroups )
        {
            auto ResItr = GrItr.second->m_mResources.find( Handle );
            if( ResItr != GrItr.second->m_mResources.end() )
            {
                ResourcePtr pRes( ResItr->second );
                GrItr.second->m_mResources.erase( ResItr );
                return pRes;
            }
        }

        return XSE_NULLRES;
    }
    ResourceWeakPtr IResourceManager::CreateResource(xst_castring& strName, GroupWeakPtr pGroup)
    {
        xst_assert( pGroup.IsValid(), "(IResourceManager::CreateResource) Group is null" );
        ResourceHandle Handle; 
        Resources::IResource* pBaseRes;
        //ResourcePtr pRes;
        {
            //XSTSimpleProfiler2("IResourceManager2::GetHash"); //~0.000008sec in debug
            Handle = XSE_HASH( strName );
        }
        {
            //XSTSimpleProfiler2("IResourceManager2::_CreateResource"); //~0.003sec in debug
        pBaseRes = _CreateResource( strName, Handle, pGroup );
       // pRes = ResourcePtr( pBaseRes );
        if( pBaseRes == xst_null )
        {
            return XSE_NULLRES;
        }
        }

        pBaseRes->m_ResourceGroupHandle = pGroup->GetHandle();
        //pBaseRes->m_strResourceName = strName;
        pBaseRes->m_ResourceHandle = Handle;
        ResourceWeakPtr pRes( pBaseRes );
        pBaseRes->RemoveRef();
        { 
            //XSTSimpleProfiler2( "CreateResource::AddResourceByHandle" ); //~0.0007sec in debug
        if( pGroup->AddResource( Handle, pRes ) != RESULT::OK )
        {
            XST_LOG_ERR( "Resource: '" << strName << "' already exists in group: " << pGroup->GetName() );
            return XSE_NULLRES;
        }
        }
        //XSE_DO_LISTENER_VOID_METHOD( ResourceCreated, ListenerList::iterator, m_lListeners, pRes );

        return pRes;
    }
예제 #4
0
bool OSGSceneItem::init(UInt32 uiInitPhase, App *pApp)
{
    fprintf(stderr, "OSGSceneItem::init %s (%x)\n",
            getName(this),
            uiInitPhase);

    if(0x0000 != (uiInitPhase & ::OSG::InitPhase::LoadReferences))
    {
        if(_sfMatchedUrl.getValue().empty() == false)
        {
            fprintf(stderr, "Loading %s\n",
                    _sfMatchedUrl.getValue().c_str());
            
            NodeUnrecPtr pRoot = SceneFileHandler::the()->read(
                _sfMatchedUrl.getValue().c_str(),
                NULL,
                NULL,
                false);
            
            fprintf(stderr, "got %p\n", pRoot.get());
            
            if(pRoot != NULL)
            {
                setRoot(pRoot);
            }
            else
            {
                fprintf(stderr, "  failed\n");
            }
        }


        if(_sfMatchedGlobalUrl.getValue().empty() == false)
        {
            fprintf(stderr, "Loading global %s\n",
                    _sfMatchedGlobalUrl.getValue().c_str());
            
            FieldContainerUnrecPtr pRes(NULL);

            _oPathHandler.pushState();

            _oPathHandler.setBaseFile(_sfMatchedGlobalUrl.getValue().c_str());

            ImageFileHandler::the()->setPathHandler(&_oPathHandler);

            fprintf(stderr, "loading osg file %s ...\n",
                    _sfMatchedGlobalUrl.getValue().c_str());

            pRes = OSG::OSGSceneFileType::the().readContainer(
                _sfMatchedGlobalUrl.getValue().c_str(),
                NULL);

            ImageFileHandler::the()->setPathHandler(NULL);

            _oPathHandler.popState();
            
            fprintf(stderr, "got global %p\n", pRes.get());
            
            if(pRes != NULL)
            {
                ContainerCollectionUnrecPtr pColl = 
                    dynamic_pointer_cast<ContainerCollection>(pRes);

                if(pColl != NULL)
                {
                    MFUnrecFieldContainerPtr::const_iterator fIt  = 
                        pColl->getMFContainers()->begin();

                    MFUnrecFieldContainerPtr::const_iterator fEnd = 
                        pColl->getMFContainers()->end();

                    while(fIt != fEnd)
                    {
                        this->pushToGlobals(*fIt);
                        ++fIt;
                    }   
                }
            }
            else
            {
                fprintf(stderr, "  failed\n");
            }

            fprintf(stderr, "got %ld globals\n",
                    _mfGlobals.size());

            if(_sfActiveCamera.getValue().empty() == false)
            {
                FieldContainer *pCnt = findNamedComponent(
                    _sfActiveCamera.getValue().c_str());

                Camera *pCam = dynamic_cast<Camera *>(pCnt);

                fprintf(stderr, "found camera %p\n",
                        pCam);

                setCamera(pCam);
            }
        }
    }

    return true;
}
예제 #5
0
HRESULT
CFileResourceCache::WriteResource(
    _In_ IXpsDocumentConsumer*  pXpsConsumer,
    _In_ IFixedPage*            pFixedPage,
    _In_ IResWriter*            pResWriter
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(pXpsConsumer, E_POINTER)) &&
        SUCCEEDED(hr = CHECK_POINTER(pFixedPage, E_POINTER)) &&
        SUCCEEDED(hr = CHECK_POINTER(pResWriter, E_POINTER)))
    {
        CComBSTR bstrKeyName;
        CComBSTR bstrURI;

        //
        // Check if the resource has already been written
        //
        if (SUCCEEDED(hr = pResWriter->GetKeyName(&bstrKeyName)) &&
            SUCCEEDED(hr = pResWriter->GetResURI(&bstrURI)))
        {
            if (!Cached(bstrKeyName))
            {
                //
                // The resource is not cached:
                //    1. Create the resource part
                //    2. Write data to part
                //    3. Cache URI and new part against the resource name
                //
                CComPtr<_T> pRes(NULL);
                CComPtr<IPrintWriteStream> pWrite(NULL);

                if (SUCCEEDED(hr = pXpsConsumer->GetNewEmptyPart(bstrURI,
                                                                 __uuidof(_T),
                                                                 reinterpret_cast<VOID**>(&pRes),
                                                                 &pWrite)))
                {
                    hr = pResWriter->WriteData(pRes, pWrite);

                    pWrite->Close();

                    try
                    {
                        CComPtr<IPartBase> pPartBase(NULL);
                        if (SUCCEEDED(hr) &&
                            SUCCEEDED(hr = pRes.QueryInterface(&pPartBase)))
                        {
                            m_resMap[CComBSTR(bstrKeyName)].first = bstrURI;
                            m_resMap[CComBSTR(bstrKeyName)].second = pPartBase;
                        }
                    }
                    catch (exception& DBG_ONLY(e))
                    {
                        ERR(e.what());
                        hr = E_FAIL;
                    }
                }
            }

            //
            // Set the resource so relationships are updated
            //
            try
            {
                if (SUCCEEDED(hr))
                {
                    hr = pFixedPage->SetPagePart(m_resMap[CComBSTR(bstrKeyName)].second);
                }
            }
            catch (exception& DBG_ONLY(e))
            {
                ERR(e.what());
                hr = E_FAIL;
            }
        }
    }

    ERR_ON_HR(hr);
    return hr;
}