Esempio n. 1
0
void LoadTextureJob::OnFinish(IZ_BOOL runResult)
{
#if 1
    if (IsCanceled() || !runResult) {
        // Free memory.
        FREE(m_InternalAllocator, m_PixelData);
        m_TargetItem->SetTexture(IZ_NULL);
        return;
    }
#endif
    
    // Create texture from pixel data.
    izanagi::graph::CTexture* texture = m_Device->CreateTexture(
        m_TexWidth, m_TexHeight,
        izanagi::graph::E_GRAPH_PIXEL_FMT_RGBA8,
        m_PixelData);

    // Set texture to target.
    IZ_ASSERT(m_TargetItem != IZ_NULL);
    //m_TargetItem->SetTexture(texture, m_Path);
    m_TargetItem->SetTexture(texture);
    SAFE_RELEASE(texture);

    // Free memory.
    FREE(m_InternalAllocator, m_PixelData);
}
Esempio n. 2
0
  void Run() override
  {
    MOZ_ASSERT(!GetIO()->IsConsumerThread());
    MOZ_ASSERT(!IsCanceled());

    GetIO()->Connect();
  }
 void Run() override
 {
   if (IsCanceled()) {
     return;
   }
   GetIO()->Connect(sBluetoothdSocketName);
 }
ECode CCancellationSignal::ThrowIfCanceled()
{
    Boolean isCanceled;
    if (IsCanceled(&isCanceled), isCanceled) {
        return E_OPERATION_CANCELED_EXCEPTION;
    }
    return NOERROR;
}
Esempio n. 5
0
  void Run() override
  {
    MOZ_ASSERT(!NS_IsMainThread());

    if (!IsCanceled()) {
      GetIO()->Listen(mCOSocketIO);
    }
  }
Esempio n. 6
0
  void Run() override
  {
    MOZ_ASSERT(!GetIO()->IsConsumerThread());

    if (!IsCanceled()) {
      GetIO()->Listen(mCOSocketIO);
    }
  }
Esempio n. 7
0
  NS_IMETHOD Run() override
  {
    MOZ_ASSERT(!GetIO()->IsConsumerThread());
    MOZ_ASSERT(!IsCanceled());

    GetIO()->Connect();

    return NS_OK;
  }
Esempio n. 8
0
 virtual void OnFinish(IZ_BOOL runResult)
 {
     if (IsCanceled()) {
         IZ_PRINTF("Finish Canceled\n");
     }
     else {
         IZ_PRINTF("Finish %s\n", runResult ? "Succeeded" : "Failed");
     }
 }
Esempio n. 9
0
bool CGUIDialogCache::OnFileCallback(void* pContext, int ipercent, float avgSpeed)
{
  m_pDlg->ShowProgressBar(true);
  m_pDlg->SetPercentage(ipercent); 

  if( IsCanceled() ) 
    return false;
  else
    return true;
}
Esempio n. 10
0
  void Run() override
  {
    MOZ_ASSERT(GetIO()->IsConsumerThread());

    if (IsCanceled()) {
      return;
    }

    RilSocketIO* io = GetIO();
    if (io->IsShutdownOnConsumerThread()) {
      return;
    }

    io->ClearDelayedConnectTask();
    io->GetIOLoop()->PostTask(FROM_HERE, new ConnectTask(io));
  }
