Public Member Functions | Public Attributes

fsc_SplitStream_t Struct Reference
[G_new_group]

#include <fsc_nsAttrStream.h>

Collaboration diagram for fsc_SplitStream_t:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 fsc_SplitStream_t ()
 fsc_SplitStream_t (const fsc_SplitStream_t &a_ss)
bool operator< (const fsc_SplitStream_t &a_ss)
void Dump (ostream &os)
void Pack (df_Packer &a_packer)

Public Attributes

df_AttrHeader_t splitInfo
string splitData
 log_CLASSID_m

Detailed Description

Definition at line 52 of file fsc_nsAttrStream.h.


Constructor & Destructor Documentation

fsc_SplitStream_t::fsc_SplitStream_t (  )  [inline]

Definition at line 53 of file fsc_nsAttrStream.h.

{};

fsc_SplitStream_t::fsc_SplitStream_t ( const fsc_SplitStream_t a_ss  )  [inline]

Definition at line 55 of file fsc_nsAttrStream.h.

References splitData, and splitInfo.

                                                     {
        splitInfo = a_ss.splitInfo;
        splitData = a_ss.splitData;
    };


Member Function Documentation

void fsc_SplitStream_t::Dump ( ostream &  os  ) 

Definition at line 54 of file fsc_nsAttrStream.cpp.

References at_ADS, at_ENDOFDATA, at_META_MASK, df_AttrHeader_t::attrOfs, df_AttrHeader_t::attrSize, df_AttrHeader_t::attrType, cmn_HexDump(), cmn_Num2Str(), GetAttrName(), ie_DF_INVSEQ, splitData, and splitInfo.

                                       {
    if (splitInfo.attrType == at_ENDOFDATA) {
        os << "  Complete attributes." << endl;
    }
    else {
        os << " Split Info : ofs = " << splitInfo.attrOfs  
        << "  size = " << splitInfo.attrSize 
        << "  lastSplit = " <<  boolalpha << (splitInfo.attrType == at_LASTSPLIT) << endl;
    }

    df_AttrHeader_t ah;
    const char *ip = splitData.data();
    const char *ep = ip + splitData.size();

    while (true) {
        if (ip + sizeof(df_AttrHeader_t) > ep) {
            break;
        }
        memcpy(&ah, ip, sizeof(df_AttrHeader_t));

        ip += sizeof(df_AttrHeader_t);

        if (ah.attrType & at_META_MASK) {
                os  << " Attribute header: type = META, stream name = " 
                    << GetAttrName((df_AttrType_e)(ah.attrType))
                    << "  ofs " << ah.attrOfs  
                    << "  size " << ah.attrSize << endl;
                os  << cmn_HexDump(ip, ah.attrSize, 16, true);
        }
        else if (ah.attrType == at_ADS) {
                os  << " Attribute header: type = ADS name "
                    << "  ofs " << ah.attrOfs  
                    << "  size " << ah.attrSize << endl;
                os  << "  name = " << string(ip, ah.attrSize) << endl;
        }
        else {
                throw ivd_InternalError(ie_DF_INVSEQ, 
                        string("Unknown record type in split stream. type =") 
                        + cmn_Num2Str(int(ah.attrType)));
        }
        ip += ah.attrSize;
    }
}

Here is the call graph for this function:

bool fsc_SplitStream_t::operator< ( const fsc_SplitStream_t a_ss  )  [inline]

Definition at line 61 of file fsc_nsAttrStream.h.

References df_AttrHeader_t::attrOfs, and splitInfo.

                                                    {
        return splitInfo.attrOfs < a_ss.splitInfo.attrOfs;
    };

void fsc_SplitStream_t::Pack ( df_Packer a_packer  ) 

Definition at line 99 of file fsc_nsAttrStream.cpp.

