Public Member Functions | Public Attributes | Private Member Functions | Private Attributes

ui_ResultPacker Class Reference
[Command line interface]

Packes output result into i_Result. More...

#include <ui_helpers.h>

List of all members.

Public Member Functions

 ui_ResultPacker ()
virtual ~ui_ResultPacker ()
const vector< i_UIResult_t > & GetUIResults ()
bool SendResults (i_UIMessageServer_ptr a_uims)
void Insert (const string &a_text, const i_UIAlignType_e a_align=uialign_LEFT)
void Insert (const UInt64_t a_num)
void Insert (const Int64_t a_num)
void Insert (const UInt32_t a_num)
void Insert (const Int32_t a_num)
void Insert (const CORBA::Long a_num)
void Insert (const CORBA::ULong a_num)
void Insert (const i_UIResultType_e a_type, const UInt64_t a_num, const i_UIAlignType_e a_align=uialign_LEFT)
void Insert (const bool a_bool)
void Insert (const char *a_cstr, const i_UIAlignType_e a_align=uialign_LEFT)
void NewRow (bool a_isHeader=false)
void MakeNewBlock ()

Public Attributes

 log_CLASSID_m

Private Member Functions

i_UIResultCell_tNewContainer ()

Private Attributes

vector< i_UIResult_tm_UIResults
UInt32_t m_numOfBlk
UInt32_t m_currentBlockLength

Detailed Description

Packes output result into i_Result.

Author:
Toni Pljakoski, HERMES SoftLab
See also:
<reference>

Definition at line 65 of file ui_helpers.h.


Constructor & Destructor Documentation

ui_ResultPacker::ui_ResultPacker (  ) 

Definition at line 49 of file ui_resultpacker.cpp.

References log_FUNC_m.

                                 :
    m_numOfBlk(0),
    m_currentBlockLength(0)
{
    log_FUNC_m(ui_ResultPacker);
    
    //MakeNewBlock();
}

ui_ResultPacker::~ui_ResultPacker (  )  [virtual]

Definition at line 58 of file ui_resultpacker.cpp.

References log_FUNC_m.


Member Function Documentation

const vector< i_UIResult_t > & ui_ResultPacker::GetUIResults (  ) 
void ui_ResultPacker::Insert ( const UInt64_t  a_num  ) 

Definition at line 106 of file ui_resultpacker.cpp.

References Insert(), log_FUNC_A_m, m_currentBlockLength, NewContainer(), i_UIResultCell_t::num, and i_UIResultCell_t::type.

                                                 {
    log_FUNC_A_m(Insert, "num:" << a_num);
    
    i_UIResultCell_t& newCell = NewContainer();
    newCell.type = uires_NUM;
    newCell.num = a_num;
    m_currentBlockLength += sizeof(newCell.num);
}

Here is the call graph for this function:

void ui_ResultPacker::Insert ( const CORBA::Long  a_num  )  [inline]

Definition at line 91 of file ui_helpers.h.

                                          {
                Insert(static_cast<const UInt64_t>(a_num)); };

void ui_ResultPacker::Insert ( const CORBA::ULong  a_num  )  [inline]

Definition at line 93 of file ui_helpers.h.

                                           {
                Insert(static_cast<const UInt64_t>(a_num)); };

void ui_ResultPacker::Insert ( const char *  a_cstr,
const i_UIAlignType_e  a_align = uialign_LEFT 
)

Definition at line 135 of file ui_resultpacker.cpp.

References i_UIResultCell_t::alignment, Insert(), log_FUNC_A_m, m_currentBlockLength, NewContainer(), i_UIResultCell_t::text, and i_UIResultCell_t::type.

                                                                              {
    log_FUNC_A_m(Insert, "cstr:" << a_cstr);

    i_UIResultCell_t& newCell = NewContainer();

    newCell.type      = uires_TEXT;
    newCell.alignment = a_align;
    newCell.text      = CORBA::string_dup(a_cstr);

    m_currentBlockLength += strlen(a_cstr)+1;
}

Here is the call graph for this function:

void ui_ResultPacker::Insert ( const bool  a_bool  ) 

Definition at line 126 of file ui_resultpacker.cpp.

