NCBI C++ ToolKit
Classes | Macros | Enumerations | Functions | Variables
ncbiapp.cpp File Reference
#include <ncbi_pch.hpp>
#include <common/ncbi_source_ver.h>
#include <corelib/ncbiapp.hpp>
#include <corelib/ncbifile.hpp>
#include <corelib/ncbi_system.hpp>
#include <corelib/ncbi_param.hpp>
#include <corelib/syslog.hpp>
#include <corelib/error_codes.hpp>
#include <corelib/ncbi_safe_static.hpp>
#include <corelib/request_ctx.hpp>
#include "ncbisys.hpp"
#include <corelib/ncbi_os_mswin.hpp>
#include <corelib/ncbidll.hpp>
#include <io.h>
#include <fcntl.h>
#include <unistd.h>
+ Include dependency graph for ncbiapp.cpp:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

class  CIdlerWrapper
 

Macros

#define HAVE_LOCAL_NCBI_BUILD_VER_H   1
 
#define NCBI_USE_ERRCODE_X   Corelib_App
 
#define NCBI_LOG_PARAM(type, Name, NAME)
 
#define RES_SIZE_USAGE(name, value_in_bytes)
 
#define RES_TIME_USAGE(name, value)
 

Enumerations

enum  ELogOptionsEvent { eStartEvent = 0x01 , eStopEvent = 0x02 , eOtherEvent = 0x03 }
 
enum  ELogOptions {
  fLogAppEnvironment = 0x01 , fLogAppEnvironmentStop = 0x02 , fLogAppRegistry = 0x04 , fLogAppRegistryStop = 0x08 ,
  fLogAppArguments = 0x10 , fLogAppPath = 0x20 , fLogAppResUsageStop = 0x40
}
 Flags to switch what to log. More...
 

Functions

 DEFINE_STATIC_MUTEX (s_InstanceMutex)
 
 NCBI_PARAM_DECL (bool, Debug, Catch_Unhandled_Exceptions)
 
 NCBI_PARAM_DEF_EX (bool, Debug, Catch_Unhandled_Exceptions, true, eParam_NoThread, DEBUG_CATCH_UNHANDLED_EXCEPTIONS)
 
typedef NCBI_PARAM_TYPE (Debug, Catch_Unhandled_Exceptions) TParamCatchExceptions
 
bool s_HandleExceptions (void)
 
 NCBI_PARAM_DECL (bool, NCBI, TerminateOnCpuIncompatibility)
 
 NCBI_PARAM_DEF_EX (bool, NCBI, TerminateOnCpuIncompatibility, false, eParam_NoThread, NCBI_CONFIG__TERMINATE_ON_CPU_INCOMPATIBILITY)
 
 NCBI_PARAM_DECL (bool, Log, LogAppEnvironment)
 
 NCBI_PARAM_DEF_EX (bool, Log, LogAppEnvironment, false, eParam_NoThread, DIAG_LOG_APP_ENVIRONMENT)
 
typedef NCBI_PARAM_TYPE (Log, LogAppEnvironment) TLogAppEnvironment
 
 NCBI_PARAM_DECL (bool, Log, LogAppEnvironmentOnStop)
 
 NCBI_PARAM_DEF_EX (bool, Log, LogAppEnvironmentOnStop, false, eParam_NoThread, DIAG_LOG_APP_ENVIRONMENT_ON_STOP)
 
typedef NCBI_PARAM_TYPE (Log, LogAppEnvironmentOnStop) TLogAppEnvironmentOnStop
 
 NCBI_PARAM_DECL (bool, Log, LogAppRegistry)
 
 NCBI_PARAM_DEF_EX (bool, Log, LogAppRegistry, false, eParam_NoThread, DIAG_LOG_APP_REGISTRY)
 
typedef NCBI_PARAM_TYPE (Log, LogAppRegistry) TLogAppRegistry
 
 NCBI_PARAM_DECL (bool, Log, LogAppRegistryOnStop)
 
 NCBI_PARAM_DEF_EX (bool, Log, LogAppRegistryOnStop, false, eParam_NoThread, DIAG_LOG_APP_REGISTRY_ON_STOP)
 
typedef NCBI_PARAM_TYPE (Log, LogAppRegistryOnStop) TLogAppRegistryOnStop
 
 NCBI_PARAM_DECL (bool, Log, LogAppArguments)
 
 NCBI_PARAM_DEF_EX (bool, Log, LogAppArguments, false, eParam_NoThread, DIAG_LOG_APP_ARGUMENTS)
 