void CHyperFeedStructureInfo::OnRequest(CRequestBasePtr pRequest)
{
	EgLib::CEgLibTraceManager::Trace(LogSubs, __FUNCTION__ , _T("OnRequest Enter"));	
	switch(pRequest->m_enType)
	{
	case _enRequestStock:
		{
			CStockRequest* pStockRequest = dynamic_cast<CStockRequest*>(pRequest.get());
			EgLib::CEgLibTraceManager::Trace(LogSubs, __FUNCTION__ , _T("Requesting Stock Start"));	
			if(pStockRequest)
			{
				EgLib::CEgLibTraceManager::Trace(LogSubs, __FUNCTION__ , _T("Get stock info call"));	
				GetStockInfo(pStockRequest->m_recParams);
			}
			EgLib::CEgLibTraceManager::Trace(LogSubs, __FUNCTION__ , _T("Requesting Stock Done: %s"), _T(pStockRequest->m_recParams->Stock));	
		}
		break;
	case _enRequestOption:
		{
			EgLib::CEgLibTraceManager::Trace(LogSubs, __FUNCTION__ , _T("Requesting Option Start"));	
			
			COptionRequest* pOptionRequest = dynamic_cast<COptionRequest*>(pRequest.get());

			if(pOptionRequest)
			{
				pOptionRequest->m_recParams.CopyTo(m_vtCurrentRequest);
//				if(!IsCanceled())
//				{
//					EgLib::CEgLibTraceManager::Trace(LogSubs, __FUNCTION__ , _T("Requesting Option Fundamental Call: %s"), _T(pOptionRequest->m_recParams->UnderlyingSymbol));	
//					LoadOptionFundamentalInfo(pOptionRequest->m_recParams->UnderlyingSymbol);
//				}
					
				if(!IsCanceled())
				{
					EgLib::CEgLibTraceManager::Trace(LogSubs, __FUNCTION__ , _T("GetOptions Call: %s"), _T(pOptionRequest->m_recParams->UnderlyingSymbol));	
					GetOptions(pOptionRequest->m_recParams->UnderlyingSymbol);
				}
				
			}
			EgLib::CEgLibTraceManager::Trace(LogSubs, __FUNCTION__ , _T("Requesting Option Done"));	
		}
		break;
	}
	EgLib::CEgLibTraceManager::Trace(LogSubs, __FUNCTION__ , _T("OnRequest Exit"));	
}
Esempio n. 12
0
  NS_IMETHOD Run() override
  {
    MOZ_ASSERT(GetIO()->IsConsumerThread());

    if (IsCanceled()) {
      return NS_OK;
    }

    RilSocketIO* io = GetIO();
    if (io->IsShutdownOnConsumerThread()) {
      return NS_OK;
    }

    io->ClearDelayedConnectTask();
    io->GetIOLoop()->PostTask(MakeAndAddRef<ConnectTask>(io));

    return NS_OK;
  }
Esempio n. 13
0
/**
 * The run method is used internally to actually run the commands.
 * @return whether or not the command should stay within the {@link Scheduler}.
 */
bool Command::Run()
{
	if (!m_runWhenDisabled && m_parent == NULL && DriverStation::GetInstance()->IsDisabled())
		Cancel();

	if (IsCanceled())
		return false;

	if (!m_initialized)
	{
		m_initialized = true;
		StartTiming();
		_Initialize();
		Initialize();
	}
	_Execute();
	Execute();
	return !IsFinished();
}
Esempio n. 14
0
//  ---------------------------------------------------------------------------                       
void
CGtfReader::ReadSeqAnnots(
    TAnnots& annots,
    ILineReader& lr,
    ILineErrorListener* pEC)
//  ----------------------------------------------------------------------------
{
    xProgressInit(lr);

    string line;
    while (xGetLine(lr, line)) {
        if (IsCanceled()) {
            AutoPtr<CObjReaderLineException> pErr(
                CObjReaderLineException::Create(
                eDiag_Info,
                0,
                "Reader stopped by user.",
                ILineError::eProblem_ProgressInfo));
            ProcessError(*pErr, pEC);
            annots.clear();
            return;
        }
        xReportProgress(pEC);
        try {
            if (xIsTrackTerminator(line)) {
                continue;
            }
            if (x_ParseBrowserLineGff(line, m_CurrentBrowserInfo)) {
                continue;
            }
            if (xParseTrackLine(line, pEC)) {
                continue;
            }
            if (x_ParseFeatureGff(line, annots, pEC)) {
                continue;
            }
        }
        catch(CObjReaderLineException& err) {
            err.SetLineNumber(m_uLineNumber);
        }
    }
}
Esempio n. 15
0
 bool Entry()
 {
     bool err = pPointingSource->SlewToCoordinatesAsync(ra, dec);
     if (err)
     {
         SetErrorMsg(_("Slew failed!"));
         return true;
     }
     while (pPointingSource->Slewing())
     {
         wxMilliSleep(500);
         if (IsCanceled())
         {
             pPointingSource->AbortSlew();
             SetErrorMsg(_("Slew was canceled"));
             break;
         }
     }
     return false;
 }
Esempio n. 16
0
/**
 * Called when the command has been removed.
 * This will call {@link Command#interrupted() interrupted()} or {@link Command#end() end()}.
 */
