本文整理汇总了C++中DataFile类的典型用法代码示例。如果您正苦于以下问题:C++ DataFile类的具体用法?C++ DataFile怎么用?C++ DataFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GETSTRING
bool Settings::LoadSettings()
////////////////////////////////////////////////////////////////////////
{
#define GETSTRING(a,b) if (settingsfile.GetString(a, tempstring)) Set##b(tempstring);
#define GETBOOL(a,b) if (settingsfile.GetBool(a, tempbool)) Set##b(tempbool);
#define GETINT(a,b) if (settingsfile.GetInteger(a, tempint)) Set##b(tempint);
BString tempstring;
bool tempbool;
int tempint;
DataFile settingsfile;
if (settingsfile.LoadDataFile(GetSettingsFile()))
{
if (settingsfile.GetBool("ASKONEXIT", tempbool))
SetAskOnExit(tempbool);
if (settingsfile.GetString("LANGUAGE", tempstring))
SetLanguage(tempstring);
if (settingsfile.GetInteger("WINDOWLEFT", tempint))
SetWindowLeft(tempint);
GETINT("WINDOWTOP", WindowTop);
GETINT("WINDOWWIDTH", WindowWidth);
GETINT("WINDOWHEIGHT", WindowHeight);
GETSTRING("TERMINALWINDOW", TerminalWindow);
GETSTRING("LEFTPANELPATH", LeftPanelPath);
GETSTRING("RIGHTPANELPATH", RightPanelPath);
return true;
}
else
return false;
}
示例2: flushFiles
void ExtentManager::flushFiles( bool sync ) {
DEV Lock::assertAtLeastReadLocked( _dbname );
for( vector<DataFile*>::iterator i = _files.begin(); i != _files.end(); i++ ) {
DataFile *f = *i;
f->flush(sync);
}
}
示例3: Init
// Action_Angle::init()
Action::RetType Action_Angle::Init(ArgList& actionArgs, TopologyList* PFL, DataSetList* DSL, DataFileList* DFL, int debugIn)
{
// Get keywords
DataFile* outfile = DFL->AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
useMass_ = actionArgs.hasKey("mass");
// Get Masks
std::string mask1 = actionArgs.GetMaskNext();
std::string mask2 = actionArgs.GetMaskNext();
std::string mask3 = actionArgs.GetMaskNext();
if (mask1.empty() || mask2.empty() || mask3.empty()) {
mprinterr("Error: angle: Requires 3 masks\n");
return Action::ERR;
}
Mask1_.SetMaskString(mask1);
Mask2_.SetMaskString(mask2);
Mask3_.SetMaskString(mask3);
// Dataset to store angles
ang_ = DSL->AddSet(DataSet::DOUBLE, MetaData(actionArgs.GetStringNext(),MetaData::M_ANGLE),"Ang");
if (ang_==0) return Action::ERR;
// Add dataset to data file list
if (outfile != 0) outfile->AddDataSet( ang_ );
mprintf(" ANGLE: [%s]-[%s]-[%s]\n",Mask1_.MaskString(), Mask2_.MaskString(),
Mask3_.MaskString());
if (useMass_)
mprintf("\tUsing center of mass of atoms in masks.\n");
return Action::OK;
}
示例4: quantizeExtentSize
DiskLoc MmapV1ExtentManager::_createExtent( OperationContext* txn,
int size,
bool enforceQuota ) {
size = quantizeExtentSize( size );
if ( size > maxSize() )
size = maxSize();
verify( size < DataFile::maxSize() );
for ( int i = numFiles() - 1; i >= 0; i-- ) {
DataFile* f = _getOpenFile(i);
invariant(f);
if ( f->getHeader()->unusedLength >= size ) {
return _createExtentInFile( txn, i, f, size, enforceQuota );
}
}
_checkQuota( enforceQuota, numFiles() );
// no space in an existing file
// allocate files until we either get one big enough or hit maxSize
for ( int i = 0; i < 8; i++ ) {
DataFile* f = _addAFile( txn, size, false );
if ( f->getHeader()->unusedLength >= size ) {
return _createExtentInFile( txn, numFiles() - 1, f, size, enforceQuota );
}
}
// callers don't check for null return code, so assert
msgasserted(14810, "couldn't allocate space for a new extent" );
}
示例5: quantizeExtentSize
Extent* ExtentManager::createExtent(const char *ns, int size, bool newCapped, bool enforceQuota ) {
size = quantizeExtentSize( size );
for ( int i = numFiles() - 1; i >= 0; i-- ) {
DataFile* f = getFile( i );
if ( f->getHeader()->unusedLength >= size ) {
return _createExtentInFile( i, f, ns, size, newCapped, enforceQuota );
}
}
// no space in an existing file
// allocate files until we either get one big enough or hit maxSize
for ( int i = 0; i < 8; i++ ) {
DataFile* f = addAFile( size, false );
if ( f->getHeader()->unusedLength >= size ||
f->getHeader()->fileLength >= DataFile::maxSize() ) {
return _createExtentInFile( numFiles() - 1, f, ns, size, newCapped, enforceQuota );
}
}
// callers don't check for null return code, so assert
msgasserted(14810, "couldn't allocate space for a new extent" );
}
示例6: mprinterr
Exec::RetType Exec_Precision::Execute(CpptrajState& State, ArgList& argIn) {
// Next string is DataSet(s)/DataFile that command pertains to.
std::string name1 = argIn.GetStringNext();
if (name1.empty()) {
mprinterr("Error: No filename/setname given.\n");
return CpptrajState::ERR;
}
// This will break if dataset name starts with a digit...
int width = argIn.getNextInteger(12);
if (width < 1) {
mprintf("Error: Cannot set width < 1 (%i).\n", width);
return CpptrajState::ERR;
}
int precision = argIn.getNextInteger(4);
if (precision < 0) precision = 0;
DataFile* df = State.DFL().GetDataFile(name1);
if (df != 0) {
mprintf("\tSetting precision for all sets in %s to %i.%i\n", df->DataFilename().base(),
width, precision);
df->SetDataFilePrecision(width, precision);
} else {
State.DSL().SetPrecisionOfDataSets( name1, width, precision );
}
return CpptrajState::OK;
}
示例7: rMain
void
MissionSelector::loadMission(string fileName)
{
if(fileName == "") return;
Mission* oldMission = rMain()->getMission();
Orbit* orbitScreen = static_cast<Orbit*>(rMain()->getScreenManager().getState(Main::ORBIT_SCREEN));
orbitScreen->enterReadyState();
DataFile* dataFile = new DataFile(stringToWString(fileName));
if(dataFile->getRootItem() != NULL) {
Mission* mission = dataFile->getRootItem()->castToClass<Mission>();
if(mission != NULL) {
rMain()->setMission(mission);
if(oldMission != NULL) {
if (oldMission == ConfigManager::getPlayer()->getHomeBase()) {
ConfigManager::getSingleton().savePlayer();
}
else {
delete oldMission->getDataFile();
}
}
}
}
}
示例8: sqlLoadCode
void sqlLoadCode( const Database &db ,
const SqlApiBindProgramId &programid ,
int nr ,
VirtualCode &vc ) {
DataFile datafile ( db, SYSTEM_CODEDATA_FNAME, DBFMODE_READONLY);
KeyFile indexfile ( db, SYSTEM_CODEKEY_FNAME , DBFMODE_READONLY);
KeyFileDefinition keydef(indexfile);
KeyType key;
keydef.put(key,0,String(programid.m_fileName));
keydef.put(key,1,nr);
bool found = indexfile.searchMin( RELOP_EQ, key, 2);
#ifdef DEBUGMODULE
_tprintf(_T("loading code for <%s>,%d\n"),programid.filename,nr);
#endif
if(!found)
throwSqlError(SQL_UNKNOWN_PROGRAMID,_T("Unknown programfile:<%s>"),programid.m_fileName);
datafile.readRecord( keydef.getRecordAddr(key), &vc, sizeof(VirtualCode));
if(_tcscmp(vc.getProgramId().m_timestamp,programid.m_timestamp) != 0)
throwSqlError(SQL_TIMESTAMP_MISMATCH,_T("Timestamp mismatch on <%s>"),programid.m_fileName);
}
示例9: Init
/** Called once before traj processing. Set up reference info. */
Action::RetType Action_DistRmsd::Init(ArgList& actionArgs, TopologyList* PFL, DataSetList* DSL, DataFileList* DFL, int debugIn)
{
// Check for keywords
DataFile* outfile = DFL->AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
// Reference keywords
// TODO: Can these just be put in the InitRef call?
bool first = actionArgs.hasKey("first");
ReferenceFrame REF = DSL->GetReferenceFrame( actionArgs );
std::string reftrajname = actionArgs.GetStringKey("reftraj");
Topology* RefParm = PFL->GetParm( actionArgs );
// Get the RMS mask string for target
std::string mask0 = actionArgs.GetMaskNext();
TgtMask_.SetMaskString(mask0);
// Get the RMS mask string for reference
std::string mask1 = actionArgs.GetMaskNext();
if (mask1.empty())
mask1 = mask0;
// Initialize reference
if (refHolder_.InitRef(false, first, false, false, reftrajname, REF, RefParm,
mask1, actionArgs, "distrmsd"))
return Action::ERR;
// Set up the RMSD data set
drmsd_ = DSL->AddSet(DataSet::DOUBLE, actionArgs.GetStringNext(),"DRMSD");
if (drmsd_==0) return Action::ERR;
// Add dataset to data file list
if (outfile != 0) outfile->AddDataSet( drmsd_ );
mprintf(" DISTRMSD: (%s), reference is %s\n",TgtMask_.MaskString(),
refHolder_.RefModeString());
return Action::OK;
}
示例10: Init
Action::RetType Action_Channel::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
// Keywords.
DataFile* outfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
dxyz_[0] = actionArgs.getKeyDouble("dx", 0.35);
dxyz_[1] = actionArgs.getKeyDouble("dy", dxyz_[0]);
dxyz_[2] = actionArgs.getKeyDouble("dz", dxyz_[1]);
// solute mask
std::string sMask = actionArgs.GetMaskNext();
if (sMask.empty()) {
mprinterr("Error: No solute mask specified.\n");
return Action::ERR;
}
soluteMask_.SetMaskString( sMask );
// solvent mask
sMask = actionArgs.GetMaskNext();
if (sMask.empty())
sMask.assign(":[email protected]");
solventMask_.SetMaskString( sMask );
// Grid Data Set
grid_ = init.DSL().AddSet(DataSet::GRID_FLT, actionArgs.GetStringNext(), "Channel");
if (grid_ == 0) return Action::ERR;
if (outfile != 0) outfile->AddDataSet( grid_ );
mprintf("Warning: *** THIS ACTION IS EXPERIMENTAL AND NOT FULLY IMPLEMENTED. ***\n");
mprintf(" CHANNEL: Solute mask [%s], solvent mask [%s]\n",
soluteMask_.MaskString(), solventMask_.MaskString());
mprintf("\tSpacing: XYZ={ %g %g %g }\n", dxyz_[0], dxyz_[1], dxyz_[2]);
return Action::OK;
}
示例11: if
// Action_AreaPerMol::Init()
Action::RetType Action_AreaPerMol::Init(ArgList& actionArgs, TopologyList* PFL, DataSetList* DSL, DataFileList* DFL, int debugIn)
{
// Get keywords
DataFile* outfile = DFL->AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
if (actionArgs.hasKey("xy")) areaType_ = XY;
else if (actionArgs.hasKey("xz")) areaType_ = XZ;
else if (actionArgs.hasKey("yz")) areaType_ = YZ;
else areaType_ = XY;
Nmols_ = (double)actionArgs.getKeyInt("nmols", -1);
// Get Masks
if (Nmols_ < 0.0) {
Nlayers_ = (double)actionArgs.getKeyInt("nlayers", 1);
if (Nlayers_ < 1.0) {
mprinterr("Error: Number of layers must be > 0\n");
return Action::ERR;
}
Mask1_.SetMaskString( actionArgs.GetMaskNext() );
}
// DataSet
area_per_mol_ = DSL->AddSet(DataSet::DOUBLE, actionArgs.GetStringNext(),"APM");
if (area_per_mol_==0) return Action::ERR;
// Add DataSet to DataFileList
if (outfile != 0) outfile->AddDataSet( area_per_mol_ );
mprintf(" AREAPERMOL: Calculating %s area per molecule", APMSTRING[areaType_]);
if (Mask1_.MaskStringSet())
mprintf(" using mask '%s', %.0f layers.\n", Mask1_.MaskString(), Nlayers_);
else
mprintf(" for %.0f mols\n", Nmols_);
return Action::OK;
}
示例12: verify
// todo: this is called a lot. streamline the common case
DataFile* MmapV1ExtentManager::getFile( TransactionExperiment* txn,
int n,
int sizeNeeded ,
bool preallocateOnly) {
verify(this);
DEV Lock::assertAtLeastReadLocked( _dbname );
if ( n < 0 || n >= DiskLoc::MaxFiles ) {
log() << "getFile(): n=" << n << endl;
massert( 10295 , "getFile(): bad file number value (corrupt db?)."
" See http://dochub.mongodb.org/core/data-recovery", false);
}
DEV {
if ( n > 100 ) {
log() << "getFile(): n=" << n << endl;
}
}
DataFile* p = 0;
if ( !preallocateOnly ) {
while ( n >= (int) _files.size() ) {
verify(this);
if( !Lock::isWriteLocked(_dbname) ) {
log() << "error: getFile() called in a read lock, yet file to return is not yet open";
log() << " getFile(" << n << ") _files.size:" <<_files.size() << ' ' << fileName(n).string();
invariant(false);
}
_files.push_back(0);
}
p = _files[n];
}
if ( p == 0 ) {
if ( n == 0 ) audit::logCreateDatabase( currentClient.get(), _dbname );
DEV Lock::assertWriteLocked( _dbname );
boost::filesystem::path fullName = fileName( n );
string fullNameString = fullName.string();
p = new DataFile(n);
int minSize = 0;
if ( n != 0 && _files[ n - 1 ] )
minSize = _files[ n - 1 ]->getHeader()->fileLength;
if ( sizeNeeded + DataFileHeader::HeaderSize > minSize )
minSize = sizeNeeded + DataFileHeader::HeaderSize;
try {
Timer t;
p->open( txn, fullNameString.c_str(), minSize, preallocateOnly );
if ( t.seconds() > 1 ) {
log() << "MmapV1ExtentManager took " << t.seconds()
<< " seconds to open: " << fullNameString;
}
}
catch ( AssertionException& ) {
delete p;
throw;
}
if ( preallocateOnly )
delete p;
else
_files[n] = p;
}
return preallocateOnly ? 0 : p;
}
示例13: DealWithMatch
bool DealWithMatch(const vector <string> &LineList, const boost::regex &RegExpress, const DataFile &TypeEntry, ofstream &TableStream,
const size_t FilingIndex)
// MAJOR robustness issues here! See notes in this function.
{
// cerr << "Going into DealWithMatch()\n";
bool IsSuccessful;
const vector <string> Captures = ObtainCaptures(RegExpress, LineList[0], TypeEntry.PatternExplainCount() + 1);
// cerr << "Got Captures\n";
const vector <string> Descriptors = GatherInfo(LineList, Captures, TypeEntry.GiveAllPatternExplains(),
TypeEntry.GiveAllAssignExpressions(), IsSuccessful);
// cerr << "Got Descriptors\n";
// May need to put in controls of some sort to determine whether something should be quoted or not.
if (IsSuccessful)
{
TableStream << GiveDelimitedList(LineList, ',') << ',' << FilingIndex << ',' << GiveDelimitedList(Descriptors, ',') << "\n";
}
// This above segment prints to the appropriate subcatalogue file the following info:
// Filename, File Group number, Volume Name, FileSize, FilingIndex, and Date information for the file, and any other descriptor information.
// there is always DateTime_Info for Descriptors[0]
return(TableStream.good());
}
示例14: while
// Action_FilterByData::Init()
Action::RetType Action_FilterByData::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
maxmin_ = init.DSL().AddSet( DataSet::INTEGER, actionArgs.GetStringKey("name"), "Filter" );
if (maxmin_ == 0) return Action::ERR;
DataFile* maxminfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
if (maxminfile != 0)
maxminfile->AddDataSet( maxmin_ );
// Get min and max args.
while (actionArgs.Contains("min"))
Min_.push_back( actionArgs.getKeyDouble("min", 0.0) );
while (actionArgs.Contains("max"))
Max_.push_back( actionArgs.getKeyDouble("max", 0.0) );
if (Min_.empty()) {
mprinterr("Error: At least one 'min' arg must be specified.\n");
return Action::ERR;
}
if (Max_.empty()) {
mprinterr("Error: At least one 'max' arg must be specified.\n");
return Action::ERR;
}
if (Min_.size() != Max_.size()) {
mprinterr("Error: # of 'min' args (%zu) != # of 'max' args (%zu)\n",
Min_.size(), Max_.size());
return Action::ERR;
}
// Get DataSets from remaining arguments
Dsets_.AddSetsFromArgs( actionArgs.RemainingArgs(), init.DSL() );
if (Dsets_.empty()) {
mprinterr("Error: No data sets specified.\n");
return Action::ERR;
}
if ( Dsets_.size() < Min_.size() ) {
mprinterr("Error: More 'min'/'max' args (%zu) than data sets (%zu).\n",
Min_.size(), Dsets_.size());
return Action::ERR;
}
if ( Dsets_.size() > Min_.size() ) {
unsigned int Nremaining = Dsets_.size() - Min_.size();
double useMin = Min_.back();
double useMax = Max_.back();
mprintf("Warning: More data sets than 'min'/'max' args.\n"
"Warning: Using min=%f and max=%f for last %zu data sets.\n",
useMin, useMax, Nremaining);
for (unsigned int ds = 0; ds < Nremaining; ++ds) {
Min_.push_back( useMin );
Max_.push_back( useMax );
}
}
mprintf(" FILTER: Filtering out frames using %zu data sets.\n", Dsets_.size());
for (unsigned int ds = 0; ds < Dsets_.size(); ds++)
mprintf("\t%.4f < '%s' < %.4f\n", Min_[ds], Dsets_[ds]->legend(), Max_[ds]);
if (maxminfile != 0)
mprintf("\tFilter frame info will be written to %s\n", maxminfile->DataFilename().full());
return Action::OK;
}
示例15: GridInit
// Action_Grid::Init()
Action::RetType Action_Grid::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
debug_ = debugIn;
nframes_ = 0;
// Get output filename
std::string filename = actionArgs.GetStringKey("out");
// Get grid options
grid_ = GridInit( "GRID", actionArgs, init.DSL() );
if (grid_ == 0) return Action::ERR;
# ifdef MPI
if (ParallelGridInit(init.TrajComm(), grid_)) return Action::ERR;
# endif
// Get extra options
max_ = actionArgs.getKeyDouble("max", 0.80);
madura_ = actionArgs.getKeyDouble("madura", 0);
smooth_ = actionArgs.getKeyDouble("smoothdensity", 0);
invert_ = actionArgs.hasKey("invert");
pdbfile_ = init.DFL().AddCpptrajFile(actionArgs.GetStringKey("pdb"),"Grid PDB",DataFileList::PDB,true);
density_ = actionArgs.getKeyDouble("density",0.033456);
if (actionArgs.hasKey("normframe")) normalize_ = TO_FRAME;
else if (actionArgs.hasKey("normdensity")) normalize_ = TO_DENSITY;
else normalize_ = NONE;
if (normalize_ != NONE && (smooth_ > 0.0 || madura_ > 0.0)) {
mprinterr("Error: Normalize options are not compatible with smoothdensity/madura options.\n");
init.DSL().RemoveSet( grid_ );
return Action::ERR;
}
// Get mask
std::string maskexpr = actionArgs.GetMaskNext();
if (maskexpr.empty()) {
mprinterr("Error: GRID: No mask specified.\n");
init.DSL().RemoveSet( grid_ );
return Action::ERR;
}
mask_.SetMaskString(maskexpr);
// Setup output file
// For backwards compat., if no 'out' assume next string is filename
if (filename.empty() && actionArgs.Nargs() > 1 && !actionArgs.Marked(1))
filename = actionArgs.GetStringNext();
DataFile* outfile = init.DFL().AddDataFile(filename, actionArgs);
if (outfile != 0) outfile->AddDataSet((DataSet*)grid_);
// Info
mprintf(" GRID:\n");
GridInfo( *grid_ );
if (outfile != 0) mprintf("\tGrid will be printed to file %s\n", outfile->DataFilename().full());
mprintf("\tGrid data set: '%s'\n", grid_->legend());
mprintf("\tMask expression: [%s]\n",mask_.MaskString());
if (pdbfile_ != 0)
mprintf("\tPseudo-PDB will be printed to %s\n", pdbfile_->Filename().full());
if (normalize_ == TO_FRAME)
mprintf("\tGrid will be normalized by number of frames.\n");
else if (normalize_ == TO_DENSITY)
mprintf("\tGrid will be normalized to a density of %g molecules/Ang^3.\n", density_);
// TODO: print extra options
return Action::OK;
}