Public Member Functions | Public Attributes | Private Attributes

ui_MsgWriter Class Reference
[Command line interface]

#include <ui_MsgWriter.h>

Collaboration diagram for ui_MsgWriter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ui_MsgWriter (const cmn_Path &a_fileOut, i_UIMessageServer_ptr a_uims, bool a_removeUimsInDestructor=true)
 ui_MsgWriter (i_UIMessageServer_ptr a_uims, bool a_removeUimsInDestructor=true)
 ~ui_MsgWriter ()
cmn_Path GetStreamPath ()
void SetStreamPath (const cmn_Path &a_streamPath)
void DisplayResult (const i_UIResult_t &a_res)
void DisplayError (const string &a_error)
void DisplayWarning (const string &a_error)
void DisplayMessage (const string &a_message, bool a_addTime=true)
void RemoveUI ()
i_UIMessageServer_ptr GetMessageServer ()
void TruncFile ()
void OpenFile (const cmn_Path &a_fileOut)
void CloseFile ()

Public Attributes

 log_CLASSID_m

Private Attributes

i_UIMessageServer_var m_ui
cmn_File m_streamOut
bool m_streamActive
bool m_uiActive
bool m_removeUimsInDestructor

Detailed Description

Definition at line 44 of file ui_MsgWriter.h.


Constructor & Destructor Documentation

ui_MsgWriter::ui_MsgWriter ( const cmn_Path a_fileOut,
i_UIMessageServer_ptr  a_uims,
bool  a_removeUimsInDestructor = true 
)

Definition at line 55 of file ui_MsgWriter.cpp.

References dbg_NORM, log_DBG_m, log_FUNC_A_m, m_ui, m_uiActive, and OpenFile().

        :
        m_uiActive(!CORBA::is_nil(a_uims)),
        m_removeUimsInDestructor(a_removeUimsInDestructor)
{
    log_FUNC_A_m(ui_MsgWriter, "removeUimsInDestructor " << boolalpha << 
                                a_removeUimsInDestructor);
    
    OpenFile(a_fileOut);
    
    if (m_uiActive) {
        log_DBG_m(dbg_NORM,"a_uims active.");
        m_ui = i_UIMessageServer::_duplicate(a_uims); 
    } 
    
}

Here is the call graph for this function:

ui_MsgWriter::ui_MsgWriter ( i_UIMessageServer_ptr  a_uims,
bool  a_removeUimsInDestructor = true 
)

Definition at line 77 of file ui_MsgWriter.cpp.

References dbg_NORM, log_DBG_m, log_FUNC_A_m, m_ui, and m_uiActive.

        :
    m_streamActive(false),
    m_uiActive(!CORBA::is_nil(a_uims)),
    m_removeUimsInDestructor(a_removeUimsInDestructor)
{
    log_FUNC_A_m(ui_MsgWriter, "removeUimsInDestructor " << boolalpha << 
                                a_removeUimsInDestructor);
    
    if (m_uiActive) {
        log_DBG_m(dbg_NORM,"a_uims active.");
        m_ui = i_UIMessageServer::_duplicate(a_uims); 
    }
}

ui_MsgWriter::~ui_MsgWriter (  ) 

Definition at line 94 of file ui_MsgWriter.cpp.

References CloseFile(), dbg_LOW, ipc_EXEC_m, log_DBG_m, log_FUNC_m, m_removeUimsInDestructor, and RemoveUI().

                            {
    log_FUNC_m(~ui_MsgWriter);

    try {
        CloseFile();
        ipc_EXEC_m(
            if (m_removeUimsInDestructor) {
                RemoveUI();
            }
        );
    } 
    catch (ivd_Exception& e) { 
        log_DBG_m(dbg_LOW, e ); 
    } 
    catch (ivd_InternalError& e) { 
        log_DBG_m(dbg_LOW, e );
    } 
    catch (...) { 
        log_DBG_m(dbg_LOW, "unknown exception cought" ); 
    }

    
//    else if (m_uiActiv) {
//        CORBA::release(m_ui);
//    }
}

Here is the call graph for this function:


Member Function Documentation

void ui_MsgWriter::CloseFile (  ) 

Definition at line 288 of file ui_MsgWriter.cpp.

References cmn_File::CloseF(), m_streamActive, and m_streamOut.

