metaproxy  1.21.0
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
metaproxy_1::filter::Multi Class Reference

#include <filter_multi.hpp>

Inheritance diagram for metaproxy_1::filter::Multi:
Inheritance graph
Collaboration diagram for metaproxy_1::filter::Multi:
Collaboration graph

Classes

struct  Backend
 
struct  BackendSet
 
struct  Frontend
 
struct  FrontendSet
 
class  Map
 
class  Rep
 
struct  ScanTermInfo
 

Public Member Functions

 ~Multi ()
 
 Multi ()
 
void process (metaproxy_1::Package &package) const
 
void configure (const xmlNode *ptr, bool test_only, const char *path)
 
void add_map_host2hosts (std::string host, std::list< std::string > hosts, std::string route)
 

Private Types

typedef std::list< ScanTermInfoScanTermInfoList
 
typedef boost::shared_ptr< BackendBackendPtr
 
typedef boost::shared_ptr< FrontendFrontendPtr
 
typedef boost::shared_ptr< Package > PackagePtr
 
typedef std::map< std::string, FrontendSet >::iterator Sets_it
 

Private Attributes

boost::scoped_ptr< Repm_p
 

Detailed Description

Definition at line 32 of file filter_multi.hpp.

Member Typedef Documentation

◆ BackendPtr

typedef boost::shared_ptr<Backend> metaproxy_1::filter::Multi::BackendPtr
private

Definition at line 41 of file filter_multi.hpp.

◆ FrontendPtr

typedef boost::shared_ptr<Frontend> metaproxy_1::filter::Multi::FrontendPtr
private

Definition at line 42 of file filter_multi.hpp.

◆ PackagePtr

typedef boost::shared_ptr<Package> metaproxy_1::filter::Multi::PackagePtr
private

Definition at line 43 of file filter_multi.hpp.

◆ ScanTermInfoList

Definition at line 40 of file filter_multi.hpp.

◆ Sets_it

typedef std::map<std::string,FrontendSet>::iterator metaproxy_1::filter::Multi::Sets_it
private

Definition at line 44 of file filter_multi.hpp.

Constructor & Destructor Documentation

◆ ~Multi()

mp::filter::Multi::~Multi ( )

Definition at line 240 of file filter_multi.cpp.

240  {
241 }

◆ Multi()

mp::filter::Multi::Multi ( )

Definition at line 236 of file filter_multi.cpp.

236  : m_p(new Multi::Rep)
237 {
238 }
boost::scoped_ptr< Rep > m_p

Member Function Documentation

◆ add_map_host2hosts()

void metaproxy_1::filter::Multi::add_map_host2hosts ( std::string  host,
std::list< std::string >  hosts,
std::string  route 
)

◆ configure()

void mp::filter::Multi::configure ( const xmlNode *  ptr,
bool  test_only,
const char *  path 
)

Definition at line 1283 of file filter_multi.cpp.

1285 {
1286  for (ptr = ptr->children; ptr; ptr = ptr->next)
1287  {
1288  if (ptr->type != XML_ELEMENT_NODE)
1289  continue;
1290  if (!strcmp((const char *) ptr->name, "target"))
1291  {
1292  std::string auth;
1293  std::string route = mp::xml::get_route(ptr, auth);
1294  std::string target = mp::xml::get_text(ptr);
1295  if (target.length() == 0)
1296  target = route;
1297  m_p->m_route_patterns.push_back(Multi::Map(target, route, auth));
1298  }
1299  else if (!strcmp((const char *) ptr->name, "hideunavailable"))
1300  {
1301  m_p->m_hide_unavailable = true;
1302  }
1303  else if (!strcmp((const char *) ptr->name, "hideerrors"))
1304  {
1305  m_p->m_hide_errors = true;
1306  }
1307  else if (!strcmp((const char *) ptr->name, "mergetype"))
1308  {
1309  std::string mergetype = mp::xml::get_text(ptr);
1310  if (mergetype == "roundrobin")
1311  m_p->m_merge_type = round_robin;
1312  else if (mergetype == "serveorder")
1313  m_p->m_merge_type = serve_order;
1314  else
1315  throw mp::filter::FilterException
1316  ("Bad mergetype " + mergetype + " in multi filter");
1317 
1318  }
1319  else
1320  {
1321  throw mp::filter::FilterException
1322  ("Bad element "
1323  + std::string((const char *) ptr->name)
1324  + " in multi filter");
1325  }
1326  }
1327 }

References metaproxy_1::filter::round_robin, and metaproxy_1::filter::serve_order.

◆ process()

void mp::filter::Multi::process ( metaproxy_1::Package &  package) const

Definition at line 1226 of file filter_multi.cpp.

1227 {
1228  FrontendPtr f = m_p->get_frontend(package);
1229 
1230  Z_GDU *gdu = package.request().get();
1231 
1232  if (gdu && gdu->which == Z_GDU_Z3950 && gdu->u.z3950->which ==
1233  Z_APDU_initRequest && !f->m_is_multi)
1234  {
1235  f->init(package, gdu);
1236  }
1237  else if (!f->m_is_multi)
1238  package.move();
1239  else if (gdu && gdu->which == Z_GDU_Z3950)
1240  {
1241  Z_APDU *apdu = gdu->u.z3950;
1242  if (apdu->which == Z_APDU_initRequest)
1243  {
1244  mp::odr odr;
1245 
1246  package.response() = odr.create_close(
1247  apdu,
1248  Z_Close_protocolError,
1249  "double init");
1250 
1251  package.session().close();
1252  }
1253  else if (apdu->which == Z_APDU_searchRequest)
1254  {
1255  f->search(package, apdu);
1256  }
1257  else if (apdu->which == Z_APDU_presentRequest)
1258  {
1259  f->present(package, apdu);
1260  }
1261  else if (apdu->which == Z_APDU_scanRequest)
1262  {
1263  f->scan(package, apdu);
1264  }
1265  else if (apdu->which == Z_APDU_close)
1266  {
1267  f->relay_apdu(package, apdu);
1268  }
1269  else
1270  {
1271  mp::odr odr;
1272 
1273  package.response() = odr.create_close(
1274  apdu, Z_Close_protocolError,
1275  "unsupported APDU in filter multi");
1276 
1277  package.session().close();
1278  }
1279  }
1280  m_p->release_frontend(package);
1281 }
boost::shared_ptr< Frontend > FrontendPtr

Member Data Documentation

◆ m_p

boost::scoped_ptr<Rep> metaproxy_1::filter::Multi::m_p
private

Definition at line 55 of file filter_multi.hpp.


The documentation for this class was generated from the following files: