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


C++ Species类代码示例

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


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

示例1: CheckPendingSpeciesTypes

void SpeciesManager::SetSpeciesHomeworlds(const std::map<std::string, std::set<int>>& species_homeworld_ids) {
    CheckPendingSpeciesTypes();
    ClearSpeciesHomeworlds();
    for (auto& entry : species_homeworld_ids) {
        const std::string& species_name = entry.first;
        const std::set<int>& homeworlds = entry.second;

        Species* species = nullptr;
        auto species_it = m_species.find(species_name);
        if (species_it != end())
            species = species_it->second.get();

        if (species) {
            species->SetHomeworlds(homeworlds);
        } else {
            ErrorLogger() << "SpeciesManager::SetSpeciesHomeworlds couldn't find a species with name " << species_name << " to assign homeworlds to";
        }
    }
}
开发者ID:adrianbroher,项目名称:freeorion,代码行数:19,代码来源:Species.cpp

示例2: save_molecular_type

    static void save_molecular_type(const MolecularTypeBase* mtb,
            std::vector<std::pair<ParticleID, Voxel> > voxels, H5::Group* group)
    {
        const Species species(mtb->species());
        boost::scoped_ptr<H5::Group> mtgroup(
                new H5::Group(group->createGroup(species.serial().c_str())));

        h5_species_struct property;
        property.radius = mtb->radius();
        property.D = mtb->D();
        const MolecularTypeBase* loc(mtb->location());
        if (loc->is_vacant())
            std::strcpy(property.location, "");
        else
            std::strcpy(property.location, loc->species().serial().c_str());
        property.is_structure = mtb->is_structure() ? 1 : 0;
        property.dimension = mtb->get_dimension();

        H5::CompType property_comp_type(get_property_comp());
        mtgroup->createAttribute("property", property_comp_type,
                H5::DataSpace(H5S_SCALAR)).write(property_comp_type, &property);

        // Save voxels
        const Integer num_voxels(voxels.size());
        std::size_t vidx(0);
        boost::scoped_array<h5_voxel_struct> h5_voxel_array(new h5_voxel_struct[num_voxels]);
        for (std::vector<std::pair<ParticleID, Voxel> >::const_iterator itr(voxels.begin());
                itr != voxels.end(); ++itr)
        {
            h5_voxel_array[vidx].lot = (*itr).first.lot();
            h5_voxel_array[vidx].serial = (*itr).first.serial();
            h5_voxel_array[vidx].coordinate = (*itr).second.coordinate();
            ++vidx;
        }

        H5::CompType voxel_comp_type(get_voxel_comp());
        hsize_t dims[] = {num_voxels};
        H5::DataSpace dspace(/* RANK= */1, dims);
        boost::scoped_ptr<H5::DataSet> dset(new H5::DataSet(
            mtgroup->createDataSet("voxels", voxel_comp_type, dspace)));
        dset->write(h5_voxel_array.get(), dset->getDataType());
    }
开发者ID:kozo2,项目名称:ecell4,代码行数:42,代码来源:LatticeSpaceHDF5Writer.hpp

示例3: updateAtomTypes

// Update AtomTypes definitions
void DUQ::updateAtomTypes()
{
	// Loop over Atoms in all Species - check AtomType availability and validity for each
	AtomType* at;
	for (Species* sp = species_.first(); sp != NULL; sp = sp->next)
	{
		for (SpeciesAtom* i = sp->atoms(); i != NULL; i = i->next)
		{
			// Is current AtomType definition valid?
			if (i->atomType() != NULL)
			{
				// Check it exists...
				if (!atomTypes_.contains(i->atomType())) i->setAtomType(NULL);
				else
				{
					// Check elements
					if (i->element() == i->atomType()->element()) continue;
					else i->setAtomType(NULL);
				}
			}
			
			// Either not valid, or nothing present.
			// Does an AtomType definition exist for this element?
			at = atomTypeForElement(i->element());
			if (!at)
			{
				// Create a suitable AtomType
				at = atomTypes_.add();
				at->setElement(i->element());
				at->setParameters(PeriodicTable::element(i->element()).parameters());
				at->setName(uniqueAtomTypeName(PeriodicTable::element(i->element()).symbol(), at));
			}
			i->setAtomType(at);
		}
	}
	
	// Step through AtomType definitions and make sure all have a valid set of Parameters
	for (AtomType* at = atomTypes_.first(); at != NULL; at = at->next)
	{
		if (!at->parameters()) at->setParameters(PeriodicTable::element(at->element()).parameters());
	}
}
开发者ID:trisyoungs,项目名称:duq,代码行数:43,代码来源:atomtypes.cpp

