TlFactory.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2006-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: AH
  6. //-----------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief Definition of CTlFactory class
  10. */
  11. #ifndef __TLFACTORY_H__
  12. #define __TLFACTORY_H__
  13. #if _MSC_VER>1000
  14. #pragma once
  15. #endif // _MSC_VER>1000
  16. #include <pylon/Platform.h>
  17. #ifdef _MSC_VER
  18. # pragma pack(push, PYLON_PACKING)
  19. #endif /* _MSC_VER */
  20. #include <pylon/stdinclude.h>
  21. #include <pylon/PylonBase.h>
  22. #include <pylon/TlInfo.h>
  23. #include <pylon/TransportLayer.h>
  24. #include <pylon/DeviceFactory.h>
  25. namespace Pylon
  26. {
  27. // forwards
  28. class CSimpleMutex;
  29. class CTlInfo;
  30. interface ITransportLayer;
  31. interface IDeviceFactory;
  32. class TlMap;
  33. class ImplicitTlRefs;
  34. //------------------------------------------------------------------------
  35. // class CTlFactory
  36. //------------------------------------------------------------------------
  37. /*!
  38. \ingroup Pylon_TransportLayer
  39. \brief the Transport Layer Factory
  40. Creates, Destroys and Enumerates transport layers as well as
  41. their devices.
  42. */
  43. class PYLONBASE_API CTlFactory : public IDeviceFactory
  44. {
  45. public:
  46. ///////////////////////////////////////////////////////////////////////
  47. /// Retrieve the transport layer factory singleton.
  48. /// Throws an exception when Pylon::PylonInitialize() has not been called before.
  49. static CTlFactory& GetInstance();
  50. /**
  51. \brief Retrieves a list of available transport layers.
  52. The list contains Pylon::CTlInfo objects used for transport layer creation.
  53. \param list List to be filled with transport layer info objects.
  54. \return Number of transport layers found.
  55. */
  56. int EnumerateTls( TlInfoList_t& list );
  57. /**
  58. \brief Creates a transport layer object from a transport layer info object.
  59. This method accepts a transport layer info object which can be obtained by calling EnumerateTls.
  60. For each successfully returned transport layer object, you must call ReleaseTl to free the transport layer object.
  61. If the creation fails, a GenApi::GenericException will be thrown.
  62. \param ti Transport layer info object specifying which transport layer to create.
  63. \return Pointer to the transport layer object created. If no matching transport layer could be found, NULL will be returned.
  64. */
  65. ITransportLayer* CreateTl( const CTlInfo& ti );
  66. /**
  67. \brief Creates a transport layer object from a device class string.
  68. This method accepts a device class string. You can see a list of available device classes in the DeviceClass.h file.
  69. For each successfully returned transport layer object, you must call ReleaseTl to free the transport layer object.
  70. If the creation fails, a GenApi::GenericException will be thrown.
  71. \param deviceClass Transport layer info object specifying which transport layer to create.
  72. \return Pointer to the transport layer object created. If no matching transport layer could be found, NULL will be returned.
  73. */
  74. ITransportLayer* CreateTl( const String_t& deviceClass );
  75. /**
  76. \brief Releases a transport layer object created by a call to CreateTl().
  77. For each successfully returned transport layer object from any CreateTl() function,
  78. you must call this function to free the transport layer object.
  79. \param pTl Pointer to the transport layer object to be released.
  80. */
  81. void ReleaseTl( const ITransportLayer* pTl );
  82. // returns a list of available devices, see IDeviceFactory for more information
  83. virtual int EnumerateDevices( DeviceInfoList_t&, bool addToList = false );
  84. // returns a list of available devices that match the filter, see IDeviceFactory for more information
  85. virtual int EnumerateDevices( DeviceInfoList_t& list, const DeviceInfoList_t& filter, bool addToList = false );
  86. // creates a device from a device info object, see IDeviceFactory for more information
  87. virtual IPylonDevice* CreateDevice( const CDeviceInfo& di );
  88. // creates first found device from a device info object, see IDeviceFactory for more information
  89. virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di = CDeviceInfo() );
  90. // creates a device from a device info object, injecting additional GenICam XML definition strings
  91. virtual IPylonDevice* CreateDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings );
  92. // creates first found device from a device info object, injecting additional GenICam XML definition strings
  93. virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings );
  94. // Use CreateDevice and pass a CDeviceInfo object containing the full name as a property.
  95. // example: IPylonDevice* device = TlFactory.CreateDevice(CDeviceInfo().SetFullName(fullname));
  96. // creates a device that matches its full name (i.e., as returned by CDeviceInfo::GetFullName).
  97. virtual IPylonDevice* CreateDevice( const String_t& );
  98. // destroys a device
  99. virtual void DestroyDevice( IPylonDevice* );
  100. // implements IDeviceFactory::IsDeviceAccessible
  101. virtual bool IsDeviceAccessible( const CDeviceInfo& deviceInfo, AccessModeSet mode = Control, EDeviceAccessiblityInfo* pAccessibilityInfo = NULL );
  102. protected:
  103. void InternalEnumerateTls( TlInfoList_t& );
  104. virtual IPylonDevice* InternalCreateDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings, bool allowAnyFirstFound );
  105. TlMap* m_pTls;
  106. ImplicitTlRefs* m_pImplicitlyCreatedTls;
  107. CSimpleMutex* m_pMemberLock;
  108. private:
  109. void Terminate( void );
  110. void checkInitialized( void ); // fires an exception when Terminate() already has been called
  111. CTlFactory( void );
  112. CTlFactory& operator=( const CTlFactory& );
  113. CTlFactory( const CTlFactory& );
  114. virtual ~CTlFactory( void );
  115. friend void Pylon::PylonInitialize();
  116. friend void Pylon::PylonTerminate( bool );
  117. friend void Pylon::SetProperty( int propertyId, const void* pData, size_t size );
  118. friend void Pylon::GetProperty( int propertyId, void* pData, size_t* pSize );
  119. };
  120. }
  121. #ifdef _MSC_VER
  122. # pragma pack(pop)
  123. #endif /* _MSC_VER */
  124. #endif /* __TLFACTORY_H__ */