Referenced by ~ui_MsgWriter().

                            {
    if (m_streamActive) {
        m_streamActive = false;
        m_streamOut.CloseF();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ui_MsgWriter::DisplayError ( const string &  a_error  ) 
void ui_MsgWriter::DisplayMessage ( const string &  a_message,
bool  a_addTime = true 
)

Definition at line 184 of file ui_MsgWriter.cpp.

References cmn_Time::c_Time2YMDhms(), dbg_DETAIL, ipc_EXEC_m, log_DBG_m, log_FUNC_m, m_streamActive, m_streamOut, m_ui, m_uiActive, and cmn_File::WriteF().

Referenced by i_MediumDupl_i::AssignResources(), TreeWalk::CheckDir(), FileInfoCache::CheckFiles(), i_MaintFriJob_i::CheckReadFri(), i_MediumDupl_i::CheckTargetMedium(), i_AdminJob_i::CheckVolumesForFormatAndInit(), i_AdminJob_i::CheckVolumesForVolumeClose(), i_FSC_i::CheckWithMedVolume(), i_AdminJob_i::CloseVolume(), i_ReorgJob_i::CompleteJob(), i_MediumDupl_i::CompleteJob(), i_MediumCheckJob_i::CompleteJob(), i_FSC_i::DelExpiredFiles(), i_AdminJob_i::DetectVolumeHeader(), fsc_VolumeCheck::DisplayMessage(), i_AdminJob_i::DoInitialize(), i_VvCopyJob_i::Execute(), i_ReorgScanJob_i::Execute(), i_ReorgJob_i::Execute(), i_RedundantCopyJob_i::Execute(), i_RecreatedIVDFSJob_i::Execute(), i_MediumDupl_i::Execute(), i_MediumCheckJob_i::Execute(), i_DelExpiredFilesJob_i::Execute(), i_AdminJob_i::Execute(), fsc_nsFSrecovery::FlushBlock(), fsc_ColectorExpFile::FlushPackage(), i_AdminJob_i::Format(), i_MaintFriJob_i::i_MaintFriJob_i(), i_MediumCheckJob_i::i_MediumCheckJob_i(), i_MediumDupl_i::i_MediumDupl_i(), i_RecoveryJob_i::i_RecoveryJob_i(), i_RedundantCopyJob_i::i_RedundantCopyJob_i(), i_ReorgJob_i::i_ReorgJob_i(), i_ThreadJob_i::i_ThreadJob_i(), i_AdminJob_i::Initialize(), i_ReorgJob_i::InitializeSingleVolume(), i_AdminJob_i::InitializeSingleVolume(), i_ReorgJob_i::InitializeVolumes(), i_AdminJob_i::InitJob(), i_FSC_i::IVDFSRecovery(), i_ReorgJob_i::MediumOperationComplete(), i_RedundantCopyJob_i::MediumOperationComplete(), i_MediumDupl_i::MediumOperationComplete(), i_MaintFriJob_i::MediumOperationComplete(), i_ReorgJob_i::MigrateFiles(), i_RedundantCopyJob_i::MigrateFiles(), nsc_ScanForIVDFSRecovery(), i_AdminJob_i::OperateLA(), i_MediumDupl_i::PreFormat(), i_RedundantCopyJob_i::Prepare(), i_MediumDupl_i::Process(), i_MaintFriJob_i::Process(), i_RecoveryJob_i::ProcessFRI(), i_MediumCheckJob_i::ProcessFRI(), i_ReorgJob_i::ReadSourceVolume(), i_ReorgJob_i::RecallFiles(), i_RedundantCopyJob_i::RecallFiles(), i_AdminJob_i::RecreateFRIandMIC(), TreeWalk::Report(), fsc_VolumeCheck::RestDataHandle(), i_AdminJob_i::StartBEA(), TreeWalk::TreeWalk(), i_AdminJob_i::~i_AdminJob_i(), i_MaintFriJob_i::~i_MaintFriJob_i(), i_RedundantCopyJob_i::~i_RedundantCopyJob_i(), and i_ThreadJob_i::~i_ThreadJob_i().

                                                                         {
    log_FUNC_m(DisplayMessage);

    ostringstream msg;

    if (a_addTime) {
        cmn_Time nowTime;
        msg << "[" << nowTime.c_Time2YMDhms() << "] " << a_message;
    }
    else {
        msg << a_message;
    }
    
    if (m_streamActive) {
        string msgStr = msg.str().append("\n");
        m_streamOut.WriteF(msgStr.c_str(), msgStr.length()); 
        
    }
    if (m_uiActive) {
        try {
            log_DBG_m(dbg_DETAIL," msg: " << a_message);  
            ipc_EXEC_m(
                m_ui->DisplayMessage(CORBA::string_dup(msg.str().c_str()));
            );
        }
        catch(ivd_Exception& e) { 
            log_DBG_m(dbg_DETAIL, e << ": Message server not accessible.");
            m_uiActive = false;
        }
        catch (...) {
            log_DBG_m(dbg_DETAIL, "Message server not accessible.");
            m_uiActive = false;
        }
    }
}

Here is the call graph for this function:

void ui_MsgWriter::DisplayResult ( const i_UIResult_t a_res  ) 

Definition at line 123 of file ui_MsgWriter.cpp.

References ipc_EXEC_m, log_FUNC_m, m_streamActive, m_ui, and m_uiActive.

                                                          {
    log_FUNC_m(DisplayResult);
    if (m_streamActive) {
//        m_streamOut << a_res;
    }
    if (m_uiActive) {
        try {
            ipc_EXEC_m(
                m_ui->DisplayResult(a_res);
            );
        }
        catch (...) {
            m_uiActive = false;
        }
    }
}

void ui_MsgWriter::DisplayWarning ( const string &  a_error  ) 

Definition at line 163 of file ui_MsgWriter.cpp.

References ipc_EXEC_m, log_FUNC_m, m_streamActive, m_streamOut, m_ui, m_uiActive, and cmn_File::WriteF().

Referenced by pm_JobMgr::CheckFSCvsIVDFS(), i_AdminJob_i::CheckVolumesForFriMicJob(), i_MaintFriJob_i::CompleteJob(), i_RecreatedIVDFSJob_i::Execute(), i_AdminJob_i::Format(), i_RedundantCopyJob_i::i_RedundantCopyJob_i(), i_AdminJob_i::Initialize(), i_AdminJob_i::InitializeSingleVolume(), i_MaintFriJob_i::PrepareMedium(), and i_AdminJob_i::~i_AdminJob_i().

                                                       {
    log_FUNC_m(DisplayWarning);
    if (m_streamActive) {
        string msgStr = a_error;
        msgStr.append("\n");
        m_streamOut.WriteF(msgStr.c_str(), msgStr.length());
    }
    if (m_uiActive) {
        try {
            ipc_EXEC_m(
                m_ui->DisplayWarning(a_error.c_str());
            );
        }
        catch (...) {
            m_uiActive = false;
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

i_UIMessageServer_ptr ui_MsgWriter::GetMessageServer (  ) 

Definition at line 241 of file ui_MsgWriter.cpp.

References log_FUNC_m, and m_ui.

Referenced by i_FSCCheckJob_i::Execute().

                                                    {
    log_FUNC_m(GetMessageServer);
    try {
        if (!CORBA::is_nil(m_ui) && !m_ui->_non_existent()){
            i_UIMessageServer_ptr ui = i_UIMessageServer::_duplicate(m_ui);
            return ui;
        } else {
            return i_UIMessageServer::_nil();
        }
    } catch (...) {
        //ignore all errors, just return nil
        return i_UIMessageServer::_nil();
    }
}

Here is the caller graph for this function:

cmn_Path ui_MsgWriter::GetStreamPath (  )  [inline]

Definition at line 68 of file ui_MsgWriter.h.

References cmn_File::GetFullPathRef().

Referenced by i_MediumCheckJob_i::CompleteJob().

{ return m_streamOut.GetFullPathRef(); };

Here is the call graph for this function:

Here is the caller graph for this function:

void ui_MsgWriter::OpenFile ( const cmn_Path a_fileOut  ) 

Definition at line 270 of file ui_MsgWriter.cpp.

References dbg_DETAIL, fom_OPEN_ALWAYS, fom_WRITE, log_DBG_m, log_FUNC_m, m_streamActive, m_streamOut, cmn_File::OpenF(), cmn_File::SeekEndF(), and cmn_File::SetFullPath().

Referenced by i_MediumCheckJob_i::i_MediumCheckJob_i(), TruncFile(), and ui_MsgWriter().

                                                     {
    log_FUNC_m(OpenFile);
    if (!a_fileOut.empty()) {
        m_streamOut.SetFullPath(a_fileOut);
    }    
    try {
        m_streamOut.OpenF(fom_OPEN_ALWAYS | fom_WRITE);
        m_streamOut.SeekEndF();
        m_streamActive = true;
    } catch (...) {
        m_streamActive = false;
    }
    log_DBG_m(dbg_DETAIL, "Open file " << a_fileOut << 
                          " status " << m_streamActive);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ui_MsgWriter::RemoveUI (  ) 

Definition at line 222 of file ui_MsgWriter.cpp.

References dbg_DETAIL, ipc_EXEC_m, log_DBG_m, log_FUNC_m, m_ui, and m_uiActive.

Referenced by ~ui_MsgWriter().

                            {
    log_FUNC_m(RemoveUI);

    if (m_uiActive) {
        try {
            ipc_EXEC_m(
                m_ui->Remove();
            );
        }
        catch (...) {
            // empty
        }
        log_DBG_m(dbg_DETAIL, "CORBA UI stopped");
    }
    m_uiActive = false;
}

Here is the caller graph for this function:

void ui_MsgWriter::SetStreamPath ( const cmn_Path a_streamPath  )  [inline]

Definition at line 69 of file ui_MsgWriter.h.

References cmn_File::SetFullPath().

                                                     {
        m_streamOut.SetFullPath(a_streamPath);
    };

Here is the call graph for this function:

void ui_MsgWriter::TruncFile (  ) 

Member Data Documentation

Definition at line 56 of file ui_MsgWriter.h.

Definition at line 64 of file ui_MsgWriter.h.

Referenced by ~ui_MsgWriter().

i_UIMessageServer_var ui_MsgWriter::m_ui [private]
bool ui_MsgWriter::m_uiActive [private]

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