当前位置: 首页>>代码示例>>C++>>正文


C++ UTIL_THROW函数代码示例

本文整理汇总了C++中UTIL_THROW函数的典型用法代码示例。如果您正苦于以下问题:C++ UTIL_THROW函数的具体用法?C++ UTIL_THROW怎么用?C++ UTIL_THROW使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了UTIL_THROW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UTIL_THROW

   /* 
   * Read potential parameters from file.
   */
   void LocalLamellarOrderingExternal::readParameters(std::istream &in) 
   {
      if (nAtomType_ == 0) {
         UTIL_THROW("nAtomType must be set before readParam");
      }
      if (!boundaryPtr_) {
         UTIL_THROW("Boundary must be set before readParam");
      }
   
      // Read parameters
      read<int>(in, "perpDirection", perpDirection_);
      if (perpDirection_ < 0 || perpDirection_ >= Dimension) {
         UTIL_THROW("Invalid index for perpendicular direction.");
      }
      read<int>(in, "parallelDirection", parallelDirection_);
      if (parallelDirection_ < 0 || parallelDirection_ >= Dimension) {
         UTIL_THROW("Invalid index for parallel direction.");
      }
      read<double>(in, "fraction", fraction_);
      prefactor_.allocate(nAtomType_);
      readDArray<double>(in, "prefactor", prefactor_, nAtomType_);
      read<double>(in, "externalParameter", externalParameter_);
      read<double>(in, "interfaceWidth", width_);
      read<int>(in, "periodicity", periodicity_);

      isInitialized_ = true;
   }
开发者ID:TaherGhasimakbari,项目名称:simpatico,代码行数:30,代码来源:LocalLamellarOrderingExternal.cpp

示例2: UTIL_THROW

   /* 
   * Read potential parameters from file.
   */
   void PeriodicExternal::readParameters(std::istream &in) 
   {
      if (nAtomType_ == 0) {
         UTIL_THROW("nAtomType must be set before readParam");
      }
      if (!boundaryPtr_) {
         UTIL_THROW("Boundary must be set before readParam");
      }
  
      // Read parameters
      prefactor_.allocate(nAtomType_);
      readDArray<double>(in, "prefactor", prefactor_, nAtomType_);

      read<double>(in, "externalParameter", externalParameter_);

      read<int>(in, "nWaveVectors", nWaveVectors_);
      read<double>(in, "C", C_);
      waveVectors_.allocate(nWaveVectors_);
      readDArray<Vector>(in, "waveVectors", waveVectors_, nWaveVectors_);

      phases_.allocate(nWaveVectors_);
      readDArray<double>(in, "phases", phases_, nWaveVectors_);
      read<Vector>(in, "shift", shift_);
      read<double>(in, "interfaceWidth", interfaceWidth_);
      read<int>(in, "periodicity", periodicity_);

      isInitialized_ = true;
   }
开发者ID:medapuram,项目名称:simpatico,代码行数:31,代码来源:PeriodicExternal.cpp

示例3: UTIL_THROW

   void McSimulation::load(const std::string& filename)
   {
      if (isInitialized_) {
         UTIL_THROW("Error: Called load when already initialized");
      }
      if (!isRestarting_) {
         UTIL_THROW("Error: Called load without restart option");
      }

      // Load from archive
      Serializable::IArchive ar;
      std::ios_base::openmode mode = std::ios_base::in | std::ios_base::binary;
      fileMaster().openRestartIFile(filename, ar.file(), mode);
      load(ar);
      ar.file().close();

      #ifdef UTIL_MPI
      #ifdef MCMD_PERTURB
      if (system().hasPerturbation()) {
         // Read one command file, after reading multiple restart files.
         Util::Log::file() << "Set to use a single command file" 
                           << std::endl;
         setIoCommunicator();
      }
      #endif
      #endif

      isInitialized_ = true;
   }
开发者ID:TaherGhasimakbari,项目名称:simpatico,代码行数:29,代码来源:McSimulation.cpp