void Command::Removed()
{
	if (m_initialized)
	{
		if (IsCanceled())
		{
			Interrupted();
			_Interrupted();
		}
		else
		{
			End();
			_End();
		}
	}
	m_initialized = false;
	m_canceled = false;
	m_running = false;
	if (m_table != NULL)
		m_table->PutBoolean(kRunning, false);
}
void CHyperFeedStructureProviderEx::OnRequest(CRequestBasePtr pRequest)
{
	switch(pRequest->m_enType)
	{
	case _enRequestStock:
		{
			CStockRequest* pStockRequest = static_cast<CStockRequest*>(pRequest.get());
			if(pStockRequest)
				GetStockResultsEx(pStockRequest->m_recParams);
		}
		break;
	case _enRequestOption:
		{
			COptionRequest* pOptionRequest = static_cast<COptionRequest*>(pRequest.get());
			if(pOptionRequest)
			{
				pOptionRequest->m_recParams.CopyTo(m_vtCurrentRequest);
				if(!IsCanceled())
					LoadOptionFundamentalInfo(pOptionRequest->m_recParams->UnderlyingSymbol);
				if(!IsCanceled())
					GetOptions(pOptionRequest->m_recParams->UnderlyingSymbol);
			}
		}
		break;
	case _enRequestFuture:
		{
			CFutureRequest* pFutureRequest = static_cast<CFutureRequest*>(pRequest.get());
			if(pFutureRequest)
				GetFutureResultsBySymbol(pFutureRequest->m_recParams, true);
		}
		break;
	case _enRequestFutures:
		{
			CFuturesRequest* pFuturesRequest = static_cast<CFuturesRequest*>(pRequest.get());
			if(pFuturesRequest)
				GetFutureResultsByRootSymbol(pFuturesRequest->m_recParams, true);
		}
		break;
	case _enRequestFuturesOption:
		{
			EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Requst Futures Options Start"));
			CFuturesOptionRequestPtr pFuturesOptionRequest = boost::shared_dynamic_cast<CFuturesOptionRequest>(pRequest);
			if(pFuturesOptionRequest)
			{
				EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("pFuturesOptionRequest"));
				pFuturesOptionRequest->m_recParams.CopyTo(m_vtCurrentRequest);
				EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetFutureInfo Call"));
				long nResult = GetFutureInfo(pFuturesOptionRequest->m_recParams, false);
				if(nResult == DBA_ERR_NO_ERROR) // Sharky: try to resolve FT_CQ00001489
				{
					EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetFutureInfo Call - No Error"));
					QuoteUpdateParams Params;
					Params.Symbol = ::SysAllocString(pFuturesOptionRequest->m_recParams->FutureSymbol);
					Params.Type = enFUT;
					Params.Exchange = NULL;

					CQuoteRequestPtr pQuoteRequest = CQuoteRequestPtr(new CQuoteRequest(_enRequestFuturesOption, &Params));
					EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetPrice for: Symbol - %s"), CW2T(Params.Symbol) );
					nResult = GetPrice(boost::shared_static_cast<CRequestBase>(pQuoteRequest), false);

					::SysFreeString(Params.Symbol);

					if(nResult == DBA_ERR_NO_ERROR) // Sharky: try to resolve FT_CQ00001489
					{
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Got Price for: %s"), CW2T(Params.Symbol));
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Requesting future options for: %s"), CW2T(Params.Symbol));
						GetFutureOptionsResults(m_clCurrentFuture, false);
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Got future options for: %s"), CW2T(Params.Symbol));

					}
					else
					{
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetPrice FAILED for: %s"),CW2T(Params.Symbol));
						/* Lets try to get with 'G' symbol */

						//Params.Exchange = ::SysAllocString(L"G");
						CComBSTR cbsTmp(pFuturesOptionRequest->m_recParams->FutureSymbol);
						cbsTmp.Append(L"G");
						Params.Symbol = cbsTmp.Detach();


						CQuoteRequestPtr pQuoteRequest = CQuoteRequestPtr(new CQuoteRequest(_enRequestFuturesOption, &Params));
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetPrice for: Symbol - %s"), CW2T(Params.Symbol) );
						nResult = GetPrice(boost::shared_dynamic_cast<CRequestBase>(pQuoteRequest), false);
						//::SysFreeString(Params.Symbol);
						//::SysFreeString(Params.Exchange );

						if(nResult == DBA_ERR_NO_ERROR) 
						{
							EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Got Price for: %s"), CW2T(Params.Symbol));
							EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Requesting future options for: %s"), CW2T(Params.Symbol));
							GetFutureOptionsResults(m_clCurrentFuture, false);
							EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Got future options for: %s"), CW2T(Params.Symbol));
						}
						else
						{
							EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetPrice FAILED for: %s"),CW2T(Params.Symbol));

						}
						/* ---Lets try to get with 'G' symbol */
					}

				}
				else
				{
					EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetFutureInfo Call - Failed"));
				}

				if(nResult != DBA_ERR_NO_ERROR) // Sharky: try to resolve FT_CQ00001489
				{
					EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Request future options - got error"));

					if(nResult == DBA_TERMINATED)
					{
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Operation was canceled by user"));
						PublicGetFutureOptionError(enInternalError, _bstr_t(L"Operation was canceled by user"));
					}
					if(nResult == DBA_ERR_KEY_NOT_FOUND)
					{
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Couldn't get future options for future. Unknown symbol"));
						PublicGetFutureOptionError(enNoDataAvailableForSymbol, _bstr_t(L"Couldn't get future options for future. Unknown symbol"));
					}
					else
					{
						_bstr_t bs =  "Couldn't get options for future. Error: ";
						bs += EtGetMessage(DBA_ERROR,nResult);
						TCHAR buffer[0x100] = {0};				
						_ltot(nResult,buffer,10);
						bs += " (";
						bs += buffer;
						bs += ")";
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T(buffer));
						PublicGetFutureOptionError(enProviderInternalError, bs);
					}
				}
			}
		}
		break;
	}
}
Esempio n. 18
0
IZ_BOOL LoadTextureJob::OnRun()
{
#if 0
    if (!m_TargetItem->IsShown()) {
        return IZ_FALSE;
    }
#endif

    // Open file.
    izanagi::CFileInputStream input;
    //VRETURN(input.Open(m_Path));
    if (!input.Open(m_Path)) {
        return IZ_FALSE;
    }

    // Read to memory.
    IZ_UINT8* buf = (IZ_UINT8*)ALLOC(m_InternalAllocator, input.GetSize());
    size_t size = input.GetSize();
    VRETURN(buf != IZ_NULL);
    input.Read(buf, 0, size);
    input.Close();

    // Read jpeg.
    jpeg_decompress_struct cinfo;
    jpeg_error_mgr jerror;
    
    cinfo.err = jpeg_std_error(&jerror);
    jpeg_create_decompress(&cinfo);

    jpeg_mem_src(&cinfo, buf, size);

    jpeg_read_header(&cinfo, IZ_TRUE);

    jpeg_start_decompress(&cinfo);

    // Alloc buffer to store line data.
    IZ_UINT pitch = cinfo.output_width * cinfo.output_components;
    IZ_UINT8* lineData = (IZ_UINT8*)ALLOC(m_InternalAllocator, pitch + 10);
    VGOTO(lineData != IZ_NULL, __EXIT__);

    // Convert to RGBA8 format.
    const IZ_UINT bpp = izanagi::graph::CGraphUtil::GetBPP(izanagi::graph::E_GRAPH_PIXEL_FMT_RGBA8);
    const IZ_UINT stride = bpp * cinfo.output_width;

    // Alloc buffer to store rgba data.
    IZ_UINT bytes = cinfo.output_width * cinfo.output_height * bpp;
    m_PixelData = (IZ_UINT8*)ALLOC(m_InternalAllocator, bytes);
    VGOTO(m_PixelData != IZ_NULL, __EXIT__);

    IZ_BOOL ret = IZ_TRUE;
    IZ_UINT8* dst = m_PixelData;

    while(cinfo.output_scanline < cinfo.output_height) {
        IZ_UINT8* buffer[1];
        buffer[0] = (IZ_UINT8*)lineData;

        jpeg_read_scanlines(&cinfo, buffer, 1);

        // Convert to rgba.
        for (IZ_UINT i = 0; i < cinfo.output_width; i++) {
            dst[i * 4 + 0] = lineData[i * 3 + 2];
            dst[i * 4 + 1] = lineData[i * 3 + 1];
            dst[i * 4 + 2] = lineData[i * 3 + 0];
            dst[i * 4 + 3] = 0xff;
        }

        dst += stride;
    }

    // Keep image size.
    m_TexWidth = cinfo.output_width;
    m_TexHeight = cinfo.output_height;

__EXIT__:
    jpeg_finish_decompress(&cinfo);
    jpeg_destroy_decompress(&cinfo);

    FREE(m_InternalAllocator, buf);
    FREE(m_InternalAllocator, lineData);

    // If this job is canceld...
    if (IsCanceled()) {
        ret = IZ_FALSE;
    }

    return ret;
}
Esempio n. 19
0
// ---------------------------------------
bool MTRecord::FormatDescription(std::string & str_output)
{
    OTString strDescription, strStatus, strKind;

    if (IsRecord())
    {
        if (IsExpired())
            strStatus = "(EXPIRED)"; // How to tell difference between instrument that processed successfully and THEN expired, versus one that expired before processing successfully? (See next comment.)
        else if (IsInvoice())
            strStatus = "(payment sent)";  // TODO: need an "invalid records" box for expired and canceled. Otherwise we may falsely assume "payment sent" when actually it expired. (We may also falsely assume payment expired when actually it was sent.) Solution is a new box.
        else
            strStatus = "";
//          strStatus = "(record)";
    }
    // -----------------------------
    else if (IsPending())
    {
        if (IsExpired())
            strStatus = "(EXPIRED)";
        else if (IsInvoice())
            strStatus = "(unpaid)";
        else if (!IsCash())
            strStatus = "(pending)";
    }
    // -----------------------------
    if (IsCanceled())
    {
        strStatus = "(CANCELED)";

        if (IsOutgoing() || IsReceipt())
            strKind.Format("%s", "sent ");
    }
    // -----------------------------
    else
    {
        if (IsOutgoing())
            strKind.Format("%s",
                           ((IsPending() && !IsCash()) ? "outgoing " : "sent "));
        else // incoming.
            strKind.Format("%s",
                           IsPending() ? "incoming " : (IsReceipt() ? "" : "received "));
    }
    // -----------------------------
    OTString strTransNumForDisplay;

    if (!IsCash())
        strTransNumForDisplay.Format(" #%ld", GetTransNumForDisplay());
    // -----------------------------
    if (IsRecord())
    {
        if (this->IsTransfer())
            strDescription.Format("%s%s%s %s", strKind.Get(), "transfer", strTransNumForDisplay.Get(), strStatus.Get());
        else if (this->IsVoucher())
            strDescription.Format("%s%s%s %s", strKind.Get(), "payment", strTransNumForDisplay.Get(), strStatus.Get());
        else if (this->IsReceipt())
        {
            std::string str_instrument_type;

            if (0 == GetInstrumentType().compare("transferReceipt"))
                str_instrument_type = "transfer";
            else if (0 == GetInstrumentType().compare("finalReceipt"))
                str_instrument_type = "final receipt (closed)";
            else if (0 == GetInstrumentType().compare("chequeReceipt"))
            {
                const long lAmount = OTAPI_Wrap::It()->StringToLong(m_str_amount);

                // I paid OUT when this chequeReceipt came through. It must be a normal cheque that I wrote.
                if (lAmount <= 0) // Notice less than OR EQUAL TO 0 -- that's because a canceled cheque has a 0 value.
                    str_instrument_type = "cheque";
                else // I GOT PAID when this chequeReceipt came through. It must be an invoice I wrote, that someone paid.
                {
                    if (IsCanceled())
                        str_instrument_type = "invoice";
                    else
                        str_instrument_type = "invoice (payment received)";
                }
            }
            else if (0 == GetInstrumentType().compare("voucherReceipt"))
            {
                str_instrument_type = "payment";
            }
            else if (0 == GetInstrumentType().compare("paymentReceipt"))
            {
                const long lAmount = OTAPI_Wrap::It()->StringToLong(m_str_amount);

                if (!IsCanceled() && (lAmount > 0))
                    strKind.Set("received ");

                str_instrument_type = "recurring payment";
            }

            strDescription.Format("%s%s%s %s", strKind.Get(), str_instrument_type.c_str(), strTransNumForDisplay.Get(), strStatus.Get());
        }
        else
            strDescription.Format("%s%s%s %s", strKind.Get(), GetInstrumentType().c_str(), strTransNumForDisplay.Get(), strStatus.Get());
    }
    else
    {
        if (this->IsTransfer())
            strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(), "transfer", strTransNumForDisplay.Get());
        else if (this->IsVoucher())
            strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(), "payment", strTransNumForDisplay.Get());

        else if (this->IsReceipt())
        {
            std::string str_instrument_type;

            if (0 == GetInstrumentType().compare("transferReceipt"))
            {
                if (IsCanceled())
                    str_instrument_type = "transfer";
                else
                    str_instrument_type = "transfer (receipt)";
            }
            else if (0 == GetInstrumentType().compare("finalReceipt"))
                str_instrument_type = "final receipt";
            else if (0 == GetInstrumentType().compare("chequeReceipt"))
            {
                const long lAmount = OTAPI_Wrap::It()->StringToLong(m_str_amount);

                // I paid OUT when this chequeReceipt came through. It must be a normal cheque that I wrote.
                if (lAmount <= 0) // Notice less than OR EQUAL TO 0 -- that's because a canceled cheque has a 0 value.
                {
                    if (IsCanceled())
                        str_instrument_type = "cheque";
                    else
                        str_instrument_type = "cheque (receipt)";
                }
                else // I GOT PAID when this chequeReceipt came through. It must be an invoice I wrote, that someone paid.
                {
                    if (IsCanceled())
                        str_instrument_type = "invoice";
                    else
                        str_instrument_type = "sent invoice (receipt: payment received)";
                }
            }
            else if (0 == GetInstrumentType().compare("voucherReceipt"))
            {
                if (IsCanceled())
                    str_instrument_type = "payment";
                else
                    str_instrument_type = "payment (receipt)";
            }
            else if (0 == GetInstrumentType().compare("paymentReceipt"))
            {
                const long lAmount = OTAPI_Wrap::It()->StringToLong(m_str_amount);

                if (!IsCanceled() && (lAmount > 0))
                    strKind.Set("received ");

                str_instrument_type = "recurring payment (receipt)";
            }

            strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(), str_instrument_type.c_str(), strTransNumForDisplay.Get());
        }
        else
            strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(), GetInstrumentType().c_str(), strTransNumForDisplay.Get());
    }
    // -----------------------------
    str_output = strDescription.Get();
    // -----------------------------
    return (!str_output.empty());
}
void CHyperFeedStructureProviderEx::OnRequest(CRequestBasePtr pRequest)
{
	switch(pRequest->m_enType)
	{
	case _enRequestStock:
		{
			CStockRequest* pStockRequest = dynamic_cast<CStockRequest*>(pRequest.get());
			if(pStockRequest)
				GetStockResultsEx(pStockRequest->m_recParams);
		}
		break;
	case _enRequestOption:
		{
			COptionRequest* pOptionRequest = dynamic_cast<COptionRequest*>(pRequest.get());
			if(pOptionRequest)
			{
				pOptionRequest->m_recParams.CopyTo(m_vtCurrentRequest);
				if(!IsCanceled())
					LoadOptionFundamentalInfo(pOptionRequest->m_recParams->UnderlyingSymbol);
				if(!IsCanceled())
					GetOptions(pOptionRequest->m_recParams->UnderlyingSymbol);
			}
		}
		break;
	case _enRequestFuture:
		{
			CFutureRequest* pFutureRequest = dynamic_cast<CFutureRequest*>(pRequest.get());
			if(pFutureRequest)
				GetFutureResultsBySymbol(pFutureRequest->m_recParams, true);
		}
		break;
	case _enRequestFutures:
		{
			CFuturesRequest* pFuturesRequest = dynamic_cast<CFuturesRequest*>(pRequest.get());
			if(pFuturesRequest)
				GetFutureResultsByRootSymbol(pFuturesRequest->m_recParams, true);
		}
		break;
	case _enRequestFuturesOption:
		{
			CFuturesOptionRequest* pFuturesOptionRequest = dynamic_cast<CFuturesOptionRequest*>(pRequest.get());
			if(pFuturesOptionRequest)
			{
				pFuturesOptionRequest->m_recParams.CopyTo(m_vtCurrentRequest);
				long nResult = GetFutureInfo(pFuturesOptionRequest->m_recParams, true);
				if(nResult == DBA_ERR_NO_ERROR) // Sharky: try to resolve FT_CQ00001489
				{
					m_clCurrentFuture.m_dFutureClosePrice = GetClosePrice(pFuturesOptionRequest->m_recParams->FutureSymbol, enFUT);

					if(m_clCurrentFuture.m_dFutureClosePrice > BAD_DOUBLE_VALUE) // Sharky: try to resolve FT_CQ00001489
					{
						GetFutureOptionsResults(m_clCurrentFuture, true);
					}
					else
					{
						PublicGetFutureOptionError(enNoDataAvailableForSymbol, _bstr_t(L"Couldn't get future options for future. No close price for future."));
					}
				}
				
				if(nResult != DBA_ERR_NO_ERROR) // Sharky: try to resolve FT_CQ00001489
				{
					if(nResult == DBA_TERMINATED)
					{
						PublicGetFutureOptionError(enInternalError, _bstr_t(L"Operation was canceled by user"));
					}
					if(nResult == DBA_ERR_KEY_NOT_FOUND)
					{
						PublicGetFutureOptionError(enNoDataAvailableForSymbol, _bstr_t(L"Couldn't get future options for future. Unknown symbol"));
					}
					else
					{
						_bstr_t bs =  "Couldn't get options for future. Error: ";
						bs += EtGetMessage(DBA_ERROR,nResult);
						TCHAR buffer[0x100] = {0};				
						_ltot(nResult,buffer,10);
						bs += " (";
						bs += buffer;
						bs += ")";
						PublicGetFutureOptionError(enProviderInternalError, bs);
					}
				}
			}
		}
		break;
	}
}
Esempio n. 21
0
File: mesh.cpp Progetto: skopp/rush
//  Here we process mesh geometry for given node.
//  Vertices for the geometry from the all meshes of the scene are allocated in 
//  one big vertex pool. One vertex can occur several times in this pool, because
//  we add 3 new vertices for every face.
//  After all meshes in the scene are processed, this pool is collapsed to remove
//  duplicate vertices.
void RBExport::ProcessMesh( INode* node )
{
    if (!node->Renderable() || node->IsNodeHidden())
    {
        return;
    }
    
    ObjectState os      = node->EvalWorldState( m_CurTime );
    Object*     pObject = os.obj;
    if (!pObject) 
    {
        Warn( "Could not evaluate object state in node <%s>. Mesh was skipped.", node->GetName() );
        return;
    }
    Matrix3 nodeTM          = node->GetNodeTM( m_CurTime );
    Matrix3 nodeTMAfterWSM  = node->GetObjTMAfterWSM( m_CurTime );
    Matrix3 mOffs           = nodeTMAfterWSM*Inverse( nodeTM );

    //  triangulate
    TriObject* pTriObj = 0;
    if (pObject->CanConvertToType( Class_ID( TRIOBJ_CLASS_ID, 0 ) )) 
    { 
        pTriObj = (TriObject*)pObject->ConvertToType( m_CurTime, Class_ID( TRIOBJ_CLASS_ID, 0 ) );
    }
    bool bReleaseTriObj = (pTriObj != pObject);
    if (!pTriObj) 
    {
        Warn( "Could not triangulate mesh in node <%s>. Node was skipped", node->GetName() );
        return;
    }

    if (!MeshModStackIsValid( node ))
    {
        Warn( "Modifier stack for node %s should be collapsed or contain only Skin modifier.", 
                node->GetName() );
    }

    //  ensure, that vertex winding direction in polygon is CCW
    Matrix3 objTM = node->GetObjTMAfterWSM( m_CurTime );
    bool bNegScale = (DotProd( CrossProd( objTM.GetRow(0), objTM.GetRow(1) ), objTM.GetRow(2) ) >= 0.0);

    int vx[3];
    if (bNegScale) 
    {
        vx[0] = 0; 
        vx[1] = 1; 
        vx[2] = 2; 
    } 
    else 
    { 
        vx[0] = 2; 
        vx[1] = 1; 
        vx[2] = 0; 
    }

    Mesh& mesh = pTriObj->GetMesh();

    bool bHasTexCoord    = (mesh.numTVerts != 0);
    bool bHasVertexColor = (mesh.numCVerts != 0) && m_pConfig->m_bExportVertexColors;
    bool bHasNormal      = m_pConfig->m_bExportNormals; 
    bool bHasSkin        = ProcessSkin( node );

    //  some cosmetics
    BOOL res = mesh.RemoveDegenerateFaces();
    if (res) 
    {
        Spam( "Degenerate faces were fixed." );
    }

    res = mesh.RemoveIllegalFaces();
    if (res) 
    {
        Spam( "Degenerate indices were fixed." );
    }
    
    ExpNode* pExpNode = GetExportedNode( node );
    if (!pExpNode)
    {
        return;
    }

    int numPri     = mesh.getNumFaces();
    int numVert    = mesh.numVerts;

    //  initialize helper array for building vertices' 0-circles
    VertexPtrArray vertexEntry;
    vertexEntry.resize( numVert );
    memset( &vertexEntry[0], 0, sizeof( ExpVertex* )*numVert );

    Spam( "Original mesh has %d vertices and %d faces.", numVert, numPri );
    bool bHasVoidFaces = false;

    //  loop on mesh faces
    for (int i = 0; i < numPri; i++)
    {
        Face& face = mesh.faces[i];

        //  calculate face normal
        const Point3& v0 = mesh.verts[face.v[vx[0]]]; 
        const Point3& v1 = mesh.verts[face.v[vx[1]]]; 
        const Point3& v2 = mesh.verts[face.v[vx[2]]]; 
        Point3 normal = -Normalize( (v1 - v0)^(v2 - v1) ); 
        normal = mOffs.VectorTransform( normal );
        normal = c_FlipTM.VectorTransform( normal );

        //  loop on face vertices
        ExpVertex* pFaceVertex[3];
        for (int j = 0; j < 3; j++)
        {
            ExpVertex v;
            v.mtlID  = pExpNode->GetMaterialIdx( face.getMatID() );            
            v.nodeID = pExpNode->m_Index;

            if (v.mtlID < 0)
            {
                bHasVoidFaces = true;
            }
            
            //  extract vertex position and apply world-space modifier to it
            int vIdx    = face.v[vx[j]];
            Point3 pt   = mesh.verts[vIdx];
            pt = mOffs.PointTransform( pt );
            pt = c_FlipTM.PointTransform( pt );
            
            v.index = vIdx;
            v.pos   = Vec3( pt.x, pt.y, pt.z );
            //v.pos *= m_WorldScale;

            //  extract skinning info
            if (bHasSkin)
            {
                GetSkinInfo( v );
            }

            //  assign normal
            if (bHasNormal)
            {
                v.normal  = Vec3( normal.x, normal.y, normal.z );
                v.smGroup = face.smGroup;
            }
            
            //  extract vertex colors
            if (bHasVertexColor)    
            {
                const VertColor& vcol = mesh.vertCol[mesh.vcFace[i].t[vx[j]]];
                v.color = ColorToDWORD( Color( vcol.x, vcol.y, vcol.z ) );
            }

            //  extract texture coordinates
            if (bHasTexCoord)   
            {
                const Point3& texCoord = mesh.tVerts[mesh.tvFace[i].t[vx[j]]];
                v.uv.x = texCoord.x;
                v.uv.y = 1.0f - texCoord.y;

                //  second texture coordinate channel
                if (mesh.getNumMaps() > 1 && mesh.mapSupport( 2 ))
                {
                    UVVert* pUVVert = mesh.mapVerts( 2 );
                    TVFace* pTVFace = mesh.mapFaces( 2 );
                    if (pUVVert && pTVFace)
                    {
                        const Point3& tc2 = pUVVert[pTVFace[i].t[vx[j]]];
                        v.uv2.x = tc2.x;
                        v.uv2.y = 1.0f - tc2.y;
                    }
                }
            }

            //  allocate new vertex 
            pFaceVertex[j] = AddVertex( v );

            //  we want vertices in the 0-ring neighborhood to be linked into closed linked list
            if (vertexEntry[vIdx] == NULL) 
            {
                vertexEntry[vIdx] = pFaceVertex[j];
                pFaceVertex[j]->pNext = pFaceVertex[j];
            }
            else
            {
                vertexEntry[vIdx]->AddToZeroRing( pFaceVertex[j] );
            }
        }
        AddPolygon( pFaceVertex[0], pFaceVertex[1], pFaceVertex[2] );

        if (IsCanceled())
        {
            return;
        }
    }

    //  correct normals at vertices corresponding to smoothing groups
    SmoothNormals( vertexEntry );

    //  put vertices into set (this removes duplicate vertices)
    for (int i = 0; i < numVert; i++)
    {
        ExpVertex::ZeroRingIterator it( vertexEntry[i] );
        while (it)
        {
            VertexSet::iterator sIt = m_VertexSet.find( it );
            if (sIt == m_VertexSet.end())
            {
                m_VertexSet.insert( it );
            }
            else
            {
                it->pBase = (*sIt);
            }
            ++it;
        }
    }

    if (bReleaseTriObj) 
    {
        delete pTriObj;
    }

    if (bHasVoidFaces)
    {
        Warn( "Mesh %s has faces with no material assigned.", node->GetName() );
    }
} // RBExport::ProcessMesh