typedef NCBI_PARAM_TYPE (Log, LogAppArguments) TLogAppArguments
 
 NCBI_PARAM_DECL (bool, Log, LogAppPath)
 
 NCBI_PARAM_DEF_EX (bool, Log, LogAppPath, false, eParam_NoThread, DIAG_LOG_APP_PATH)
 
typedef NCBI_PARAM_TYPE (Log, LogAppPath) TLogAppPath
 
 NCBI_PARAM_DECL (bool, Log, LogAppRunContext)
 
 NCBI_PARAM_DEF_EX (bool, Log, LogAppRunContext, false, eParam_NoThread, DIAG_LOG_APP_RUN_CONTEXT)
 
typedef NCBI_PARAM_TYPE (Log, LogAppRunContext) TLogAppRunContext
 
 NCBI_PARAM_DECL (bool, Log, LogAppResUsageOnStop)
 
 NCBI_PARAM_DEF_EX (bool, Log, LogAppResUsageOnStop, false, eParam_NoThread, DIAG_LOG_APP_RESUSAGE_ON_STOP)
 
typedef NCBI_PARAM_TYPE (Log, LogAppResUsageOnStop) TLogAppResUsageOnStop
 
void s_RoundResUsageSize (Uint8 value_in_bytes, string &suffix, Uint8 &value)
 
INcbiIdlerGetIdler (EOwnership ownership)
 Return currently installed idler or NULL. More...
 
void SetIdler (INcbiIdler *idler, EOwnership ownership)
 Set new idler and ownership. More...
 
void RunIdler (void)
 Execute currently installed idler if any. More...
 

Variables

const char * s_ArgLogFile
 
const char * s_ArgCfgFile
 
const char * s_ArgVersion
 
const char * s_ArgFullVersion
 
const char * s_ArgFullVersionXml
 
const char * s_ArgFullVersionJson
 
const char * s_ArgDryRun
 
const char * s_ArgDelimiter
 
static bool s_IsApplicationStarted = false
 
static CSafeStatic< CRWLocks_InstanceRWLock (CSafeStaticLifeSpan(CSafeStaticLifeSpan::eLifeSpan_Long, 1))
 
CSafeStatic< CIdlerWrappers_IdlerWrapper
 

Macro Definition Documentation

◆ HAVE_LOCAL_NCBI_BUILD_VER_H

#define HAVE_LOCAL_NCBI_BUILD_VER_H   1

Definition at line 36 of file ncbiapp.cpp.

◆ NCBI_LOG_PARAM

