0032203: Draw Harness, ViewerTest - drop dependency from OpenGL
[occt.git] / src / Graphic3d / Graphic3d_GraphicDriverFactory.hxx
1 // Copyright (c) 2021 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _Graphic3d_GraphicDriverFactory_HeaderFile
15 #define _Graphic3d_GraphicDriverFactory_HeaderFile
16
17 #include <NCollection_List.hxx>
18 #include <Standard_Type.hxx>
19 #include <TCollection_AsciiString.hxx>
20
21 class Aspect_DisplayConnection;
22 class Graphic3d_GraphicDriver;
23 class Graphic3d_GraphicDriverFactory;
24 typedef NCollection_List<Handle(Graphic3d_GraphicDriverFactory)> Graphic3d_GraphicDriverFactoryList;
25
26 //! This class for creation of Graphic3d_GraphicDriver.
27 class Graphic3d_GraphicDriverFactory : public Standard_Transient
28 {
29   DEFINE_STANDARD_RTTIEXT(Graphic3d_GraphicDriverFactory, Standard_Transient)
30 public:
31
32   //! Registers factory.
33   //! @param theFactory     [in] factory to register
34   //! @param theIsPreferred [in] add to the beginning of the list when TRUE, or add to the end otherwise
35   Standard_EXPORT static void RegisterFactory (const Handle(Graphic3d_GraphicDriverFactory)& theFactory,
36                                                bool theIsPreferred = false);
37
38   //! Unregisters factory.
39   Standard_EXPORT static void UnregisterFactory (const TCollection_AsciiString& theName);
40
41   //! Return default driver factory or NULL if no one was registered.
42   Standard_EXPORT static Handle(Graphic3d_GraphicDriverFactory) DefaultDriverFactory();
43
44   //! Return the global map of registered driver factories.
45   Standard_EXPORT static const Graphic3d_GraphicDriverFactoryList& DriverFactories();
46
47 public:
48
49   //! Creates new empty graphic driver.
50   virtual Handle(Graphic3d_GraphicDriver) CreateDriver (const Handle(Aspect_DisplayConnection)& theDisp) = 0;
51
52   //! Return driver factory name.
53   const TCollection_AsciiString& Name() const { return myName; }
54
55 protected:
56
57   //! Empty constructor.
58   Standard_EXPORT Graphic3d_GraphicDriverFactory (const TCollection_AsciiString& theName);
59
60 protected:
61
62   TCollection_AsciiString myName;
63
64 };
65
66 #endif // _Graphic3d_GraphicDriverFactory_HeaderFile