References at_ADS, at_ENDOFDATA, at_LASTSPLIT, at_META_MASK, df_AttrHeader_t::attrOfs, df_AttrHeader_t::attrSize, df_AttrHeader_t::attrType, cmn_HexDump(), cmn_Num2Str(), dbg_DETAIL, dbg_LOW, df_SS_ABORTED, df_SS_COMPLETE, df_ST_ALTDATA, df_ST_META, GetAttrName(), df_Packer::GetBSData(), ivd_BaseException::GetError(), ivd_BaseException::GetFriendly(), ie_DF_INVSEQ, log_DBG_m, log_FUNC_m, splitData, splitInfo, df_Packer::WriteBSData(), df_Packer::WriteRecBSEnd(), and df_Packer::WriteRecBSStart().

                                               {
    log_FUNC_m(Pack);
    if (splitInfo.attrType != at_ENDOFDATA) { // not last stream
        return;
    }
    log_DBG_m(dbg_DETAIL, " Split Info : ofs = " << splitInfo.attrOfs  
    << "  size = " << splitInfo.attrSize 
    << "  lastSplit = " <<  boolalpha << (splitInfo.attrType == at_LASTSPLIT));

    df_AttrHeader_t ah;
    const char *ip = splitData.data();
    const char *ep = ip + splitData.size();

    while (true) {
        if (ip + sizeof(df_AttrHeader_t) > ep) {
            break;
        }
        memcpy(&ah, ip, sizeof(df_AttrHeader_t));

        ip += sizeof(df_AttrHeader_t);

        if (ah.attrType & at_META_MASK) {
            log_DBG_m(dbg_DETAIL, " Attribute header: type = META, stream name = " 
                << GetAttrName((df_AttrType_e)(ah.attrType))
                << "  ofs " << ah.attrOfs  
                << "  size " << ah.attrSize);
            log_DBG_m(dbg_DETAIL, cmn_HexDump(ip, ah.attrSize, 16, true));

            a_packer.WriteRecBSStart(df_ST_META, 
                                     GetAttrName((df_AttrType_e)(ah.attrType)), 
                                     ah.attrSize);

            UInt32_t status = df_SS_COMPLETE;
            UInt64_t streamLeft = ah.attrSize;

            while (streamLeft > 0) {

                UInt8_t *buf;
                UInt32_t bufSize;
                try {
                    a_packer.GetBSData(buf, bufSize);
                }
                catch (ivd_Exception &ie) {
                    if (ie.GetError() == ie_DF_SSIZE) {
                        log_DBG_m(dbg_LOW, "Cannot get buffer for stream: " << 
                                    ie.GetFriendly());
                        status = df_SS_ABORTED;
                        break;
                    }
                    else
                        throw;
                }

                memcpy(buf, ip, bufSize);
                ip += bufSize;

                // commit DF buffer
                a_packer.WriteBSData();

                streamLeft -= bufSize;
            } // while (streamLeft > 0)

            try {
                a_packer.WriteRecBSEnd(status);
            }
            catch (ivd_Exception &ie) {
                if (ie.GetError() == ie_DF_SSIZE) {
                    log_DBG_m(dbg_LOW, "BSEnd error: " << ie.GetFriendly());
                    // end byte stream, with different status -> should succeeed
                    a_packer.WriteRecBSEnd(df_SS_ABORTED);
                }
                else
                    throw;
            }

        }
        else if (ah.attrType == at_ADS) {
            string streamName(ip, ah.attrSize);

            log_DBG_m(dbg_DETAIL, " Attribute header: type = ADS name "
                << "  ofs " << ah.attrOfs  
                << "  size " << ah.attrSize 
                << "  name = " << streamName);

            a_packer.WriteRecBSStart(df_ST_ALTDATA, 
                                     streamName, 
                                     0);
            a_packer.WriteRecBSEnd(df_SS_COMPLETE);
            ip += ah.attrSize;
        }
        else {
                throw ivd_InternalError(ie_DF_INVSEQ, 
                        string("Unknown record type in split stream. type =") 
                        + cmn_Num2Str(int(ah.attrType)));
        }
    }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 70 of file fsc_nsAttrStream.h.


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