<commit_before>#ifndef maciResolveHelper_H_
#define maciResolveHelper_H_

/*******************************************************************
* E.S.O. - ACS project
*
* "@(#) $Id: maciHelper.h,v 1.87 2006/10/03 03:31:04 sharring Exp $"
*
* who       when        what
* --------  ----------  ----------------------------------------------
* msekoran  2001/09/21  added getManagerHostname()
* msekoran  2001/08/29  created
*/

#ifndef __cplusplus
#error This is a C++ include file and cannot be used from plain C
#endif

#include <acsutil.h>
#include <maciExport.h>

#include <maciS.h>

#include <orbsvcs/CosNamingC.h>

#include <ace/SString.h>

#include <cdb.h>

#include <tao/IFR_Client/IFR_BasicC.h>

namespace maci {
 using namespace cdb;

/**
 * MACIHelper class is a class helping to handle commonly used operations.
 * @author <a href=mailto:<EMAIL>><NAME></a>,
 * Jozef Stefan Institute, Slovenia<br>
 * @version "@(#) $Id: maciHelper.h,v 1.87 2006/10/03 03:31:04 sharring Exp $"
 */

class maci_EXPORT MACIHelper
{

public:

  /**
   * Extract hostname from corbaloc address.
   * @param corbaloc corbaloc address
   * @return hostname or empty string on failure
   */
  static ACE_CString extractHostnameFromCorbaloc(const ACE_TCHAR *corbaloc);

  /**
   * <i>getManagerHostname</i> is a method helping to retrieve Manager's hostname.
   * The Manager hostame is extraced using the first valid of the following options:
   *    # Command line option <i>-m</i> or <i>-managerReference</i>
   *    # ManagerReference value in configuration database
   *    # Environment variable MANAGER_REFERENCE
   *    # hostname
   * 
   * @param argv command line parameter count
   * @param argc command line array of strings
   * @param cdb pointer to the configuration database, if 0 no CDB lookup will be done
   * @param cdbPrefix prefix to be added to the 'ManagerReference' field (e.g. ':Appl_data:MACI:Containers:Container')
   * @return Manager's hostname
   */
  static ACE_CString getManagerHostname(int argc, ACE_TCHAR **argv,
					Table * cdbTable, const ACE_TCHAR * cdbPrefix);

  /**
   * <i>resolveManager</i> method is a method helping to resolve Manager's reference.
   * The Manager reference is defined by the first valid of the following options:
   *    # Command line option <i>-m</i> or <i>-managerReference</i>
   *    # ManagerReference value in configuration database
   *    # Environment variable MANAGER_REFERENCE
   *    # corbaloc::<hostname>:xxxx/Manager
   * 
   * @param orb CORBA ORB
   * @param argv command line parameter count
   * @param argc command line array of strings
   * @param cdb pointer to the configuration database, if 0 no CDB lookup will be done
   * @param cdbPrefix prefix to be added to the 'ManagerReference' field (e.g. ':Appl_data:MACI:Containers:Container')
   * @param retries number of retries resolving Manager's reference, <= 0 means infinite
   * @param secTimeout timeout expressed in seconds, == 0 means inifinite (dt between retries is 3 secs)
   * @return CORBA reference to the Manager or maci::Manager::_nil() if unable to resolve Manager's reference
   */
  static maci::Manager_ptr resolveManager(CORBA::ORB_ptr orb,
					  int argc, ACE_TCHAR **argv,
					  Table * cdbTable, const ACE_TCHAR * cdbPrefix, 
					  int retries = 3, unsigned int secTimeout = 0);

  /**
   * <i>resolveManager</i> method resolve given stringified CORBA reference to the Maneger.
   * @param orb CORBA ORB
   * @param reference stringified CORBA reference to the Manager
   * @param retries number of retries resolving Manager reference, <= 0 means infinite
   * @param secTimeout timeout expressed in seconds, == 0 means inifinite (dt between retries is 3secs)
   * @return CORBA reference to the Manager or maci::Manager::_nil() if unable to resolve Manager reference
   */
  static maci::Manager_ptr resolveManager(CORBA::ORB_ptr orb,
					  const ACE_TCHAR * reference, 
					  int retries = 3, unsigned int secTimeout = 0);

