| 
    SNAP Library 2.0, Developer Reference
    2013-05-13 16:33:57
    
   SNAP, a general purpose, high performance system for analysis and manipulation of large networks 
   | 
  
  
  
 
#include <blobbs.h>


Public Member Functions | |
| TMBlobBs (const TStr &BlobBsFNm, const TFAccess &_Access=faRdOnly, const int &_MxSegLen=-1) | |
| ~TMBlobBs () | |
| TMBlobBs & | operator= (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 | 
| 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; } }


Definition at line 503 of file blobbs.cpp.
References Access, faRdOnly, and SaveMain().

| void TMBlobBs::DelBlob | ( | const TBlobPt & | BlobPt | ) |  [virtual] | 
        
Implements TBlobBs.
Definition at line 546 of file blobbs.cpp.
References TBlobPt::GetSeg(), and SegV.

| 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);
}

| TBlobPt TMBlobBs::FFirstBlobPt | ( | ) |  [virtual] | 
        
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);
  }
}

| PSIn TMBlobBs::GetBlob | ( | const TBlobPt & | BlobPt | ) |  [virtual] | 
        
Implements TBlobBs.
Definition at line 541 of file blobbs.cpp.
References TBlobPt::GetSeg(), and SegV.

| TBlobPt TMBlobBs::GetFirstBlobPt | ( | ) |  [virtual] | 
        
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";
}

| 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());
}


| 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);
}


| 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");}

| 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");
}


| 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().


| 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;
}


| 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;
}

| 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());
}


TFAccess TMBlobBs::Access [private] | 
        
Definition at line 190 of file blobbs.h.
Referenced by New(), PutBlob(), TMBlobBs(), and ~TMBlobBs().
int TMBlobBs::CurSegN [private] | 
        
int TMBlobBs::MxSegLen [private] | 
        
Definition at line 191 of file blobbs.h.
Referenced by LoadMain(), New(), PutBlob(), SaveMain(), and TMBlobBs().
TStr TMBlobBs::NrFMid [private] | 
        
Definition at line 192 of file blobbs.h.
Referenced by Exists(), LoadMain(), PutBlob(), SaveMain(), and TMBlobBs().
TStr TMBlobBs::NrFPath [private] | 
        
Definition at line 192 of file blobbs.h.
Referenced by Exists(), LoadMain(), PutBlob(), SaveMain(), and TMBlobBs().
TBlobBsV TMBlobBs::SegV [private] | 
        
Definition at line 193 of file blobbs.h.
Referenced by DelBlob(), FFirstBlobPt(), FNextBlobPt(), GetBlob(), GetFirstBlobPt(), PutBlob(), SaveMain(), and TMBlobBs().