NCBI C++ ToolKit
data_loader_factory.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef DATA_LOADER_FACTORY__HPP
2 #define DATA_LOADER_FACTORY__HPP
3 
4 /* $Id: data_loader_factory.hpp 99428 2023-03-27 14:01:59Z ivanov $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author:
30 *
31 * File Description:
32 *
33 */
34 
35 
36 #include <corelib/ncbistd.hpp>
37 #include <corelib/ncbiobj.hpp>
40 #include <objmgr/data_loader.hpp>
41 
42 
45 
46 class CDataLoader;
47 
48 /////////////////////////////////////////////////////////////////////////////
49 
50 // Name of parameters used by all factories
51 
52 // pointer
53 #define kCFParam_ObjectManagerPtr "ObjectManagerPtr"
54 // int
55 #define kCFParam_DataLoader_Priority "DataLoader_Priority"
56 
57 // string: any value except "Default" results in eNonDefault
58 #define kCFParam_DataLoader_IsDefault "DataLoader_IsDefault"
59 
60 
62  : public IClassFactory<CDataLoader>
63 {
64 public:
68 
69  CDataLoaderFactory(const string& driver_name, int patch_level = -1);
70  virtual ~CDataLoaderFactory() {}
71 
72  const string& GetDriverName(void) const { return m_DriverName; }
73  void GetDriverVersions(TDriverList& info_list) const;
74 
75  CDataLoader*
76  CreateInstance(const string& driver = kEmptyStr,
78  const TPluginManagerParamTree* params = 0) const;
79 
80 protected:
81  // True if params != 0 and node name corresponds to expected name
82  bool ValidParams(const TPluginManagerParamTree* params) const;
83 
86  const TPluginManagerParamTree* params) const = 0;
87 
88  CObjectManager::EIsDefault GetIsDefault(
89  const TPluginManagerParamTree* params) const;
90  CObjectManager::TPriority GetPriority(
91  const TPluginManagerParamTree* params) const;
92 
93 private:
94  CObjectManager* x_GetObjectManager(
95  const TPluginManagerParamTree* params) const;
96 
98  string m_DriverName;
99 };
100 
101 
102 template <class TDataLoader>
104 {
105 public:
106  CSimpleDataLoaderFactory(const string& name)
107  : CDataLoaderFactory(name)
108  {
109  return;
110  }
112  return;
113  }
114 
115 protected:
118  const TPluginManagerParamTree* params) const
119  {
120  return TDataLoader::RegisterInObjectManager(
121  om,
122  GetIsDefault(params),
123  GetPriority(params)).GetLoader();
124  }
125 };
126 
127 
130 
131 #endif // DATA_LOADER_FACTORY__HPP
CVersionInfo m_DriverVersionInfo
IClassFactory< CDataLoader > TParent
CObjectManager::TPriority GetPriority(const TPluginManagerParamTree *params) const
const string & GetDriverName(void) const
TParent::SDriverInfo TDriverInfo
CObjectManager::EIsDefault GetIsDefault(const TPluginManagerParamTree *params) const
TParent::TDriverList TDriverList
virtual CDataLoader * CreateAndRegister(CObjectManager &om, const TPluginManagerParamTree *params) const =0
CObjectManager –.
virtual CDataLoader * CreateAndRegister(CObjectManager &om, const TPluginManagerParamTree *params) const
CSimpleDataLoaderFactory(const string &name)
definition of a Culling tree
Definition: ncbi_tree.hpp:100
CVersionInfo –.
IClassFactory<> –.
Include a standard set of the NCBI C++ Toolkit most basic headers.
EIsDefault
Flag defining if the data loader is included in the "default" group.
virtual void GetDriverVersions(TDriverList &driver_list) const =0
Versions of the interface exported by the factory.
virtual TClass * CreateInstance(const string &driver=kEmptyStr, CVersionInfo version=GetDefaultDrvVers(), const TPluginManagerParamTree *params=0) const =0
Create driver's instance.
#define NCBI_INTERFACE_VERSION(iface)
Macro to construct CVersionInfo class using interface name (relies on CInterfaceVersion class)
list< SDriverInfo > TDriverList
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define kEmptyStr
Definition: ncbistr.hpp:123
#define NCBI_XOBJMGR_EXPORT
Definition: ncbi_export.h:1307
static int version
Definition: mdb_load.c:29
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
The Object manager core.
Plugin manager (using class factory paradigm).
CRef< objects::CObjectManager > om
Modified on Mon Jul 15 05:36:19 2024 by modify_doxy.py rev. 669887