Impact Acquire SDK C++
RequestFactory Class Reference

A default request factory. More...

#include <mvIMPACT_acquire.h>

Public Member Functions

virtual RequestcreateRequest (Device *, int)
 
virtual ~RequestFactory ()
 

Detailed Description

A default request factory.

Applications need to derive from this class and must re-implement the function mvIMPACT::acquire::RequestFactory::createRequest to work with custom objects derived from mvIMPACT::acquire::Request.

Deriving from mvIMPACT::acquire::Request can be useful when a certain device driver or device offers a custom feature that is returned as part of the request object that can not be accessed using the mvIMPACT::acquire::Request class offered by this interface.

This shows how a request factory could be used to create custom request objects from within a mvIMPACT::acquire::FunctionInterface instance.

class MyRequestFactory;
//-----------------------------------------------------------------------------
// Example for a derived request object. It doesn't introduce new functionality
// but rebinds an existing property. Custom properties could bound in a similar
// way.
class MyRequest : public mvIMPACT::acquire::Request
//-----------------------------------------------------------------------------
{
friend class MyRequestFactory;
void init( void )
{
DeviceComponentLocator locator(getComponentLocator());
locator.bindComponent( myRequestResult, "Result" );
}
protected:
explicit MyRequest( Device* pDev, int requestNr ) : Request(pDev, requestNr), myRequestResult()
{
init();
}
public:
explicit MyRequest( const MyRequest& src ) : Request(src), myRequestResult(src.myRequestResult) {}
MyRequest& operator=( const MyRequest& rhs )
{
if( this != &rhs )
{
Request::operator=( rhs );
init();
}
return *this;
}
PropertyIRequestResult myRequestResult;
};
//-----------------------------------------------------------------------------
// Example for a factory that creates 'MyRequest' instances
class MyRequestFactory : public mvIMPACT::acquire::RequestFactory
//-----------------------------------------------------------------------------
{
public:
virtual mvIMPACT::acquire::Request* createRequest( Device* pDev, int requestNr ) { return new MyRequest( pDev, requestNr ); }
};
A class to locate components within the driver.
Definition mvIMPACT_acquire.h:8043
This class and its functions represent an actual device detected by this interface in the current sys...
Definition mvIMPACT_acquire.h:6118
A default request factory.
Definition mvIMPACT_acquire.h:10717
Contains information about a captured buffer.
Definition mvIMPACT_acquire.h:8640
EnumPropertyI< TRequestResult > PropertyIRequestResult
Defines a property for values defined by mvIMPACT::acquire::TRequestResult.
Definition mvIMPACT_acquire.h:4640

Now the request factory must be passed to the constructor of the function interface

//-----------------------------------------------------------------------------
void fn( mvIMPACT::acquire::Device* pDev )
//-----------------------------------------------------------------------------
{
// ... some code ...
MyRequestFactory mrf;
FunctionInterface fi(pDev, &mrf);
// ... more additional code
// assuming we got back a request from the driver at this point:
const Request* pRequest = fi.getRequest( getRequestNrFromSomewhere() );
if( pRequest->isOK() )
{
const MyRequest* pMyRequest(dynamic_cast<const MyRequest*>(pRequest));
cout << pMyRequest->myRequestResult.name() << ": " << pMyRequest->myRequestResult.readS() << endl;
// do what you want to do with your derived request instance here!
}
// ... probably even more additional code
}
The function interface to devices supported by this interface.
Definition mvIMPACT_acquire.h:10758
bool isOK(void) const
Convenience function to check if a request has been processed successfully.
Definition mvIMPACT_acquire.h:9474
Since
1.12.56

Constructor & Destructor Documentation

◆ ~RequestFactory()

virtual ~RequestFactory ( )
inlinevirtual

Member Function Documentation

◆ createRequest()

virtual Request * createRequest ( Device * ,
int  )
inlinevirtual