SNAP Library 2.1, Developer Reference  2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TMBlobBs Class Reference

#include <blobbs.h>

Inheritance diagram for TMBlobBs:
Collaboration diagram for TMBlobBs:

List of all members.

Public Member Functions

 TMBlobBs (const TStr &BlobBsFNm, const TFAccess &_Access=faRdOnly, const int &_MxSegLen=-1)
 ~TMBlobBs ()
TMBlobBsoperator= (const TMBlobBs &)
TStr GetVersionStr () const
TBlobPt PutBlob (const PSIn &SIn)
TBlobPt PutBlob (const TBlobPt &BlobPt, const PSIn &SIn)
PSIn GetBlob (const TBlobPt &BlobPt)
void DelBlob (const TBlobPt &BlobPt)
TBlobPt GetFirstBlobPt ()
TBlobPt FFirstBlobPt ()
bool FNextBlobPt (TBlobPt &TrvBlobPt, TBlobPt &BlobPt, PSIn &BlobSIn)

Static Public Member Functions

static PBlobBs New (const TStr &BlobBsFNm, const TFAccess &Access=faRdOnly, const int &MxSegLen=-1)
static bool Exists (const TStr &BlobBsFNm)

Private Member Functions

void LoadMain (int &Segs)
void SaveMain () const

Static Private Member Functions

static void GetNrFPathFMid (const TStr &BlobBsFNm, TStr &NrFPath, TStr &NrFMid)
static TStr GetMainFNm (const TStr &NrFPath, const TStr &NrFMid)
static TStr GetSegFNm (const TStr &NrFPath, const TStr &NrFMid, const int &SegN)

Private Attributes

TFAccess Access
int MxSegLen
TStr NrFPath
TStr NrFMid
TBlobBsV SegV
int CurSegN

Detailed Description

Definition at line 188 of file blobbs.h.


Constructor & Destructor Documentation

TMBlobBs::TMBlobBs ( const TStr BlobBsFNm,
const TFAccess _Access = faRdOnly,
const int &  _MxSegLen = -1 
)

Definition at line 449 of file blobbs.cpp.

References Access, TVec< TVal, TSizeTy >::Add(), TFile::DelWc(), TFile::Exists(), faCreate, Fail, faRdOnly, faRestore, faUpdate, forever, GetMainFNm(), GetNrFPathFMid(), GetSegFNm(), LoadMain(), TBlobBs::MxBlobFLen, MxSegLen, TGBlobBs::New(), New(), NrFMid, NrFPath, SaveMain(), and SegV.