  /**
   * <i>resolveNameService</i> method is a method helping to resolve CORBA NameService's reference.
   * The NameService reference is defined by the first valid of the following options:
   *    # Command line option <i>-ORBInitRef NameService=<corbaloc reference> (e.g. corbaloc::te1.hq.eso.org:xxxx)</i>
   *      using CORBA::ORB::resolve_initial_references("NameService"), ORB has to be already initialized with the command line
   *    # Environment variable NAMESERVICE_REFERENCE
   *    # corbaloc::<hostname>:xxxx/NameService
   * 
   * @param orb CORBA ORB
   * @param retries number of retries resolving NameService reference, <= 0 means infinite
   * @param secTimeout timeout expressed in seconds, == 0 means inifinite (dt between retries is 3secs)
   * @return CORBA reference to the NameService's root CosNaming::NamingContext
   */
  static CosNaming::NamingContext_ptr resolveNameService(CORBA::ORB_ptr orb,
							 int retries = 3, unsigned int secTimeout = 0);
  /**
   * <i>resolveNameService</i> method resolve given stringified CORBA reference to the NameService.
   * @param orb CORBA ORB
   * @param reference stringified CORBA reference to the NameService
   * @param retries number of retries resolving NameService reference, <= 0 means infinite
   * @param secTimeout timeout expressed in seconds, == 0 means inifinite (dt between retries is 3secs)
   * @return CORBA reference to the NameService's root CosNaming::NamingContext or CosNaming::NamingContext::_nil() if unable to resolve NameService reference
   */
  static CosNaming::NamingContext_ptr resolveNameService(CORBA::ORB_ptr orb,
							 const ACE_TCHAR * reference, 
							 int retries = 3, unsigned int secTimeout = 0);


  /**
   * <i>resolveInterfaceRepository</i> method is a method helping to resolve CORBA InterfaceRepository's reference.
   * The InterfaceRepository reference is defined by the first valid of the following options:
   *    # Command line option <i>-ORBInitRef InterfaceRepository=<corbaloc reference> (e.g. corbaloc::te1.hq.eso.org:xxxx)</i>
   *      using CORBA::ORB::resolve_initial_references("InterfaceRepository"), ORB has to be already initialized with the command line
   *    # Manager get_service("InterfaceRepository")
   *    # corbaloc::<manager's hostname>:xxxx/NameService
   *    # corbaloc::<hostname>:xxxx/NameService
   * 
   * @param orb CORBA ORB
   * @param manager Manager's reference.
   * @param argv command line parameter count
   * @param argc command line array of strings
   * @param cdb pointer to the configuration database, if 0 no CDB lookup will be done
   * @param cdbPrefix prefix to be added to the 'ManagerReference' field (e.g. ':Appl_data:MACI:Containers:Container')
   * @param retries number of retries resolving NameService reference, <= 0 means infinite
   * @param secTimeout timeout expressed in seconds, == 0 means inifinite (dt between retries is 3secs).   
   * @return CORBA reference to the InterfaceRepository or CORBA::Object::_nil()
   */
  static CORBA::Repository_ptr resolveInterfaceRepository(CORBA::ORB_ptr orb, maci::Manager_ptr manager,
							 int argc, ACE_TCHAR **argv,
							 Table * cdbTable, const ACE_TCHAR * cdbPrefix,
							 int retries = 3, unsigned int secTimeout = 0);

  /**<commit_msg>Removed CDB parameters from getManagerHostname, resolveManager, resolveInterfaceRepository because CDB field Container.ManagerReference has been removed and therefore CDB access is not needed. Note that even before, the CDB was retrieved from the manager, and the ManagerReference CDB attribute was useless.<commit_after>#ifndef maciResolveHelper_H_
#define maciResolveHelper_H_

/*******************************************************************
* E.S.O. - ACS project
*
* "@(#) $Id: maciHelper.h,v 1.88 2007/09/07 13:34:49 hsommer Exp $"
*
* who       when        what
* --------  ----------  ----------------------------------------------
* msekoran  2001/09/21  added getManagerHostname()
* msekoran  2001/08/29  created
*/

#ifndef __cplusplus
#error This is a C++ include file and cannot be used from plain C
#endif

#include <acsutil.h>
#include <maciExport.h>

#include <maciS.h>

#include <orbsvcs/CosNamingC.h>

#include <ace/SString.h>

#include <cdb.h>

#include <tao/IFR_Client/IFR_BasicC.h>

namespace maci {
 using namespace cdb;

/**
 * MACIHelper class is a class helping to handle commonly used operations.
 * @author <a href=mailto:<EMAIL>><NAME></a>,
 * Jozef Stefan Institute, Slovenia<br>
 * @version "@(#) $Id: maciHelper.h,v 1.88 2007/09/07 13:34:49 hsommer Exp $"
 */

class maci_EXPORT MACIHelper
{

public:

  /**
   * Extract hostname from corbaloc address.
   * @param corbaloc corbaloc address
   * @return hostname or empty string on failure
   */
  static ACE_CString extractHostnameFromCorbaloc(const ACE_TCHAR *corbaloc);

  /**
   * <i>getManagerHostname</i> is a method helping to retrieve Manager's hostname.
   * The Manager hostame is extraced using the first valid of the following options:
   *    # Command line option <i>-m</i> or <i>-managerReference</i>
   *    # ManagerReference value in configuration database
   *    # Environment variable MANAGER_REFERENCE
   *    # hostname
   * 
   * @param argv command line parameter count
   * @param argc command line array of strings
   * @return Manager's hostname
   */
  static ACE_CString getManagerHostname(int argc, ACE_TCHAR **argv);