示例4: UTIL_THROW

   /*
   * Remove all ghosts.
   */
   void AtomStorage::clearGhosts()
   {
      // Precondition
      if (locked_) 
         UTIL_THROW("AtomStorage is locked");

      // Clear ghosts from the map
      map_.clearGhosts(ghostSet_);

      // Transfer ghosts from the set to the reservoir
      Atom* atomPtr;
      while (ghostSet_.size() > 0) {
         atomPtr = &ghostSet_.pop();
         ghostReservoir_.push(*atomPtr);
      }

      if (ghostSet_.size() != 0) {
         UTIL_THROW("Nonzero ghostSet size at end of clearGhosts");
      }
      if (map_.nGhost() != 0) {
         UTIL_THROW("Nonzero nGhost in map at end of clearGhosts");
      }
      if (map_.nGhostDistinct() != 0) {
         UTIL_THROW("Nonzero nGhostDistinct at end of clearGhosts");
      }
   }
开发者ID:tdunn19,项目名称:simpatico,代码行数:29,代码来源:AtomStorage.cpp

示例5: UTIL_THROW

   /*
   * Load state from an archive.
   */
   void ClusterHistogram::loadParameters(Serializable::IArchive& ar)
   {
      // Load interval and outputFileName
      Analyzer::loadParameters(ar);

      loadParameter<int>(ar,"speciesId", speciesId_);
      if (speciesId_ < 0) {
         UTIL_THROW("Negative speciesId");
      }
      if (speciesId_ >= system().simulation().nSpecies()) {
         UTIL_THROW("speciesId > nSpecies");
      }

      loadParameter<int>(ar, "atomTypeId", atomTypeId_);
      if (atomTypeId_ < 0) {
         UTIL_THROW("Negative atomTypeId");
      }

      loadParameter<double>(ar, "cutoff", cutoff_);
      if (cutoff_ < 0) {
         UTIL_THROW("Negative cutoff");
      }

      identifier_.initialize(speciesId_, atomTypeId_, cutoff_);
      loadParameter<int>(ar, "histMin", histMin_);
      loadParameter<int>(ar, "histMax", histMax_);
      ar >> hist_;

      ar >> nSample_;

      isInitialized_ = true;
   }
开发者ID:dmorse,项目名称:simpatico,代码行数:35,代码来源:ClusterHistogram.cpp

示例6: UTIL_THROW

   /*
   * Load state from an archive.
   */
   void StructureFactor::loadParameters(Serializable::IArchive& ar)
   {
      Analyzer::loadParameters(ar);
      ar & nAtomType_;
      loadParameter<int>(ar, "nMode", nMode_);
      loadDMatrix<double>(ar, "modes", modes_, nMode_, nAtomType_);
      loadParameter<int>(ar, "nWave", nWave_);
      loadDArray<IntVector>(ar, "waveIntVectors", waveIntVectors_, nWave_);
      ar & structureFactors_;
      ar & nSample_;

      // Validate
      if (nAtomType_ != system().simulation().nAtomType()) {
         UTIL_THROW("Inconsistent values of nAtomType_");
      }
      if (modes_.capacity1() != nMode_) {
         UTIL_THROW("Inconsistent capacity1 for modes array");
      }
      if (modes_.capacity2() != nAtomType_) {
         UTIL_THROW("Inconsistent capacity2 for modes array");
      }
      if (waveIntVectors_.capacity() != nWave_) {
         UTIL_THROW("Inconsistent capacity for waveIntVector");
      }

      // Allocate temporary data structures
      waveVectors_.allocate(nWave_);
      fourierModes_.allocate(nWave_, nMode_);

      isInitialized_ = true;
   }
开发者ID:medapuram,项目名称:simpatico,代码行数:34,代码来源:StructureFactor.cpp

示例7: if