示例4: editSpecies

int Database::editSpecies(Species s)
{
    QVariant name = s.getName().toString().toLower();
    if(this->specieExist(name) > 0){
        this->showError(QMessageBox::tr("Esta espécie já existe"));
        return 0;
    }
    if(this->specieExist(name) <= 0){
        this->query.prepare("UPDATE Species SET name=? WHERE Species.id=?;");
        this->query.addBindValue(name);
        this->query.addBindValue(s.getId());
        if(!this->query.exec()){
            this->showError(this->query.lastError());
            return -1;
        }
        return 1;
    }
    QMessageBox::information(0, QMessageBox::tr("Erro"),QMessageBox::tr("Espécie não encontrada!"));
    return 0;
}
开发者ID:gavaza,项目名称:pacca,代码行数:20,代码来源:database.cpp

示例5: system

   /*
   * Initial setup.
   */
   void
   ClusterIdentifier::initialize(int speciesId, int atomTypeId, double cutoff)
   {
      // Set member variables
      speciesId_ = speciesId;
      atomTypeId_ = atomTypeId;
      cutoff_ = cutoff;

      // Allocate memory
      Species* speciesPtr = &system().simulation().species(speciesId);
      int moleculeCapacity = speciesPtr->capacity();
      links_.allocate(moleculeCapacity);
      clusters_.reserve(64);
      int atomCapacity = system().simulation().atomCapacity();
      cellList_.setAtomCapacity(atomCapacity);

      // Note: We must set the cellist atom capacity to the total atom capacity,
      // even though we are only interested in clusters of one species, because 
      // the celllist atom capacity sets the maximum allowed atom index value.
   }
开发者ID:dmorse,项目名称:simpatico,代码行数:23,代码来源:ClusterIdentifier.cpp

示例6: START_TEST

END_TEST