References i_UIResultCell_t::boolVar, Insert(), log_FUNC_A_m, m_currentBlockLength, NewContainer(), and i_UIResultCell_t::type.

                                              {
    log_FUNC_A_m(Insert, "bool:" << a_bool);

    i_UIResultCell_t& newCell = NewContainer();
    newCell.type = uires_BOOL;
    newCell.boolVar = a_bool;
    m_currentBlockLength += sizeof(newCell.boolVar);
}

Here is the call graph for this function:

void ui_ResultPacker::Insert ( const Int64_t  a_num  )  [inline]

Definition at line 82 of file ui_helpers.h.

                                        {
                Insert(static_cast<const UInt64_t>(a_num)); };

void ui_ResultPacker::Insert ( const i_UIResultType_e  a_type,
const UInt64_t  a_num,
const i_UIAlignType_e  a_align = uialign_LEFT 
)

Definition at line 115 of file ui_resultpacker.cpp.

References i_UIResultCell_t::alignment, Insert(), log_FUNC_A_m, m_currentBlockLength, NewContainer(), i_UIResultCell_t::num, and i_UIResultCell_t::type.

                                                            {
    log_FUNC_A_m(Insert, "num:" << a_num);
    i_UIResultCell_t& newCell = NewContainer();
    newCell.alignment = a_align;
    newCell.type = a_type;
    newCell.num  = a_num;
    m_currentBlockLength += sizeof(newCell.num);
}

Here is the call graph for this function:

void ui_ResultPacker::Insert ( const string &  a_text,
const i_UIAlignType_e  a_align = uialign_LEFT 
)
void ui_ResultPacker::Insert ( const Int32_t  a_num  )  [inline]

Definition at line 86 of file ui_helpers.h.

                                        {
                Insert(static_cast<const UInt64_t>(a_num)); };

void ui_ResultPacker::Insert ( const UInt32_t  a_num  )  [inline]

Definition at line 84 of file ui_helpers.h.

                                         {
                Insert(static_cast<const UInt64_t>(a_num)); };

void ui_ResultPacker::MakeNewBlock (  ) 

Definition at line 63 of file ui_resultpacker.cpp.

References i_UIResultCell_t::alignment, i_UIResultCell_t::boolVar, i_UIResult_t::cell, ipc_nilStr, m_numOfBlk, m_UIResults, i_UIResultCell_t::num, i_UIResultCell_t::text, i_UIResultCell_t::type, and i_UIResult_t::type.

Referenced by i_ManagementInterface_i::ListJob(), and NewRow().

                                   {
    //log_FUNC_m(MakeNewBlock);

    m_UIResults.resize(m_UIResults.size() + 1);
    i_UIResult_t &newBlock =  m_UIResults.back();

    newBlock.type           = uiitem_UNKNOWN;
    newBlock.cell.type      = uires_NO_TYPE;
    newBlock.cell.alignment = uialign_LEFT;
    newBlock.cell.text      = CORBA::string_dup(ipc_nilStr);
    newBlock.cell.boolVar   = false;
    newBlock.cell.num       = 0;

    m_numOfBlk = m_UIResults.size();
}

Here is the caller graph for this function:

i_UIResultCell_t & ui_ResultPacker::NewContainer (  )  [private]

Definition at line 178 of file ui_resultpacker.cpp.

References i_UIResultCell_t::alignment, i_UIResultCell_t::boolVar, i_UIResult_t::cell, ie_MIF_UIPACKER, ipc_nilStr, ivd_Error, log_FUNC_m, m_UIResults, i_UIResultCell_t::num, i_UIResult_t::table, i_UIResultCell_t::text, i_UIResultCell_t::type, i_UIResult_t::type, uiitem_CELL, uiitem_TABLE, and uiitem_UNKNOWN.