Referenced by New().

                                                                      :
  TBlobBs(), Access(_Access), MxSegLen(_MxSegLen),
  NrFPath(), NrFMid(), SegV(), CurSegN(0){
  if (MxSegLen==-1){MxSegLen=MxBlobFLen;}
  GetNrFPathFMid(BlobBsFNm, NrFPath, NrFMid);
  switch (Access){
    case faCreate:{
      TFile::DelWc(BlobBsFNm+".*");
      TStr SegFNm=GetSegFNm(NrFPath, NrFMid, 0);
      PBlobBs Seg=TGBlobBs::New(SegFNm, faCreate, MxSegLen);
      SegV.Add(Seg);
      SaveMain(); break;}
    case faUpdate:
    case faRdOnly:{
      int Segs; LoadMain(Segs);
      for (int SegN=0; SegN<Segs; SegN++){
        TStr SegFNm=GetSegFNm(NrFPath, NrFMid, SegN);
        SegV.Add(TGBlobBs::New(SegFNm, Access, MxSegLen));
      }
      break;}
    case faRestore:{
      // assume no segments
      int Segs=-1;
      // if main-file exists
      if (TFile::Exists(GetMainFNm(NrFPath, NrFMid))){
        // load main file
        int _Segs; LoadMain(_Segs);
        // load segment-files which exist
        Segs=0;
        forever {
          // get segment file-name
          TStr SegFNm=GetSegFNm(NrFPath, NrFMid, Segs);
          // if segment-file exists then add segment else break check-loop
          if (TFile::Exists(SegFNm)){
            SegV.Add(TGBlobBs::New(SegFNm, Access, MxSegLen));
            Segs++;
          } else {
            break;
          }
        }
      }
      // if no segments exist then create blob-base from scratch
      if (Segs==-1){
        TStr SegFNm=GetSegFNm(NrFPath, NrFMid, 0);
        PBlobBs Seg=TGBlobBs::New(SegFNm, faCreate, MxSegLen);
        SegV.Add(Seg);
        SaveMain();
      }
      break;}
    default: Fail;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 503 of file blobbs.cpp.

References Access, faRdOnly, and SaveMain().

                   {
  if (Access!=faRdOnly){
    SaveMain();
  }
}

Here is the call graph for this function:


Member Function Documentation

void TMBlobBs::DelBlob ( const TBlobPt BlobPt) [virtual]

Implements TBlobBs.

Definition at line 546 of file blobbs.cpp.

References TBlobPt::GetSeg(), and SegV.

                                           {
  int SegN=BlobPt.GetSeg();
  SegV[SegN]->DelBlob(BlobPt);
}

Here is the call graph for this function:

bool TMBlobBs::Exists ( const TStr BlobBsFNm) [static]

Definition at line 576 of file blobbs.cpp.

References GetMainFNm(), GetNrFPathFMid(), NrFMid, and NrFPath.

                                          {
  TStr NrFPath; TStr NrFMid; GetNrFPathFMid(BlobBsFNm, NrFPath, NrFMid);
  TStr MainFNm=GetMainFNm(NrFPath, NrFMid);
  return TFile::Exists(MainFNm);
}

Here is the call graph for this function:

Implements TBlobBs.

Definition at line 555 of file blobbs.cpp.

References SegV.

                              {
  return SegV[0]->FFirstBlobPt();
}
bool TMBlobBs::FNextBlobPt ( TBlobPt TrvBlobPt,
TBlobPt BlobPt,
PSIn BlobSIn 
) [virtual]

Implements TBlobBs.

Definition at line 559 of file blobbs.cpp.

References TBlobPt::GetSeg(), TVec< TVal, TSizeTy >::Len(), TBlobPt::PutSeg(), and SegV.

                                                                            {
  uchar SegN=TrvBlobPt.GetSeg();
  if (SegV[SegN]->FNextBlobPt(TrvBlobPt, BlobPt, BlobSIn)){
    TrvBlobPt.PutSeg(SegN);
    BlobPt.PutSeg(SegN);
    return true;
  } else
  if (SegN==SegV.Len()-1){
    return false;
  } else {
    SegN++;
    TrvBlobPt=SegV[SegN]->FFirstBlobPt();
    TrvBlobPt.PutSeg(SegN);
    return FNextBlobPt(TrvBlobPt, BlobPt, BlobSIn);
  }
}

Here is the call graph for this function:

PSIn TMBlobBs::GetBlob ( const TBlobPt BlobPt) [virtual]

Implements TBlobBs.

Definition at line 541 of file blobbs.cpp.

References TBlobPt::GetSeg(), and SegV.

                                           {
  int SegN=BlobPt.GetSeg();
  return SegV[SegN]->GetBlob(BlobPt);
}

Here is the call graph for this function:

Implements TBlobBs.

Definition at line 551 of file blobbs.cpp.

References SegV.

                                {
  return SegV[0]->GetFirstBlobPt();
}
TStr TMBlobBs::GetMainFNm ( const TStr NrFPath,
const TStr NrFMid 
) [static, private]

Definition at line 423 of file blobbs.cpp.

Referenced by Exists(), LoadMain(), SaveMain(), and TMBlobBs().

                                         {
  return NrFPath+NrFMid+".mbb";
}

Here is the caller graph for this function:

void TMBlobBs::GetNrFPathFMid ( const TStr BlobBsFNm,
TStr NrFPath,
TStr NrFMid 
) [static, private]

Definition at line 417 of file blobbs.cpp.

References TStr::GetFMid(), TStr::GetFPath(), TStr::GetNrFMid(), and TStr::GetNrFPath().

Referenced by Exists(), and TMBlobBs().

                                                    {
  NrFPath=TStr::GetNrFPath(BlobBsFNm.GetFPath());
  NrFMid=TStr::GetNrFMid(BlobBsFNm.GetFMid());
}

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TMBlobBs::GetSegFNm ( const TStr NrFPath,
const TStr NrFMid,
const int &  SegN 
) [static, private]

Definition at line 428 of file blobbs.cpp.

References TStr::GetNrNumFExt().

Referenced by PutBlob(), and TMBlobBs().

                                                          {
  return NrFPath+NrFMid+".mbb"+""+TStr::GetNrNumFExt(SegN);
}

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TMBlobBs::GetVersionStr ( ) const [inline, virtual]

Implements TBlobBs.

Definition at line 210 of file blobbs.h.

Referenced by LoadMain(), and SaveMain().

                             {
    return TStr("Multiple-File Blob Base Format 1.0");}

Here is the caller graph for this function:

void TMBlobBs::LoadMain ( int &  Segs) [private]

Definition at line 433 of file blobbs.cpp.

References EAssert, GetMainFNm(), TILx::GetVarInt(), TILx::GetVarStr(), GetVersionStr(), MxSegLen, New(), NrFMid, NrFPath, oloCsSens, oloFrcEoln, and oloSigNum.

Referenced by TMBlobBs().

                                {
  PSIn SIn=TFIn::New(GetMainFNm(NrFPath, NrFMid));
  TILx Lx(SIn, TFSet()|oloFrcEoln|oloSigNum|oloCsSens);
  EAssert(Lx.GetVarStr("Version")==GetVersionStr());
  MxSegLen=Lx.GetVarInt("MxSegLen");
  Segs=Lx.GetVarInt("Segments");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PBlobBs TMBlobBs::New ( const TStr BlobBsFNm,
const TFAccess Access = faRdOnly,
const int &  MxSegLen = -1 
) [inline, static]

Definition at line 203 of file blobbs.h.

References Access, MxSegLen, and TMBlobBs().

Referenced by LoadMain(), PutBlob(), SaveMain(), and TMBlobBs().

                          {
    return PBlobBs(new TMBlobBs(BlobBsFNm, Access, MxSegLen));}

Here is the call graph for this function:

Here is the caller graph for this function:

TMBlobBs& TMBlobBs::operator= ( const TMBlobBs ) [inline]

Definition at line 208 of file blobbs.h.

References Fail.

{Fail; return *this;}
TBlobPt TMBlobBs::PutBlob ( const PSIn SIn) [virtual]

Implements TBlobBs.

Definition at line 509 of file blobbs.cpp.

References Access, TVec< TVal, TSizeTy >::Add(), CurSegN, EAssert, TBlobPt::Empty(), faCreate, faRestore, faUpdate, GetSegFNm(), TVec< TVal, TSizeTy >::Len(), MxSegLen, New(), NrFMid, NrFPath, TBlobPt::PutSeg(), and SegV.

Referenced by PutBlob().

                                        {
  EAssert((Access==faCreate)||(Access==faUpdate)||(Access==faRestore));
  TBlobPt BlobPt=SegV[CurSegN]->PutBlob(SIn);
  if (BlobPt.Empty()){
    for (uchar SegN=0; SegN<SegV.Len(); SegN++){
      BlobPt=SegV[CurSegN=SegN]->PutBlob(SIn);
      if (!BlobPt.Empty()){break;}
    }
    if (BlobPt.Empty()){
      TStr SegFNm=GetSegFNm(NrFPath, NrFMid, SegV.Len());
      PBlobBs Seg=TGBlobBs::New(SegFNm, faCreate, MxSegLen);
      CurSegN=SegV.Add(Seg); EAssert(CurSegN<=255);
      BlobPt=SegV[CurSegN]->PutBlob(SIn);
    }
  }
  if (!BlobPt.Empty()){
    BlobPt.PutSeg(uchar(CurSegN));}
  return BlobPt;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TBlobPt TMBlobBs::PutBlob ( const TBlobPt BlobPt,
const PSIn SIn 
) [virtual]

Implements TBlobBs.

Definition at line 529 of file blobbs.cpp.

References Access, EAssert, TBlobPt::Empty(), faCreate, faRestore, faUpdate, TBlobPt::GetSeg(), PutBlob(), TBlobPt::PutSeg(), and SegV.

                                                               {
  EAssert((Access==faCreate)||(Access==faUpdate)||(Access==faRestore));
  int SegN=BlobPt.GetSeg();
  TBlobPt NewBlobPt=SegV[SegN]->PutBlob(BlobPt, SIn);
  if (NewBlobPt.Empty()){
    NewBlobPt=PutBlob(SIn);
  } else {
    NewBlobPt.PutSeg(BlobPt.GetSeg());
  }
  return NewBlobPt;
}

Here is the call graph for this function:

void TMBlobBs::SaveMain ( ) const [private]

Definition at line 441 of file blobbs.cpp.

References GetMainFNm(), GetVersionStr(), TVec< TVal, TSizeTy >::Len(), MxSegLen, New(), NrFMid, NrFPath, oloCsSens, oloFrcEoln, oloSigNum, TOLx::PutVarInt(), TOLx::PutVarStr(), and SegV.

Referenced by TMBlobBs(), and ~TMBlobBs().

                              {
  PSOut SOut=TFOut::New(GetMainFNm(NrFPath, NrFMid));
  TOLx Lx(SOut, TFSet()|oloFrcEoln|oloSigNum|oloCsSens);
  Lx.PutVarStr("Version", GetVersionStr());
  Lx.PutVarInt("MxSegLen", MxSegLen);
  Lx.PutVarInt("Segments", SegV.Len());
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 190 of file blobbs.h.

Referenced by New(), PutBlob(), TMBlobBs(), and ~TMBlobBs().

int TMBlobBs::CurSegN [private]

Definition at line 194 of file blobbs.h.

Referenced by PutBlob().

int TMBlobBs::MxSegLen [private]

Definition at line 191 of file blobbs.h.

Referenced by LoadMain(), New(), PutBlob(), SaveMain(), and TMBlobBs().

Definition at line 192 of file blobbs.h.

Referenced by Exists(), LoadMain(), PutBlob(), SaveMain(), and TMBlobBs().

Definition at line 192 of file blobbs.h.

Referenced by Exists(), LoadMain(), PutBlob(), SaveMain(), and TMBlobBs().


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