Skip to content

pylon/TlFactory.h#

Definition of CTlFactory class.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::CTlFactory
the Transport Layer Factory

Source code#

//-----------------------------------------------------------------------------
//  Basler pylon SDK
//  Copyright (c) 2006-2022 Basler AG
//  http://www.baslerweb.com
//  Author:  AH
//-----------------------------------------------------------------------------
#ifndef __TLFACTORY_H__
#define __TLFACTORY_H__

#if _MSC_VER>1000
#pragma once
#endif // _MSC_VER>1000

#include <pylon/Platform.h>

#ifdef _MSC_VER
#   pragma pack(push, PYLON_PACKING)
#endif /* _MSC_VER */

#include <pylon/stdinclude.h>
#include <pylon/PylonBase.h>
#include <pylon/TlInfo.h>
#include <pylon/TransportLayer.h>
#include <pylon/DeviceFactory.h>


namespace Pylon
{
    // forwards
    class CSimpleMutex;
    class CTlInfo;
    interface ITransportLayer;
    interface IDeviceFactory;
    class TlMap;
    class ImplicitTlRefs;

    //------------------------------------------------------------------------
    // class CTlFactory
    //------------------------------------------------------------------------
    class PYLONBASE_API CTlFactory : public IDeviceFactory
    {
    public:
        static CTlFactory& GetInstance();

        int EnumerateTls( TlInfoList_t& list );

        ITransportLayer* CreateTl( const CTlInfo& ti );

        ITransportLayer* CreateTl( const String_t& deviceClass );

        void ReleaseTl( const ITransportLayer* pTl );

        // returns a list of available devices, see IDeviceFactory for more information
        virtual int EnumerateDevices( DeviceInfoList_t&, bool addToList = false );

        // returns a list of available devices that match the filter, see IDeviceFactory for more information
        virtual int EnumerateDevices( DeviceInfoList_t& list, const DeviceInfoList_t& filter, bool addToList = false );

        // creates a device from a device info object, see IDeviceFactory for more information
        virtual IPylonDevice* CreateDevice( const CDeviceInfo& di );

        // creates first found device from a device info object, see IDeviceFactory for more information
        virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di = CDeviceInfo() );

        // creates a device from a device info object, injecting additional GenICam XML definition strings
        virtual IPylonDevice* CreateDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings );

        // creates first found device from a device info object, injecting additional GenICam XML definition strings
        virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings );

        // Use CreateDevice and pass a CDeviceInfo object containing the full name as a property.
        // example: IPylonDevice* device = TlFactory.CreateDevice(CDeviceInfo().SetFullName(fullname));
        // creates a device that matches its full name (i.e., as returned by CDeviceInfo::GetFullName).
        virtual IPylonDevice* CreateDevice( const String_t& );

        // destroys a device
        virtual void DestroyDevice( IPylonDevice* );

        // implements IDeviceFactory::IsDeviceAccessible
        virtual bool IsDeviceAccessible( const CDeviceInfo& deviceInfo, AccessModeSet mode = Control, EDeviceAccessiblityInfo* pAccessibilityInfo = NULL );

    protected:
        void InternalEnumerateTls( TlInfoList_t& );
        virtual IPylonDevice* InternalCreateDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings, bool allowAnyFirstFound );

        TlMap* m_pTls;
        ImplicitTlRefs* m_pImplicitlyCreatedTls;
        CSimpleMutex* m_pMemberLock;

    private:
        void Terminate( void );
        void checkInitialized( void ); // fires an exception when Terminate() already has been called

        CTlFactory( void );
        CTlFactory& operator=( const CTlFactory& );
        CTlFactory( const CTlFactory& );

        virtual ~CTlFactory( void );

        friend void Pylon::PylonInitialize();
        friend void Pylon::PylonTerminate( bool );
        friend void Pylon::SetProperty( int propertyId, const void* pData, size_t size );
        friend void Pylon::GetProperty( int propertyId, void* pData, size_t* pSize );
    };

}

#ifdef _MSC_VER
#   pragma pack(pop)
#endif /* _MSC_VER */

#endif /* __TLFACTORY_H__ */

Updated on 5 July 2022 at 15:30:01