Ejemplo n.º 1
0
int AcceptHandler::handle_input(ACE_HANDLE) {
    ACE_TRACE("AcceptHandler::handle_input(ACE_HANDLE)");

    ACE_INET_Addr clientAddr;

    // create a new ReadHandler
    ReadHandler *reader = 0;
    ACE_NEW_NORETURN (reader, ReadHandler());
    if (reader == 0)
      ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: Failed to allocate ")
                        ACE_TEXT ("reader. (errno = %i: %m)\n"), errno), -1);

    // put reader in an auto pointer so we can use ACE_ERROR_RETURN safely
    auto_ptr<ReadHandler> pReader(reader);

    // accept the connection using the reader's stream
    if (mAcceptor.accept(reader->getStream(), &clientAddr) == -1)
      ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: Failed to accept ")
                    ACE_TEXT ("client connection. (errno = %i: %m)\n"), errno), -1);

    // register the reader with the reactor
    if (mReactor->register_handler(reader,
            ACE_Event_Handler::READ_MASK) == -1)
      ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: Failed to register ")
                        ACE_TEXT ("read handler. (errno = %i: %m)\n"), errno), -1);

    // from now on the read handler takes care of itself
    pReader.release();

    return 0; // keep going
}
Ejemplo n.º 2
0
/*++

Routine Name:

    CRemoteDictionary::WriteData

Routine Description:

    This method handles the parsing of a new dictionary and
    the writing out the new dictionary

Arguments:

    pWriter - Pointer to a stream to write the resource out to

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CRemoteDictionary::WriteData(
    _In_ IPartBase*         pResource,
    _In_ IPrintWriteStream* pWriter
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(pResource, E_POINTER)) &&
        SUCCEEDED(hr = CHECK_POINTER(pWriter, E_POINTER)))
    {
        try
        {
            CComPtr<IUnknown>                pRead(NULL);
            CComPtr<IPartResourceDictionary> pResDictPart(NULL);
            CComPtr<IPrintReadStream>        pReader(NULL);

            if (SUCCEEDED(hr = m_pFixedPage->GetPagePart(m_bstrDictionaryURI, &pRead)) &&
                SUCCEEDED(hr = pRead->QueryInterface(&pResDictPart)) &&
                SUCCEEDED(hr = pResDictPart->GetStream(&pReader)))
            {
                //
                // Create a SAX handler to parse the markup in the fixed page
                //
                CCMSaxHandler cmSaxHndlr(pWriter, m_pBmpConverter, m_pRefConverter, NULL);

                //
                // Set-up the SAX reader and begin parsing the mark-up
                //
                CComPtr<ISAXXMLReader> pSaxRdr(NULL);

                if (SUCCEEDED(hr = pSaxRdr.CoCreateInstance(CLSID_SAXXMLReader60)) &&
                    SUCCEEDED(hr = pSaxRdr->putContentHandler(&cmSaxHndlr)))
                {
                    CComPtr<ISequentialStream> pReadStreamToSeq(NULL);

                    pReadStreamToSeq.Attach(new pfp::PrintReadStreamToSeqStream(pReader));

                    if (SUCCEEDED(hr = CHECK_POINTER(pReadStreamToSeq, E_OUTOFMEMORY)))
                    {
                        hr = pSaxRdr->parse(CComVariant(static_cast<ISequentialStream*>(pReadStreamToSeq)));
                    }
                }
            }
        }
        catch (CXDException& e)
        {
            hr = e;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Ejemplo n.º 3
0
//  ----------------------------------------------------------------------------
void CMultiReaderApp::xProcessDefault(
    const CArgs& args,
    CNcbiIstream& istr,
    CNcbiOstream& ostr)
//  ----------------------------------------------------------------------------
{
    auto_ptr<CReaderBase> pReader(CReaderBase::GetReader(m_uFormat, m_iFlags));
    if (!pReader.get()) {
        NCBI_THROW2(CObjReaderParseException, eFormat,
            "File format not supported", 0);
    }
    CRef<CSerialObject> object = pReader->ReadObject(istr, m_pErrors);
    xWriteObject(*object, ostr);
}
Ejemplo n.º 4
0
bool hasZeros (double minx, double miny, double maxx, double maxy, double normx, double normy) {
	pdal::Options readerOptions;
	readerOptions.add("connection", "host='localhost' dbname='lidar' user='******'");
	readerOptions.add("table", "lidar");
	readerOptions.add("column", "pa");
	readerOptions.add("srid", 3857);

	char buf [4096];
	snprintf(buf, sizeof(buf) - 1,
			"PC_Intersects(pa, ST_MakeEnvelope(%lf,%lf,%lf,%lf,3857))",
			minx, miny, maxx, maxy);
	buf[sizeof(buf) - 1] = 0;
	readerOptions.add("where", buf);


	boost::shared_ptr<pdal::drivers::pgpointcloud::Reader> pReader(new
			pdal::drivers::pgpointcloud::Reader(readerOptions));

	pReader->initialize();
	std::cout << "Query: " << buf << " ::: " << pReader->getNumPoints() << " points" << std::endl;

	pdal::PointBuffer pbuf(pReader->getSchema(), pReader->getNumPoints());
	pdal::StageSequentialIterator* iterator = pReader->createSequentialIterator(pbuf);
	iterator->read(pbuf);

	//std::cout << pbuf.getSchema() << std::endl;

	// read in points
	pdal::Dimension const& x = pbuf.getSchema().getDimension("X");
	pdal::Dimension const& y = pbuf.getSchema().getDimension("Y");
	pdal::Dimension const& z = pbuf.getSchema().getDimension("Z");

	size_t origin_points = 0;
	for (size_t i = 0, il = pReader->getNumPoints() ; i < il ; i ++) {
		float x_ = static_cast<float>(x.applyScaling(pbuf.getField<int>(x, i))) - normx,
			  y_ = static_cast<float>(y.applyScaling(pbuf.getField<int>(y, i))) - normy,
			  z_ = static_cast<float>(z.applyScaling(pbuf.getField<int>(z, i)));



		if (closeToZero(x_) &&
			closeToZero(y_)) {
				origin_points ++;
		}

	}
	std::cout << "Volume point stats: origin: " << origin_points << std::endl;
	return origin_points > 0;
}