  /**
   * <i>resolveManager</i> method is a method helping to resolve Manager's reference.
   * The Manager reference is defined by the first valid of the following options:
   *    # Command line option <i>-m</i> or <i>-managerReference</i>
   *    # ManagerReference value in configuration database
   *    # Environment variable MANAGER_REFERENCE
   *    # corbaloc::<hostname>:xxxx/Manager
   * 
   * @param orb CORBA ORB
   * @param argv command line parameter count
   * @param argc command line array of strings
   * @param retries number of retries resolving Manager's reference, <= 0 means infinite
   * @param secTimeout timeout expressed in seconds, == 0 means inifinite (dt between retries is 3 secs)
   * @return CORBA reference to the Manager or maci::Manager::_nil() if unable to resolve Manager's reference
   */
  static maci::Manager_ptr resolveManager(CORBA::ORB_ptr orb,
					  int argc, ACE_TCHAR **argv,
					  int retries = 3, unsigned int secTimeout = 0);

  /**
   * <i>resolveManager</i> method resolve given stringified CORBA reference to the Maneger.
   * @param orb CORBA ORB
   * @param reference stringified CORBA reference to the Manager
   * @param retries number of retries resolving Manager reference, <= 0 means infinite
   * @param secTimeout timeout expressed in seconds, == 0 means inifinite (dt between retries is 3secs)
   * @return CORBA reference to the Manager or maci::Manager::_nil() if unable to resolve Manager reference
   */
  static maci::Manager_ptr resolveManager(CORBA::ORB_ptr orb,
					  const ACE_TCHAR * reference, 
					  int retries = 3, unsigned int secTimeout = 0);

  /**
   * <i>resolveNameService</i> method is a method helping to resolve CORBA NameService's reference.
   * The NameService reference is defined by the first valid of the following options:
   *    # Command line option <i>-ORBInitRef NameService=<corbaloc reference> (e.g. corbaloc::te1.hq.eso.org:xxxx)</i>
   *      using CORBA::ORB::resolve_initial_references("NameService"), ORB has to be already initialized with the command line
   *    # Environment variable NAMESERVICE_REFERENCE
   *    # corbaloc::<hostname>:xxxx/NameService
   * 
   * @param orb CORBA ORB
   * @param retries number of retries resolving NameService reference, <= 0 means infinite
   * @param secTimeout timeout expressed in seconds, == 0 means inifinite (dt between retries is 3secs)
   * @return CORBA reference to the NameService's root CosNaming::NamingContext
   */
  static CosNaming::NamingContext_ptr resolveNameService(CORBA::ORB_ptr orb,
							 int retries = 3, unsigned int secTimeout = 0);
  /**
   * <i>resolveNameService</i> method resolve given stringified CORBA reference to the NameService.
   * @param orb CORBA ORB
   * @param reference stringified CORBA reference to the NameService
   * @param retries number of retries resolving NameService reference, <= 0 means infinite
   * @param secTimeout timeout expressed in seconds, == 0 means inifinite (dt between retries is 3secs)
   * @return CORBA reference to the NameService's root CosNaming::NamingContext or CosNaming::NamingContext::_nil() if unable to resolve NameService reference
   */
  static CosNaming::NamingContext_ptr resolveNameService(CORBA::ORB_ptr orb,
							 const ACE_TCHAR * reference, 
							 int retries = 3, unsigned int secTimeout = 0);


  /**
   * <i>resolveInterfaceRepository</i> method is a method helping to resolve CORBA InterfaceRepository's reference.
   * The InterfaceRepository reference is defined by the first valid of the following options:
   *    # Command line option <i>-ORBInitRef InterfaceRepository=<corbaloc reference> (e.g. corbaloc::te1.hq.eso.org:xxxx)</i>
   *      using CORBA::ORB::resolve_initial_references("InterfaceRepository"), ORB has to be already initialized with the command line
   *    # Manager get_service("InterfaceRepository")
   *    # corbaloc::<manager's hostname>:xxxx/NameService
   *    # corbaloc::<hostname>:xxxx/NameService
   * 
   * @param orb CORBA ORB
   * @param manager Manager's reference.
   * @param argv command line parameter count
   * @param argc command line array of strings
   * @param retries number of retries resolving NameService reference, <= 0 means infinite
   * @param secTimeout timeout expressed in seconds, == 0 means inifinite (dt between retries is 3secs).   
   * @return CORBA reference to the InterfaceRepository or CORBA::Object::_nil()
   */
  static CORBA::Repository_ptr resolveInterfaceRepository(CORBA::ORB_ptr orb, maci::Manager_ptr manager,
							 int argc, ACE_TCHAR **argv,
							 int retries = 3, unsigned int secTimeout = 0);

  /**
{'fraction_non_alphanumeric': 0.10699529847556633, 'fraction_numerical': 0.011183929334663058, 'mean_word_length': 3.8095238095238093, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6338037', 'n_tokens_mistral': 4434, 'n_tokens_neox': 4019, 'n_words': 1432}