Referenced by Insert().

                                               {
    //log_FUNC_m(NewContainer);
        
    i_UIResult_t &lastBlock =  m_UIResults.back();
    switch (lastBlock.type){
        case(uiitem_UNKNOWN):
            // NOTE: Fall through on purpose
            //log_DBG_m(dbg_DETAIL,"block UNKNOWN");
        case(uiitem_CELL):
            {
                lastBlock.type = uiitem_CELL;

                lastBlock.cell.type       = uires_NO_TYPE;
                lastBlock.cell.alignment  = uialign_LEFT;
                lastBlock.cell.text       = CORBA::string_dup(ipc_nilStr);
                lastBlock.cell.boolVar    = false;
                lastBlock.cell.num        = 0;

                return lastBlock.cell;
            }        
        case(uiitem_TABLE):
            {
                i_UIResultCellSeq_t& currentRow = lastBlock.table[lastBlock.table.length() - 1].row;
               
                currentRow.length(currentRow.length() + 1);
                currentRow[currentRow.length() - 1].type      = uires_NO_TYPE;
                currentRow[currentRow.length() - 1].alignment = uialign_LEFT;
                currentRow[currentRow.length() - 1].text      = CORBA::string_dup(ipc_nilStr);
                currentRow[currentRow.length() - 1].boolVar   = false;
                currentRow[currentRow.length() - 1].num       = 0;

                return currentRow[currentRow.length() - 1];
            }
        default:
            log_FUNC_m(NewContainer);
            throw ivd_Error(ie_MIF_UIPACKER,"result type not set");
    }

}

Here is the caller graph for this function:

void ui_ResultPacker::NewRow ( bool  a_isHeader = false  ) 

Definition at line 147 of file ui_resultpacker.cpp.

References dbg_DETAIL, ie_MIF_UIPACKER, ivd_Error, log_DBG_m, log_FUNC_m, m_currentBlockLength, m_UIResults, MakeNewBlock(), MAX_CORBA_UIRESULT_BLOCK_LENGTH, i_UIResult_t::table, i_UIResult_t::type, uiitem_CELL, and uiitem_UNKNOWN.

Referenced by _tmain(), i_ManagementInterface_i::FileHistory(), i_ManagementInterface_i::ListDriveHosts(), i_ManagementInterface_i::ListDrives(), i_ManagementInterface_i::ListJob(), i_ManagementInterface_i::ListJobs(), i_ManagementInterface_i::ListMedia(), i_ManagementInterface_i::ListMediumVolumes(), i_ManagementInterface_i::ListPartitions(), i_ManagementInterface_i::ListSingleMedium(), i_ManagementInterface_i::ListSlots(), i_ManagementInterface_i::MakeInventoryHeader(), i_ManagementInterface_i::PartitionReorgStat(), i_ManagementInterface_i::PartitionStatus(), i_ManagementInterface_i::PoolReorgStat(), i_ManagementInterface_i::ShowLibraryInventory(), and i_ManagementInterface_i::SystemStatus().

                                           {
    log_FUNC_m(NewRow);
    //Check Block Length
    if (m_currentBlockLength == 0){

        //make new block
        MakeNewBlock();
    }

    if (m_currentBlockLength >= MAX_CORBA_UIRESULT_BLOCK_LENGTH){
        //make new block
        MakeNewBlock();
    }

    i_UIResult_t &lastBlock =  m_UIResults.back();
    
    if (lastBlock.type == uiitem_UNKNOWN){
        log_DBG_m(dbg_DETAIL,"Will set result type to table");
        lastBlock.type = uiitem_TABLE;
    } 
    else if (lastBlock.type == uiitem_CELL) {
        throw ivd_Error(ie_MIF_UIPACKER, "Can not invoke new Row on CELL");
    }

    log_DBG_m(dbg_DETAIL,"Creating new row");
    lastBlock.table.length(lastBlock.table.length() + 1);
    lastBlock.table[lastBlock.table.length() -1 ].isHdr = a_isHeader;
    
  
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool ui_ResultPacker::SendResults ( i_UIMessageServer_ptr  a_uims  ) 

Member Data Documentation

Definition at line 106 of file ui_helpers.h.

Definition at line 113 of file ui_helpers.h.

Referenced by Insert(), and NewRow().

Definition at line 112 of file ui_helpers.h.

Referenced by MakeNewBlock().

Definition at line 72 of file ui_helpers.h.

Referenced by GetUIResults(), MakeNewBlock(), NewContainer(), NewRow(), and SendResults().


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