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

Go to the SVN repository for this file.

1 /* $Id: data_loader_factory.cpp 38407 2008-07-01 17:39:23Z vasilche $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Aleksey Grichenko, Eugene Vasilchenko
27 *
28 * File Description:
29 * Data loader factory
30 *
31 */
32 
33 #include <ncbi_pch.hpp>
35 
36 
39 
40 
42  int patch_level)
43  : m_DriverVersionInfo(
46  patch_level >= 0 ?
47  patch_level : ncbi::CInterfaceVersion<CDataLoader>::ePatchLevel),
48  m_DriverName(driver_name)
49 {
50  _ASSERT(!m_DriverName.empty());
51 }
52 
53 
55 {
56  info_list.push_back(TDriverInfo(m_DriverName, m_DriverVersionInfo));
57 }
58 
59 
61  const string& driver,
63  const TPluginManagerParamTree* params) const
64 {
65  CDataLoader* loader = 0;
66  if (driver.empty() || driver == m_DriverName) {
70  _ASSERT(om);
71  loader = CreateAndRegister(*om, params);
72  }
73  }
74  return loader;
75 }
76 
77 
79  const TPluginManagerParamTree* params) const
80 {
81  string om_str = params ?
82  GetParam(m_DriverName, params, kCFParam_ObjectManagerPtr, false, "0") :
83  kEmptyStr;
84  CObjectManager* om = static_cast<CObjectManager*>(
85  const_cast<void*>(NStr::StringToPtr(om_str)));
86  return om ? om : &*CObjectManager::GetInstance();
87 }
88 
89 
91  const TPluginManagerParamTree* params) const
92 {
93  string def_str =
95  "NonDefault");
96  return (NStr::CompareNocase(def_str, "Default") == 0) ?
98 }
99 
100 
102  const TPluginManagerParamTree* params) const
103 {
104  string priority_str =
107  return NStr::StringToInt(priority_str);
108 }
109 
110 
112  const TPluginManagerParamTree* params) const
113 {
114  if (!params) {
115  return false;
116  }
117  return true;
118 }
119 
120 
CVersionInfo m_DriverVersionInfo
void GetDriverVersions(TDriverList &info_list) const
CObjectManager::TPriority GetPriority(const TPluginManagerParamTree *params) const
TParent::SDriverInfo TDriverInfo
CObjectManager::EIsDefault GetIsDefault(const TPluginManagerParamTree *params) const
bool ValidParams(const TPluginManagerParamTree *params) const
TParent::TDriverList TDriverList
virtual CDataLoader * CreateAndRegister(CObjectManager &om, const TPluginManagerParamTree *params) const =0
CObjectManager * x_GetObjectManager(const TPluginManagerParamTree *params) const
CDataLoader * CreateInstance(const string &driver=kEmptyStr, CVersionInfo version=NCBI_INTERFACE_VERSION(CDataLoader), const TPluginManagerParamTree *params=0) const
Create driver's instance.
CInterfaceVersion<> –.
CObjectManager –.
definition of a Culling tree
Definition: ncbi_tree.hpp:100
CVersionInfo –.
#define kCFParam_ObjectManagerPtr
#define kCFParam_DataLoader_Priority
#define kCFParam_DataLoader_IsDefault
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
EIsDefault
Flag defining if the data loader is included in the "default" group.
@ kPriority_Default
Use default priority for added data.
#define NCBI_INTERFACE_VERSION(iface)
Macro to construct CVersionInfo class using interface name (relies on CInterfaceVersion class)
string GetParam(const string &driver_name, const TPluginManagerParamTree *params, const string &param_name, bool mandatory, const string &default_value) const
Utility function to get an element of parameter tree Throws an exception when mandatory parameter is ...
#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
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
Definition: ncbistr.cpp:219
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static const void * StringToPtr(const CTempStringEx str, TStringToNumFlags flags=0)
Convert string to pointer.
Definition: ncbistr.cpp:2781
@ eNonCompatible
major, minor does not match
static int version
Definition: mdb_load.c:29
Magic spell ;-) needed for some weird compilers... very empiric.
CRef< objects::CObjectManager > om
#define _ASSERT
#define const
Definition: zconf.h:232
Modified on Wed Jun 19 17:00:57 2024 by modify_doxy.py rev. 669887