void ScoreFeatureManager::configure(const std::vector<std::string> args)
{
  bool domainAdded = false;
  bool sparseDomainAdded = false;

  for (size_t i = 0; i < args.size(); ++i) {
  	if (args[i] == "--IgnoreSentenceId") {
      m_includeSentenceId = true;
    } else if (args[i].substr(0,8) == "--Domain") {
      string type = args[i].substr(8);
      ++i;
      UTIL_THROW_IF(i == args.size(), ScoreFeatureArgumentException, "Missing domain file");
      string domainFile = args[i];
      UTIL_THROW_IF(domainAdded, ScoreFeatureArgumentException,
                    "Only allowed one domain feature");
      if (type == "Subset") {
        m_features.push_back(ScoreFeaturePtr(new SubsetDomainFeature(domainFile)));
      } else if (type == "Ratio") {
        m_features.push_back(ScoreFeaturePtr(new RatioDomainFeature(domainFile)));
      } else if (type == "Indicator") {
        m_features.push_back(ScoreFeaturePtr(new IndicatorDomainFeature(domainFile)));
      } else {
        UTIL_THROW(ScoreFeatureArgumentException, "Unknown domain feature type " << type);
      }
      domainAdded = true;
      m_includeSentenceId = true;
    } else if (args[i].substr(0,14) == "--SparseDomain") {
      string type = args[i].substr(14);
      ++i;
      UTIL_THROW_IF(i == args.size(), ScoreFeatureArgumentException, "Missing domain file");
      string domainFile = args[i];
      UTIL_THROW_IF(sparseDomainAdded, ScoreFeatureArgumentException,
                    "Only allowed one sparse domain feature");
      if (type == "Subset") {
        m_features.push_back(ScoreFeaturePtr(new SparseSubsetDomainFeature(domainFile)));
      } else if (type == "Ratio") {
        m_features.push_back(ScoreFeaturePtr(new SparseRatioDomainFeature(domainFile)));
      } else if (type == "Indicator") {
        m_features.push_back(ScoreFeaturePtr(new SparseIndicatorDomainFeature(domainFile)));
      } else {
        UTIL_THROW(ScoreFeatureArgumentException, "Unknown domain feature type " << type);
      }
      sparseDomainAdded = true;
      m_includeSentenceId = true;
    } else if(args[i] == "--GHKMFeatureSparse"){
    	//MARIA
    	m_features.push_back(ScoreFeaturePtr(new InternalStructFeatureSparse()));
    } else if(args[i] == "--GHKMFeatureDense"){
    	//MARIA
    	m_features.push_back(ScoreFeaturePtr(new InternalStructFeatureDense()));
    } else {
      UTIL_THROW(ScoreFeatureArgumentException,"Unknown score argument " << args[i]);
    	}

  }

}
开发者ID:akartbayev,项目名称:mosesdecoder,代码行数:57,代码来源:ScoreFeature.cpp

示例8: UTIL_THROW

 /* 
 * Set nAtomType
 */
 void OrthoBoxExternal::setNAtomType(int nAtomType) 
 {  
    if (nAtomType <= 0) {
       UTIL_THROW("nAtomType <= 0");
    }
    if (nAtomType > MaxAtomType) {
       UTIL_THROW("nAtomType > OrthoBoxExternal::MaxAtomType");
    }
    nAtomType_ = nAtomType;
 }
开发者ID:jglaser,项目名称:simpatico,代码行数:13,代码来源:OrthoBoxExternal.cpp

示例9: UTIL_THROW

 /* 
 * Set nAtomType
 */
 void NucleationExternal::setNAtomType(int nAtomType) 
 {  
    if (nAtomType <= 0) {
       UTIL_THROW("nAtomType <= 0");
    }
    if (nAtomType > MaxAtomType) {
       UTIL_THROW("nAtomType > NucleationExternal::MaxAtomType");
    }
    nAtomType_ = nAtomType;
 }
开发者ID:jmysona,项目名称:testing2,代码行数:13,代码来源:NucleationExternal.cpp

示例10: UTIL_THROW

 /*
 * Clear memory block (reset to empty state).
 */
 void MemoryIArchive::clear()
 {
    if (!isAllocated()) {
       UTIL_THROW("Archive is not allocated");
    }
    if (!ownsData_) {  
       UTIL_THROW("Archive does not own data");
    }
    cursor_ = begin(); 
    end_ = begin();
 }
开发者ID:jglaser,项目名称:simpatico,代码行数:14,代码来源:MemoryIArchive.cpp

示例11: UTIL_THROW

void OnDiskWrapper::BeginLoad(const std::string &filePath)
{
  if (!OpenForLoad(filePath)) {
    UTIL_THROW(util::FileOpenException, "Couldn't open for loading: " << filePath);
  }

  if (!m_vocab.Load(*this))
    UTIL_THROW(util::FileOpenException, "Couldn't load vocab");

  UINT64 rootFilePos = GetMisc("RootNodeOffset");
  m_rootSourceNode = new PhraseNode(rootFilePos, *this);
}
开发者ID:batman2013,项目名称:mosesdecoder,代码行数:12,代码来源:OnDiskWrapper.cpp

示例12: UTIL_THROW

 /*
 * Finalize receiving block, check consistency.
 */
 void Buffer::endRecvBlock()
 {
    if (recvSize_ != 0) {
       UTIL_THROW("Error: Recv counter != 0 at end of block");
    }
    if (recvPtr_ != recvBlockEnd_) {
       UTIL_THROW("Error: Inconsistent recv cursor at end of block");
    }
    recvBlockBegin_ = 0;
    recvBlockEnd_ = 0;
    recvSize_ = 0;
    recvType_ = NONE;
 }
