mvIMPACT Acquire SDK C++
RequestFactory Class Reference

A default request factory. More...

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 )
{
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 default request factory.
Definition: mvIMPACT_acquire.h:10405
virtual Request * createRequest(Device *, int)
Definition: mvIMPACT_acquire.h:10408
Contains information about a captured buffer.
Definition: mvIMPACT_acquire.h:8426
Request & operator=(const Request &rhs)
Allows assignments of mvIMPACT::acquire::Request objects.
Definition: mvIMPACT_acquire.h:8726
EnumPropertyI< TRequestResult > PropertyIRequestResult
Defines a property for values defined by mvIMPACT::acquire::TRequestResult.
Definition: mvIMPACT_acquire.h:4495

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
}
This class and its functions represent an actual device detected by this interface in the current sys...
Definition: mvIMPACT_acquire.h:5938
Since
1.12.56

Constructor & Destructor Documentation

◆ ~RequestFactory()

virtual ~RequestFactory ( )
inlinevirtual

Member Function Documentation

◆ createRequest()

virtual Request* createRequest ( Device ,
int   
)
inlinevirtual

The documentation for this class was generated from the following file: