This class is responsible to store the Cdr that belongs to a network partner balance sheet to file system (writing them to CDR file(s) in the corresponding balance page directory structure).
Definition at line 75 of file cdrioimpl.h.
typedef std::map<Date, CdrList> OSB_LIB::CdrIoImpl::CdrGroups [private] |
typedef std::set<std::string> OSB_LIB::CdrIoImpl::PathList [private] |
Constructor with id of supported balance page.
std::auto_ptr<CdrIo> OSB_LIB::CdrIoImpl::clone | ( | ) | const [virtual] |
bool OSB_LIB::CdrIoImpl::commitChanges | ( | ) | [virtual] |
Remove backup CDR files.
Implements OSB_LIB::CdrIo.
void OSB_LIB::CdrIoImpl::copyFile | ( | const std::string & | from, | |
const std::string & | to | |||
) | [private] |
Make a copy of a file.
from | Path name of source file. | |
to | Path name of target file. |
OsbException | for any error:
|
size_t OSB_LIB::CdrIoImpl::getCdrFiles | ( | const std::string & | dirName, | |
PathList & | dest | |||
) | [private] |
Get all CDR files.
dirName | Name of directory to search (recursivly). | |
dest | Gets the list of CDR files. |
OsbException | if the page directory exists but can not accessed. |
size_t OSB_LIB::CdrIoImpl::getSubDirs | ( | const std::string & | dirName, | |
PathList & | dest | |||
) | [private] |
Get all subdirectories.
dirName | Name of directory to search (recursivly). | |
dest | Gets the list of subdirectories. |
OsbException | if the page directory exists but can not accessed. |
Group cdrs by date.
The function groups the list of cdrs by date so that inserting these cdrs into the file system would be faster since the directory structure of these cdrs are stored by date.
dest | Gets the list of CDRs grouped by date. | |
src | The list of CDRs to be grouped. |
std::string OSB_LIB::CdrIoImpl::mkFilename | ( | long | n | ) | const [private] |
Create filename (without extension) from a number.
n | Number to use. |
void OSB_LIB::CdrIoImpl::moveFileAway | ( | const std::string & | path | ) | [private] |
Rename an obsolete backup file.
path | Path of backup file. |
OsbException | if rename() fails. |
std::string OSB_LIB::CdrIoImpl::newCdrFile | ( | const std::string & | dirName, | |
size_t | numFiles | |||
) | const [private] |
Create a new CDR file.
dirName | Directory in which to create the CDR file, it must exist. | |
numFiles | Number of CDR files in dirName. |
OsbException | if the creation of the CDR file fails. |
FILE* OSB_LIB::CdrIoImpl::openOutputFile | ( | std::string & | path, | |
bool | mkBackup | |||
) | [private] |
Open the last regular CDR file, creating a backup.
path | On input: Directory to use. The function appends a trailing / if needed. On output: Path to the opened CDR file (if the function returns successful). | |
mkBackup | Flag if backup copies of modified files must be created. |
OsbException | in case of any error:
|
std::string OSB_LIB::CdrIoImpl::pageDir | ( | ) | const [private] |
void OSB_LIB::CdrIoImpl::prepareWrite | ( | ) | [virtual] |
Prepare the CDR files for writing.
OsbException | for any error encountered. |
Implements OSB_LIB::CdrIo.
void OSB_LIB::CdrIoImpl::read | ( | CdrList & | dest, | |
const std::string & | path | |||
) | [private] |
Read all CDRs from a file.
dest | STL-container to store the CDR records. | |
path | Path of input file. |
OsbException |
|
void OSB_LIB::CdrIoImpl::read | ( | CdrList & | dest | ) | [virtual] |
Retrieve the call details records of a balance page.
dest | STL-container to store the CDR records. |
OsbException | for any error encountered. |
Implements OSB_LIB::CdrIo.
bool OSB_LIB::CdrIoImpl::remove | ( | ) | [virtual] |
Remove related CDR files and directories from file system.
This function deletes all regular CDR files and, if empty, the directories below and including baseDir_.
Implements OSB_LIB::CdrIo.
bool OSB_LIB::CdrIoImpl::removeChangedFile | ( | const std::string & | path | ) | [private] |
Remove a changed CDR file.
path | Path of file to remove. |
bool OSB_LIB::CdrIoImpl::removeChangedFiles | ( | ) | [private] |
Remove all changed CDR files.
std::string OSB_LIB::CdrIoImpl::renameCdrFile | ( | const std::string & | filePath, | |
const std::string & | extTo | |||
) | [private] |
Rename a CDR file to its backup.
filePath | Path of CDR file. | |
extTo | Extension of backup file. |
OsbException |
|
void OSB_LIB::CdrIoImpl::replace | ( | const CdrList & | newCdrs, | |
Asn1Writer & | writer | |||
) | [virtual] |
Replace CDRs on the file system.
newCdrs | STL container with new CDRs. | |
writer | ASN.1 writer to use. |
OsbException | for any error encountered. |
Implements OSB_LIB::CdrIo.
bool OSB_LIB::CdrIoImpl::restoreCdrFile | ( | const std::string & | path | ) | [private] |
Recover a CDR file.
bool OSB_LIB::CdrIoImpl::restoreCdrFiles | ( | ) | [private] |
Restore all changed CDR files.
bool OSB_LIB::CdrIoImpl::undoChanges | ( | ) | [virtual] |
Undo a previous call to write() or replace().
Implements OSB_LIB::CdrIo.
void OSB_LIB::CdrIoImpl::write | ( | const CdrList & | cdrs, | |
Asn1Writer & | writer, | |||
bool | mkBackup | |||
) | [private] |
Write the CDRs to the file system.
cdrs | List of CDRs to write. | |
writer | ASN.1 writer to use. | |
mkBackup | Flag if backup copies of modified files must be created. |
OsbException | in case of any error. |
void OSB_LIB::CdrIoImpl::write | ( | const CdrList & | cdrs, | |
Asn1Writer & | writer | |||
) | [virtual] |
Write CDRs to the file system.
cdrs | List of call details records to write. | |
writer | ASN.1 writer to use. |
OsbException | for any error encountered. |
Implements OSB_LIB::CdrIo.
PathList OSB_LIB::CdrIoImpl::changedFiles_ [private] |
const std::string OSB_LIB::CdrIoImpl::extBak_ [static, private] |
const std::string OSB_LIB::CdrIoImpl::extCdr_ [static, private] |
const std::string OSB_LIB::CdrIoImpl::extRpl_ [static, private] |
Id<BsPage> OSB_LIB::CdrIoImpl::pageId_ [private] |
PathList OSB_LIB::CdrIoImpl::recoverFiles_ [private] |