#define NCBI_LOG_PARAM (   type,
  Name,
  NAME 
)
Value:
NCBI_PARAM_DECL (type, Log, LogApp ## Name); \
NCBI_PARAM_DEF_EX(type, Log, LogApp ## Name, false, eParam_NoThread, DIAG_LOG_APP_ ## NAME); \
typedef NCBI_PARAM_TYPE(Log, LogApp ## Name) TLogApp ## Name;
#define NAME
@ eParam_NoThread
Do not use per-thread values.
Definition: ncbi_param.hpp:418
typedef NCBI_PARAM_TYPE(Debug, Catch_Unhandled_Exceptions) TParamCatchExceptions
NCBI_PARAM_DECL(bool, Debug, Catch_Unhandled_Exceptions)
Definition: type.c:6

Definition at line 452 of file ncbiapp.cpp.

◆ NCBI_USE_ERRCODE_X

#define NCBI_USE_ERRCODE_X   Corelib_App

Definition at line 65 of file ncbiapp.cpp.

◆ RES_SIZE_USAGE

#define RES_SIZE_USAGE (   name,
  value_in_bytes 
)
Value:
{ \
string suffix; \
Uint8 value; \
s_RoundResUsageSize(value_in_bytes, suffix, value); \
extra.Print(name + suffix, value); \
}
char value[7]
Definition: config.c:431
static const char * suffix[]
Definition: pcregrep.c:408

Definition at line 528 of file ncbiapp.cpp.

◆ RES_TIME_USAGE

#define RES_TIME_USAGE (   name,
  value 
)
Value:
if (value >= 0 ) \
extra.Print(name, (Uint8)value)
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105

Definition at line 536 of file ncbiapp.cpp.

Enumeration Type Documentation

◆ ELogOptions

Flags to switch what to log.

Enumerator
fLogAppEnvironment 

log app environment on app start

fLogAppEnvironmentStop 

log app environment on app stop

fLogAppRegistry 

log app registry on app start

fLogAppRegistryStop 

log app registry on app stop

fLogAppArguments 

log app arguments

fLogAppPath 

log app executable path

fLogAppResUsageStop 

log resource usage on app stop

Definition at line 475 of file ncbiapp.cpp.

◆ ELogOptionsEvent

Enumerator
eStartEvent 

right before AppMain()

eStopEvent 

right after AppMain()

eOtherEvent 

any case is fine

Definition at line 467 of file ncbiapp.cpp.

Function Documentation

◆ DEFINE_STATIC_MUTEX()

DEFINE_STATIC_MUTEX ( s_InstanceMutex  )

◆ NCBI_PARAM_DECL() [1/10]

NCBI_PARAM_DECL ( bool  ,
Debug  ,
Catch_Unhandled_Exceptions   
)

◆ NCBI_PARAM_DECL() [2/10]

NCBI_PARAM_DECL ( bool  ,
Log  ,
LogAppArguments   
)

◆ NCBI_PARAM_DECL() [3/10]

NCBI_PARAM_DECL ( bool  ,
Log  ,
LogAppEnvironment   
)

◆ NCBI_PARAM_DECL() [4/10]

NCBI_PARAM_DECL ( bool  ,
Log  ,
LogAppEnvironmentOnStop   
)

◆ NCBI_PARAM_DECL() [5/10]

NCBI_PARAM_DECL ( bool  ,
Log  ,
LogAppPath   
)

◆ NCBI_PARAM_DECL() [6/10]

NCBI_PARAM_DECL ( bool  ,
Log  ,
LogAppRegistry   
)

◆ NCBI_PARAM_DECL() [7/10]

NCBI_PARAM_DECL ( bool  ,
Log  ,
LogAppRegistryOnStop   
)

◆ NCBI_PARAM_DECL() [8/10]

NCBI_PARAM_DECL ( bool  ,
Log  ,
LogAppResUsageOnStop   
)

◆ NCBI_PARAM_DECL() [9/10]

NCBI_PARAM_DECL ( bool  ,
Log  ,
LogAppRunContext   
)

◆ NCBI_PARAM_DECL() [10/10]

NCBI_PARAM_DECL ( bool  ,
NCBI  ,
TerminateOnCpuIncompatibility   
)

◆ NCBI_PARAM_DEF_EX() [1/10]

NCBI_PARAM_DEF_EX ( bool  ,
Debug  ,
Catch_Unhandled_Exceptions  ,
true  ,
eParam_NoThread  ,
DEBUG_CATCH_UNHANDLED_EXCEPTIONS   
)

◆ NCBI_PARAM_DEF_EX() [2/10]

NCBI_PARAM_DEF_EX ( bool  ,
Log  ,
LogAppArguments  ,
false  ,
eParam_NoThread  ,
DIAG_LOG_APP_ARGUMENTS   
)

◆ NCBI_PARAM_DEF_EX() [3/10]

NCBI_PARAM_DEF_EX ( bool  ,
Log  ,
LogAppEnvironment  ,
false  ,
eParam_NoThread  ,
DIAG_LOG_APP_ENVIRONMENT   
)

◆ NCBI_PARAM_DEF_EX() [4/10]

NCBI_PARAM_DEF_EX ( bool  ,
Log  ,
LogAppEnvironmentOnStop  ,
false  ,
eParam_NoThread  ,
DIAG_LOG_APP_ENVIRONMENT_ON_STOP   
)

◆ NCBI_PARAM_DEF_EX() [5/10]

NCBI_PARAM_DEF_EX ( bool  ,
Log  ,
LogAppPath  ,
false  ,
eParam_NoThread  ,
DIAG_LOG_APP_PATH   
)

◆ NCBI_PARAM_DEF_EX() [6/10]

NCBI_PARAM_DEF_EX ( bool  ,
Log  ,
LogAppRegistry  ,
false  ,
eParam_NoThread  ,
DIAG_LOG_APP_REGISTRY   
)

◆ NCBI_PARAM_DEF_EX() [7/10]

NCBI_PARAM_DEF_EX ( bool  ,
Log  ,
LogAppRegistryOnStop  ,
false  ,
eParam_NoThread  ,
DIAG_LOG_APP_REGISTRY_ON_STOP   
)

◆ NCBI_PARAM_DEF_EX() [8/10]

NCBI_PARAM_DEF_EX ( bool  ,
Log  ,
LogAppResUsageOnStop  ,
false  ,
eParam_NoThread  ,
DIAG_LOG_APP_RESUSAGE_ON_STOP   
)

◆ NCBI_PARAM_DEF_EX() [9/10]

NCBI_PARAM_DEF_EX ( bool  ,
Log  ,
LogAppRunContext  ,
false  ,
eParam_NoThread  ,
DIAG_LOG_APP_RUN_CONTEXT   
)

◆ NCBI_PARAM_DEF_EX() [10/10]

NCBI_PARAM_DEF_EX ( bool  ,
NCBI  ,
TerminateOnCpuIncompatibility  ,
false  ,
eParam_NoThread  ,
NCBI_CONFIG__TERMINATE_ON_CPU_INCOMPATIBILITY   
)

◆ NCBI_PARAM_TYPE() [1/9]

typedef NCBI_PARAM_TYPE ( Debug  ,
Catch_Unhandled_Exceptions   
)

◆ NCBI_PARAM_TYPE() [2/9]

typedef NCBI_PARAM_TYPE ( Log  ,
LogAppArguments   
)

◆ NCBI_PARAM_TYPE() [3/9]

typedef NCBI_PARAM_TYPE ( Log  ,
LogAppEnvironment   
)

◆ NCBI_PARAM_TYPE() [4/9]

typedef NCBI_PARAM_TYPE ( Log  ,
LogAppEnvironmentOnStop   
)

◆ NCBI_PARAM_TYPE() [5/9]

typedef NCBI_PARAM_TYPE ( Log  ,
LogAppPath   
)

◆ NCBI_PARAM_TYPE() [6/9]

typedef NCBI_PARAM_TYPE ( Log  ,
LogAppRegistry   
)

◆ NCBI_PARAM_TYPE() [7/9]

typedef NCBI_PARAM_TYPE ( Log  ,
LogAppRegistryOnStop   
)

◆ NCBI_PARAM_TYPE() [8/9]

typedef NCBI_PARAM_TYPE ( Log  ,
LogAppResUsageOnStop   
)

◆ NCBI_PARAM_TYPE() [9/9]

typedef NCBI_PARAM_TYPE ( Log  ,
LogAppRunContext   
)

◆ s_HandleExceptions()

bool s_HandleExceptions ( void  )

Definition at line 382 of file ncbiapp.cpp.

Referenced by CNcbiApplicationAPI::AppMain(), and CNcbiApplicationAPI::x_TryMain().

◆ s_RoundResUsageSize()

void s_RoundResUsageSize ( Uint8  value_in_bytes,
string suffix,
Uint8 value 
)

Definition at line 513 of file ncbiapp.cpp.

References suffix, and value.

Variable Documentation

◆ s_ArgCfgFile

const char* s_ArgCfgFile
extern

◆ s_ArgDelimiter

const char* s_ArgDelimiter
extern

Definition at line 89 of file ncbiargs.cpp.

Referenced by CNcbiApplicationAPI::AppMain(), and CArgDescriptions::x_CreateArg().

◆ s_ArgDryRun

const char* s_ArgDryRun
extern

Definition at line 88 of file ncbiargs.cpp.

Referenced by CArgDescriptions::AddStdArguments(), and CNcbiApplicationAPI::AppMain().

◆ s_ArgFullVersion

const char* s_ArgFullVersion
extern

◆ s_ArgFullVersionJson

const char* s_ArgFullVersionJson
extern

Definition at line 87 of file ncbiargs.cpp.

Referenced by CArgDescriptions::AddStdArguments(), and CNcbiApplicationAPI::AppMain().

◆ s_ArgFullVersionXml

const char* s_ArgFullVersionXml
extern

Definition at line 86 of file ncbiargs.cpp.

Referenced by CArgDescriptions::AddStdArguments(), and CNcbiApplicationAPI::AppMain().

◆ s_ArgLogFile

const char* s_ArgLogFile
extern

◆ s_ArgVersion

const char* s_ArgVersion
extern

◆ s_IdlerWrapper

CSafeStatic<CIdlerWrapper> s_IdlerWrapper

Definition at line 1817 of file ncbiapp.cpp.

Referenced by GetIdler(), RunIdler(), and SetIdler().

◆ s_InstanceRWLock

◆ s_IsApplicationStarted

bool s_IsApplicationStarted = false
static
Modified on Fri Jan 05 07:22:37 2024 by modify_doxy.py rev. 669887