开发者ID:pombredanne,项目名称:simpatico,代码行数:16,代码来源:Buffer.cpp

示例13: system

 /*
 * Clear accumulators.
 */
 void McMuExchange::setup()
 {
    nMolecule_ = system().nMolecule(speciesId_);
    if (nMolecule_ > accumulators_.capacity()) {
       UTIL_THROW("nMolecule > capacity");
    }
    if (nMolecule_ <= 0) {
       UTIL_THROW("nMolecule <= 0");
    }
    for (int iMol = 0; iMol < nMolecule_; ++iMol) {
       accumulators_[iMol].clear();
    }
 }
开发者ID:TaherGhasimakbari,项目名称:simpatico,代码行数:16,代码来源:McMuExchange.cpp

示例14: UTIL_THROW

 /*
 * Read saveInterval and saveFileName.
 */
 void Integrator::readParameters(std::istream& in)
 {
    read<int>(in, "saveInterval", saveInterval_);
    if (saveInterval_ > 0) {
       if (Analyzer::baseInterval > 0) {
          if (saveInterval_ % Analyzer::baseInterval != 0) {
             UTIL_THROW("saveInterval is not a multiple of baseInterval");
          }
       } else {
          UTIL_THROW("Analyzer::baseInterval is not positive");
       }
       read<std::string>(in, "saveFileName", saveFileName_);
    }
 }
开发者ID:medapuram,项目名称:simpatico,代码行数:17,代码来源:Integrator.cpp

示例15: UTIL_THROW

GlobalLexicalModelUnlimited::GlobalLexicalModelUnlimited(const std::string &line)
  :StatelessFeatureFunction(0, line)
{
  UTIL_THROW(util::Exception,
             "GlobalLexicalModelUnlimited hasn't been refactored for new feature function framework yet"); // TODO need to update arguments to key=value

  const vector<string> modelSpec = Tokenize(line);

  for (size_t i = 0; i < modelSpec.size(); i++ ) {
    bool ignorePunctuation = true, biasFeature = false, restricted = false;
    size_t context = 0;
    string filenameSource, filenameTarget;
    vector< string > factors;
    vector< string > spec = Tokenize(modelSpec[i]," ");

    // read optional punctuation and bias specifications
    if (spec.size() > 0) {
      if (spec.size() != 2 && spec.size() != 3 && spec.size() != 4 && spec.size() != 6) {
        std::cerr << "Format of glm feature is <factor-src>-<factor-tgt> [ignore-punct] [use-bias] "
                  <<  "[context-type] [filename-src filename-tgt]";
        //return false;
      }

      factors = Tokenize(spec[0],"-");
      if (spec.size() >= 2)
        ignorePunctuation = Scan<size_t>(spec[1]);
      if (spec.size() >= 3)
        biasFeature = Scan<size_t>(spec[2]);
      if (spec.size() >= 4)
        context = Scan<size_t>(spec[3]);
      if (spec.size() == 6) {
        filenameSource = spec[4];
        filenameTarget = spec[5];
        restricted = true;
      }
    } else
      factors = Tokenize(modelSpec[i],"-");

    if ( factors.size() != 2 ) {
      std::cerr << "Wrong factor definition for global lexical model unlimited: " << modelSpec[i];
      //return false;
    }

    const vector<FactorType> inputFactors = Tokenize<FactorType>(factors[0],",");
    const vector<FactorType> outputFactors = Tokenize<FactorType>(factors[1],",");
    throw runtime_error("GlobalLexicalModelUnlimited should be reimplemented as a stateful feature");
    GlobalLexicalModelUnlimited* glmu = NULL; // new GlobalLexicalModelUnlimited(inputFactors, outputFactors, biasFeature, ignorePunctuation, context);

    if (restricted) {
      cerr << "loading word translation word lists from " << filenameSource << " and " << filenameTarget << endl;
      if (!glmu->Load(filenameSource, filenameTarget)) {
        std::cerr << "Unable to load word lists for word translation feature from files "
                  << filenameSource
                  << " and "
                  << filenameTarget;
        //return false;
      }
    }
  }
}
开发者ID:NickRuiz,项目名称:mosesdecoder,代码行数:60,代码来源:GlobalLexicalModelUnlimited.cpp


注:本文中的UTIL_THROW函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。