START_TEST ( test_Species_parent_add )
{
    Species *ia = new Species(2, 4);
    ia->setId("s");
    ia->setCompartment("c");
    Model *m = new Model(2, 4);

    m->addSpecies(ia);

    delete ia;

    ListOf *lo = m->getListOfSpecies();

    fail_unless(lo == m->getSpecies(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
开发者ID:alexholehouse,项目名称:SBMLIntegrator,代码行数:20,代码来源:TestSBMLParentObject.cpp

示例7: remove_species_attribute

void NetworkModel::remove_species_attribute(const Species& sp)
{
    species_container_type::iterator i(
        std::find(species_attributes_.begin(), species_attributes_.end(), sp));
    if (i == species_attributes_.end())
    {
        std::ostringstream message;
        message << "Speices [" << sp.serial() << "] not found";
        throw NotFound(message.str()); // use boost::format if it's allowed
    }
    species_attributes_.erase(i);
}
开发者ID:greatlse,项目名称:ecell4,代码行数:12,代码来源:NetworkModel.cpp

示例8: UTIL_THROW

   /*
   * Initialize all Angle objects for Molecules of one Species.
   *
   * This functions assigns pointers to Atoms and angle types ids within a
   * contiguous block of Angle objects, and sets a pointer in each Molecule
   * to the first Angle in the associated block.
   */
   void Simulation::initializeSpeciesAngles(int iSpecies)
   {

      if (nAngleType_ <= 0) {
         UTIL_THROW("nAngleType must be positive");
      }

      Species*  speciesPtr = 0;
      Molecule *moleculePtr = 0;
      Angle    *anglePtr = 0;
      Atom     *firstAtomPtr, *atom0Ptr, *atom1Ptr, *atom2Ptr;
      int       iMol, iAngle, atom0Id, atom1Id, atom2Id, type;
      int       capacity, nAngle;

      speciesPtr = &species(iSpecies);
      capacity   = speciesPtr->capacity();
      nAngle     = speciesPtr->nAngle();

      // Initialize pointers before loop
      moleculePtr = &molecules_[firstMoleculeIds_[iSpecies]];
      anglePtr = &angles_[firstAngleIds_[iSpecies]];

      // Loop over molecules in Species
      for (iMol = 0; iMol < capacity; ++iMol) {

         firstAtomPtr = &(moleculePtr->atom(0));
         moleculePtr->setFirstAngle(*anglePtr);
         moleculePtr->setNAngle(nAngle);

         if (nAngle > 0) {

            // Create angles for a molecule
            for (iAngle = 0; iAngle < nAngle; ++iAngle) {

               // Get pointers to atoms spanning the angle and angle type
               atom0Id  = speciesPtr->speciesAngle(iAngle).atomId(0);
               atom1Id  = speciesPtr->speciesAngle(iAngle).atomId(1);
               atom2Id  = speciesPtr->speciesAngle(iAngle).atomId(2);
               type     = speciesPtr->speciesAngle(iAngle).typeId();
               atom0Ptr = firstAtomPtr + atom0Id;
               atom1Ptr = firstAtomPtr + atom1Id;
               atom2Ptr = firstAtomPtr + atom2Id;

               // Set fields of the Angle object
               anglePtr->setAtom(0, *atom0Ptr);
               anglePtr->setAtom(1, *atom1Ptr);
               anglePtr->setAtom(2, *atom2Ptr);
               anglePtr->setTypeId(type);

               ++anglePtr;

            }

         }

         ++moleculePtr;
      }

   }
开发者ID:tdunn19,项目名称:simpatico,代码行数:66,代码来源:Simulation.cpp

示例9: UTIL_CHECK

   /*
   * Generate random molecules
   */
   bool Generator::generate(int nMolecule, 
                            const DArray<double>& diameters, 
                            CellList& cellList)
   {
      // Preconditions
      UTIL_CHECK(nMolecule <= species().capacity());
      UTIL_CHECK(cellList.atomCapacity() == simulation().atomCapacity());

      // Attempt to place all molecules in Species
      int speciesId = species().id();
      int maxAttempt = 200;
      int iAttempt;
      bool success;
      bool isMutable;
      Species* speciesPtr;
      for (int iMol = 0; iMol < nMolecule; ++iMol) {
         Molecule &newMolecule= simulation().getMolecule(speciesId);
         system().addMolecule(newMolecule);
         speciesPtr = &system().simulation().species(speciesId);
         isMutable = speciesPtr->isMutable();
         if (isMutable) {
           speciesPtr->mutator().setMoleculeState(newMolecule, 0);
         }
         success = false;
         iAttempt = 0;
         while (!success && iAttempt < maxAttempt) {
            success = attemptPlaceMolecule(newMolecule,
                                           diameters, cellList);
            ++iAttempt;
         }
         if (!success) {
            system().removeMolecule(newMolecule);
            Log::file() << "Failed to insert Linear molecule " 
                        << iMol << "\n";
            return false;
         }
      }
      return true;
   }
开发者ID:dmorse,项目名称:simpatico,代码行数:42,代码来源:Generator.cpp

示例10: loadParameters

   /* 
   * Load from archive.
   */
   void EndSwapMove::loadParameters(Serializable::IArchive& ar) 
   {
      McMove::loadParameters(ar);
      loadParameter<int>(ar, "speciesId", speciesId_);
      ar & atomTypeIds_;

      // Validate
      Species* speciesPtr = &(simulation().species(speciesId_));
      int nAtom = speciesPtr->nAtom();
      if (speciesPtr->isMutable()) {
         UTIL_THROW("EndSwapMove applied to mutable species");
      }
      Linear* linearPtr = dynamic_cast<Linear*>(speciesPtr);
      if (linearPtr == 0) {
         UTIL_THROW("EndSwapMove applied to species that is not Linear");
      }
      if (nAtom != atomTypeIds_.capacity()) {
         UTIL_THROW("Inconsistent capacity for atomTypeIds array");
      }
  
      positions_.allocate(nAtom);
   }
开发者ID:TaherGhasimakbari,项目名称:simpatico,代码行数:25,代码来源:EndSwapMove.cpp

示例11: START_TEST

END_TEST


START_TEST (test_RDFAnnotationMetaid_setAnnotation3)
{
  const char * rdfAnn =
    "<annotation>\n"
		"  <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
		"    <rdf:Description rdf:about=\"#_003\">\n"
    "      <dc:creator>\n"
		"        <rdf:Bag>\n"
		"          <rdf:li rdf:parseType=\"Resource\">\n"
    "            <vCard:N rdf:parseType=\"Resource\">\n"
		"              <vCard:Family>Le Novere</vCard:Family>\n"
		"              <vCard:Given>Nicolas</vCard:Given>\n"
		"            </vCard:N>\n"
		"            <vCard:EMAIL>[email protected]</vCard:EMAIL>\n"
		"            <vCard:ORG rdf:parseType=\"Resource\">\n"
		"              <vCard:Orgname>EMBL-EBI</vCard:Orgname>\n"
		"            </vCard:ORG>\n"
		"          </rdf:li>\n"
		"        </rdf:Bag>\n"
		"      </dc:creator>\n"
		"      <dcterms:created rdf:parseType=\"Resource\">\n"
		"        <dcterms:W3CDTF>2005-02-02T14:56:11Z</dcterms:W3CDTF>\n"
		"      </dcterms:created>\n"
		"      <dcterms:modified rdf:parseType=\"Resource\">\n"
		"        <dcterms:W3CDTF>2006-05-30T10:46:02Z</dcterms:W3CDTF>\n"
		"      </dcterms:modified>\n"
		"      <bqbiol:is>\n"
		"        <rdf:Bag>\n"
		"          <rdf:li rdf:resource=\"http://www.geneontology.org/#GO:0007274\"/>\n"
		"        </rdf:Bag>\n"
		"      </bqbiol:is>\n"
		"    </rdf:Description>\n"
		"  </rdf:RDF>\n"
    "</annotation>";


  Species *s = m->getSpecies(0);
  fail_unless(s->setAnnotation(rdfAnn) == LIBSBML_UNEXPECTED_ATTRIBUTE);

  fail_unless(s->getAnnotation() == NULL);

  s->setMetaId("_003");
  fail_unless(s->setAnnotation(rdfAnn) == LIBSBML_OPERATION_SUCCESS);

  fail_unless(s->getAnnotation() != NULL);

  fail_unless( equals(rdfAnn, s->getAnnotation()->toXMLString().c_str()));


}
开发者ID:kirichoi,项目名称:roadrunner,代码行数:53,代码来源:TestRDFAnnotationMetaid.cpp

示例12: initializeSpeciesDihedrals

   /*
   * Initialize all Dihedral objects for Molecules of one Species.
   *
   * This functions assigns pointers to Atoms and Dihedral types ids within
   * a contiguous block of Dihedral objects, and sets a pointer in each 
   * Molecule to the first Dihedral in the associated block.
   */
   void Simulation::initializeSpeciesDihedrals(int iSpecies)
   {

      Species*  speciesPtr = 0;
      Molecule *moleculePtr = 0;
      Dihedral  *dihedralPtr = 0;
      Atom     *firstAtomPtr, *atom0Ptr, *atom1Ptr, *atom2Ptr, *atom3Ptr;
      int       iMol, iDihedral, atom0Id, atom1Id, atom2Id, atom3Id, type;
      int       capacity, nDihedral;

      speciesPtr = &species(iSpecies);
      capacity   = speciesPtr->capacity();
      nDihedral  = speciesPtr->nDihedral();

      // Initialize pointers before loop
      moleculePtr = &molecules_[firstMoleculeIds_[iSpecies]];
      dihedralPtr = &dihedrals_[firstDihedralIds_[iSpecies]];

      // Loop over molecules in Species
      for (iMol = 0; iMol < capacity; ++iMol) {

         firstAtomPtr = &(moleculePtr->atom(0));
         moleculePtr->setFirstDihedral(*dihedralPtr);
         moleculePtr->setNDihedral(nDihedral);

         if (nDihedral > 0) {

            // Create dihedrals for a molecule
            for (iDihedral = 0; iDihedral < nDihedral; ++iDihedral) {

               // Get local indices for atoms and dihedral type
               atom0Id  = speciesPtr->speciesDihedral(iDihedral).atomId(0);
               atom1Id  = speciesPtr->speciesDihedral(iDihedral).atomId(1);
               atom2Id  = speciesPtr->speciesDihedral(iDihedral).atomId(2);
               atom3Id  = speciesPtr->speciesDihedral(iDihedral).atomId(3);
               type     = speciesPtr->speciesDihedral(iDihedral).typeId();

               // Calculate atom pointers
               atom0Ptr = firstAtomPtr + atom0Id;
               atom1Ptr = firstAtomPtr + atom1Id;
               atom2Ptr = firstAtomPtr + atom2Id;
               atom3Ptr = firstAtomPtr + atom3Id;

               // Set fields of the Dihedral object
               dihedralPtr->setAtom(0, *atom0Ptr);
               dihedralPtr->setAtom(1, *atom1Ptr);
               dihedralPtr->setAtom(2, *atom2Ptr);
               dihedralPtr->setAtom(3, *atom3Ptr);
               dihedralPtr->setTypeId(type);

               ++dihedralPtr;
            }
         }
         ++moleculePtr;
      }

   }
开发者ID:tdunn19,项目名称:simpatico,代码行数:64,代码来源:Simulation.cpp

示例13: while

std::string SEDMLUtils::findIdByNameAndType(
  const std::map<CCopasiObject*, SBase*>& map,
  int typeCode,
  const std::string& name)
{
  std::map<CCopasiObject*, SBase*>::const_iterator it = map.begin();

  std::string::size_type compartmentStart = name.find("{");
  std::string nameOnly = name.substr(0, compartmentStart);

  while (it != map.end())
    {
      SBase* current = it->second;

      if (((current->getTypeCode() & typeCode) == typeCode) &&
          current->getName() == name)
        return current->getId();

      if (typeCode == SBML_SPECIES  && compartmentStart != std::string::npos)
        {
          if (((current->getTypeCode() & typeCode) == typeCode) &&
              current->getName() == nameOnly)
            {
              std::string compName = name.substr(compartmentStart + 1, name.size() - compartmentStart  - 2);
              std::string compId = findIdByNameAndType(map, SBML_COMPARTMENT, compName);
              Species* species = (Species*) current;

              if (species->getCompartment() == compId)
                return species->getId();
            }
        }

      ++it;
    }

  return "";
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:37,代码来源:SEDMLUtils.cpp

示例14: Species

int Database::insertSpecie(Species s)
{
    QVariant name = s.getName().toString().toLower();
    if(!this->specieExist(name)){
        this->query.prepare("INSERT INTO Species (name) VALUES (:name);");
        this->query.bindValue(":name",name);
        if(!this->query.exec()){
            this->showError(this->query.lastError());
            return -1;
        }
        return this->query.lastInsertId().toInt();
    }
    this->showError(QMessageBox::tr("Essa espécie já existe!"));
    return 0;
}
开发者ID:gavaza,项目名称:pacca,代码行数:15,代码来源:database.cpp

示例15: i

std::vector<ReactionRule> NetworkModel::query_reaction_rules(
    const Species& sp) const
{
    first_order_reaction_rules_map_type::const_iterator
        i(first_order_reaction_rules_map_.find(sp.serial()));

    std::vector<ReactionRule> retval;
    if (i != first_order_reaction_rules_map_.end())
    {
        retval.reserve((*i).second.size());
        for (first_order_reaction_rules_map_type::mapped_type::const_iterator
                 j((*i).second.begin()); j != (*i).second.end(); ++j)
        {
            retval.push_back(reaction_rules_[*j]);
        }
    }
    return retval;
}
开发者ID:greatlse,项目名称:ecell4,代码行数:18,代码来源:NetworkModel.cpp


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