bool TrafficLights::State::operator==(const State &etat) const
{
  if (nom() == etat.nom())
    return true;
  else
    return false;
}
bool
AGActivities::generateInOutTraffic() {
    /**
     * outgoing traffic already done by generateTrips():
     * people who work out of the city.
     * Here are people from outside the city coming to work.
     */
    if (myCity->peopleIncoming.empty()) {
        return true;
    }
    if (myCity->cityGates.empty()) {
        return false;
    }
    int num = 1;
    std::list<AGAdult>::iterator itA;

    for (itA = myCity->peopleIncoming.begin(); itA != myCity->peopleIncoming.end(); ++itA) {
        int posi = myCity->statData.getRandomCityGateByIncoming();
        std::string nom(generateName(num, "carIn"));
        AGTrip wayTrip(myCity->cityGates[posi], itA->getWorkPosition().getPosition(), nom, itA->getWorkPosition().getOpening());
        //now we put the estimated time of entrance in the city.
        wayTrip.setDepTime(wayTrip.estimateDepTime(wayTrip.getTime(), myCity->statData.speedTimePerKm));
        AGTrip retTrip(itA->getWorkPosition().getPosition(), myCity->cityGates[posi], nom, itA->getWorkPosition().getClosing());
        trips.push_back(wayTrip);
        trips.push_back(retTrip);
        ++num;
    }
    return true;
}
 BaseTemplate TypeTemplate::TemplateDeBase() const
 {
 
   Chaine nom(this->classeTemplate->Name()->ToString()) ;
   
   rDebug(nom) ;
   
   if (nom == Chaine("Association"))
     return Compilateur::Association ;
   else if (nom == Chaine("Composition"))
     return Compilateur::Composition ;
   else if (nom == Chaine("EnsembleComposition"))
     return Compilateur::EnsembleComposition ;
   else if (nom == Chaine("EnsembleAssociation"))
     return Compilateur::EnsembleAssociation ;
   else if (nom == Chaine("FonctionObjetValeur"))
     return Compilateur::FonctionObjetValeur ;
   else if (nom == Chaine("FonctionCompositionObjetObjet"))
     return Compilateur::FonctionCompositionObjetObjet ;
   else if (nom == Chaine("FonctionAssociationObjetObjet"))
     return Compilateur::FonctionAssociationObjetObjet ;
   else if (nom == Chaine("FonctionCompositionValeurObjet"))
     return Compilateur::FonctionCompositionValeurObjet ;
   else if (nom == Chaine("FonctionAssociationValeurObjet"))
     return Compilateur::FonctionAssociationValeurObjet ;
   
   else
     return Compilateur::NonPrisEnCompte ;
 }
bool Signalisation::Etat::operator==(const Etat &etat) const
{
  if (nom() == etat.nom())
    return true;
  else
    return false;
}
예제 #5
0
void Livre::sauvegarde(QXmlStreamWriter & stream)
{
    stream.writeStartElement ("media");
    stream.writeTextElement ("nom", nom ());
    if(!cycle ().isEmpty ())
    {
        stream.writeStartElement ("cycle");
        stream.writeAttribute ("tome", QString::number (numeroTome ()));
        stream.writeCharacters (cycle());
        stream.writeEndElement ();
    }
    stream.writeTextElement ("editeur", editeur ());
    stream.writeTextElement ("sortie", date ().toString ());

    if(!url ().isEmpty ())
    {
        stream.writeTextElement ("url", url ().toString ());
    }

    stream.writeTextElement ("genre", genre ());
    stream.writeTextElement ("lu", QString::number (isFini ()));

    foreach(QString atlas, auteur ())
    {
        stream.writeTextElement ("auteur", atlas);
    }
예제 #6
0
파일: xfload.cpp 프로젝트: dkearns/icon
//cs  new makefunc that allocates a proc_block
static int newmakefunc(dptr d, char *name, int (*func)(), int arity) {
	value nom(NewString,name);
	proc_block* pbp;
	if( arity < 0 ) pbp = new proc_block(nom, (iconfvbl*)func);
			else pbp = new proc_block(nom, (iconfunc*)func, arity);
	if( pbp==0 ) return 0;
	d->dword = D_Proc;
	d->vword.bptr = (union block *)pbp;	
	return 1;
}
예제 #7
0
void Film::sauvegarde(QXmlStreamWriter & stream)
{
    qDebug()<<"Sauvegade de "<<nom();
    stream.writeStartElement("media");
    stream.writeTextElement("nom", nom());
    stream.writeTextElement("genre", genre());
    stream.writeTextElement("date", date().toString("d/M/yyyy"));
    stream.writeTextElement("vue", QString::number(isFini()));
    stream.writeTextElement("url", url().toString());
    stream.writeTextElement("type", getType());
    stream.writeTextElement("realisateur", getRealisateur());
    stream.writeTextElement("scenariste", getScenariste());
    stream.writeTextElement("support", QString::number(getSupport()));
    stream.writeTextElement("duree", getDuree().toString());

    foreach(QString jupiter, getActeursPrincipaux())
    {
        stream.writeTextElement("acteur", jupiter);
    }
예제 #8
0
파일: iir_coeff.cpp 프로젝트: xloem/pothos
// Get frequency response at freq
float_type iir_coeff::freqz_mag(float_type freq) {
  int i;
  std::complex<float_type> z(1, 0);
  std::complex<float_type> z_inc = std::complex<float_type>(std::cos(freq), std::sin(freq));
  std::complex<float_type> nom(0);
  std::complex<float_type> den(0);
  for (i = 0; i < order + 1; i++) {
    nom += z * b_tf[i];
    den += z * a_tf[i];
    z *= z_inc;
  }
  return std::sqrt(std::norm(nom / den));
}
예제 #9
0
void BandeDessine::sauvegarde(QXmlStreamWriter & stream)
{
    stream.writeStartElement("media");
    stream.writeTextElement("nom", nom());
    stream.writeTextElement("date", date().toString());
    stream.writeTextElement("genre", genre());
    stream.writeTextElement("url", url().toString());
    stream.writeTextElement("fini", QString::number(isFini()));

    stream.writeTextElement("lu", QString::number(isLu()));
    stream.writeTextElement("encoursachat", QString::number(isEnCoursAchat()));

    foreach(QString artemis, getAuteur())
    {
        stream.writeTextElement("auteur", artemis);
    }
예제 #10
0
/**
 * \brief Permet à un joueur de rejoindre un salon
 * \param indice L'indice du salon dans la liste
 * \param socket La socket du joueur qui veut rejoindre le salon
 * \return l'indice du joueur ou -1 si échec
 */
int GestionnaireSalon::rejoindreSalon(SocketTcp * socket, 
	unsigned char indice, unsigned char requete[MAX_TCP_MTU]) {

	// correspondance entre l'indice client et serveur
	indice = (unsigned char)getIndiceSalonDisponible((int)indice);

	char * nomJoueur = NULL;

	if(requete[0] == 0x1) {
		nomJoueur = (char *)&requete[1];
	}
	else if(requete[0] == 0x2) {
		nomJoueur = (char *)&requete[2];
	}
	else{
		return -1;
	}

	std::string nom(nomJoueur);

	std::cout << "SIZE = " << listeSalon.size() << std::endl;

	if((unsigned int)indice >= listeSalon.size()) {
		afficheur->afficher("erro", "L'indice du salon est trop grand");
		return -1;
	}

	if(listeSalon[(unsigned int)indice] != nullptr) {
		std::cout << "Gestionnaire salon socket address : " << socket << std::endl;
		if(!listeSalon[(unsigned int)indice]->ajouterJoueur(socket, nom))
		{
			afficheur->afficher("erro", "Impossible de rejoindre le salon");
			return -1;
		}
		else
		{
			return indice;
		}
	}
	else {
		afficheur->afficher("erro", "Le salon est introuvable");
		return -1;
	}
}
예제 #11
0
bool CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate)
{
    CBotToken   token(name, CBotString());
    CBotClass*  pClass = type.GetClass();

    CBotVar*    pVar = CBotVar::Create( name, type );
/// pVar->SetUniqNum(CBotVar::NextUniqNum());
    pVar->SetPrivate( mPrivate );

    if ( pClass != NULL )
    {
//      pVar->SetClass(pClass);
        if ( type.Eq(CBotTypClass) )
        {
            // adds a new statement for the object initialization
            pVar->m_InitExpr = new CBotNew() ;
            CBotToken nom( pClass->GetName() );
            pVar->m_InitExpr->SetToken(&nom);
        }
    }
    return AddItem( pVar );
}
예제 #12
0
QString Client::out() const
{
    return prenom() + " " + nom();
}
예제 #13
0
void Film::chargement(QDomElement & element)
{
    QDomNodeList pluton = element.elementsByTagName("nom");
    if(pluton.size() > 0)
    {
        setNom(pluton.at(0).toElement().text());
    }
    else
    {
        throw QString("Il manque le nom");
    }

    pluton = element.elementsByTagName("genre");

    if(pluton.size() > 0)
    {
        setGenre(pluton.at(0).toElement().text());
    }
    else
    {
        throw QString("Il manque le genre");
    }

    pluton = element.elementsByTagName("date");

    if(pluton.size() > 0)
    {
        setDate(QDate::fromString(pluton.at(0).toElement().text(), "d/M/yyyy"));
    }
    else
    {
        throw QString("Il manque la date");
    }

    pluton = element.elementsByTagName("vue");
    if(pluton.size() > 0)
    {
        setFini(pluton.at(0).toElement().text().toInt());
    }
    else
    {
        throw QString("Il manque fini");
    }

    pluton = element.elementsByTagName("url");
    if(pluton.size() > 0)
    {
        setUrl(QUrl(pluton.at(0).toElement().text()));
    }
    else
    {
        throw QString("Il manque l'url");
    }

    pluton = element.elementsByTagName("realisateur");

    if(pluton.size() > 0)
    {
        setRealisateur(pluton.at(0).toElement().text());
    }
    else
    {
        throw QString("Il manque le réalisateur");
    }

    pluton = element.elementsByTagName("scenariste");

    if(pluton.size() > 0)
    {
        setScenariste(pluton.at(0).toElement().text());
    }
    else
    {
        throw QString("Il manque le scenariste");
    }

    pluton = element.elementsByTagName("support");
    if(pluton.size() > 0)
    {
        setSupport((Film::Support)pluton.at(0).toElement().text().toInt());
    }
    else
    {
        throw QString("Il manque le support");
    }

    pluton = element.elementsByTagName("duree");

    if(pluton.size() > 0)
    {
        setDuree(QTime::fromString(pluton.at(0).toElement().text()));
    }
    else
    {
        throw QString("Il manque la durée");
    }

    pluton = element.elementsByTagName("acteur");

    for(int terra = 0; terra < pluton.size(); terra ++)
    {
        addActeur(pluton.at(terra).toElement().text());
    }

    pluton = element.elementsByTagName("type");

    if(pluton.size() > 0)
    {
        setType(pluton.at(0).toElement().text());
    }
    qDebug()<<"Chargement "<<nom()<<"ok";

}
// Description: read the specified geometry from the lataDB_ structure and put it in "dom".
//  load_faces: flag, tells if we should read faces definitions in the lata file
//  merge_virtual_elements: flag, if a "VIRTUAL_ELEMENTS" array is present in the lata file,
//   merges these elements to the requested block.
void DomainUnstructured::fill_domain_from_lataDB(const LataDB & lataDB,
                                                 const Domain_Id & id,
                                                 entier load_faces, 
                                                 entier merge_virtual_elements) 
{
  operator=(DomainUnstructured()); // Reset all data.

  id_ = id;
  const LataDBGeometry & geom = lataDB.get_geometry(id.timestep_, id.name_);

  // ********************************
  // 1) Look for the sub-block items to read (parallel computation)
  entier decal_nodes = 0;
  entier decal_elements = 0;
  entier decal_faces = 0;
  entier nb_sommets = -1;
  entier nb_elements = -1;
  entier nb_faces = -1;

  entier domain_has_faces = load_faces && lataDB.field_exists(id.timestep_, id.name_, "FACES");
  
  // Tableau de 3 joints (SOM, ELEM et FACES)
  LataVector<IntTab> joints;
  entier nproc = 1;
  for (entier i_item = 0; i_item < 3; i_item++) {
    LataField_base::Elem_som loc = LataField_base::SOM; (void) loc;
    Nom nom("JOINTS_SOMMETS");
    Nom nom2("SOMMETS");
    if (i_item == 1) {
      loc = LataField_base::ELEM;
      nom = "JOINTS_ELEMENTS";
      nom2 = "ELEMENTS";
    } else if (i_item == 2) {
      loc = LataField_base::FACES;
      nom = "JOINTS_FACES";
      nom2 = "FACES";
    }

    IntTab & joint = joints.add();
    if (lataDB.field_exists(id.timestep_, id.name_, nom)) {
      entier nb_items = lataDB.get_field(id.timestep_, id.name_, nom2, "*").size_;
      IntTab tmp;
      lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, nom, "*"), tmp);
      nproc = tmp.dimension(0);
      // Recalcule la deuxieme colonne en fonction de la premiere
      joint.resize(nproc, 2);
      for (entier i = 0; i < nproc; i++) {
        joint(i, 0) = tmp(i, 0);
        if (i < nproc-1)
          joint(i, 1) = tmp(i+1, 0) - tmp(i, 0);
        else 
          joint(i, 1) = nb_items - tmp(i, 0);
      }
    } 
  }

  if (id_.block_ < 0 || nproc == 1) {
    // read all blocks at once default values are ok
    set_joints(LataField_base::SOM) = joints[0];
    set_joints(LataField_base::ELEM) = joints[1];
    set_joints(LataField_base::FACES) = joints[2];
  } else {
    if (id_.block_ >= nproc) {
      Journal() << "LataFilter::get_geometry : request non existant block " << id.block_ 
                << " in geometry " << id.name_ << endl;
      throw;
    }
    const entier n = id_.block_;
    decal_nodes = joints[0](n, 0);
    nb_sommets = joints[0](n, 1);
    decal_elements = joints[1](n, 0);
    nb_elements = joints[1](n, 1);
    if (domain_has_faces) {
      decal_faces = joints[2](n, 0);
      nb_faces = joints[2](n, 1);
    }
  }

  // ******************************
  // 2) Read nodes, elements and faces data
  elt_type_ = Domain::element_type_from_string(geom.elem_type_);

  lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, "SOMMETS", "*"), nodes_, decal_nodes, nb_sommets);
  lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, "ELEMENTS", "*"), elements_, decal_elements, nb_elements);
  set_lata_block_offset(LataField_base::SOM, decal_nodes);
  set_lata_block_offset(LataField_base::ELEM, decal_elements);
  if (decal_nodes > 0) {
    // Nodes are stored with global numbering in the lata file: transform to sub_block numbering :
    elements_ -= decal_nodes;
  }
  if (domain_has_faces) {
    set_lata_block_offset(LataField_base::FACES, decal_faces);
    lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, "FACES", "*"), faces_, decal_faces, nb_faces);
    if (decal_nodes > 0)
      faces_ -= decal_nodes;
    lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, "ELEM_FACES", "*"), elem_faces_, decal_elements, nb_elements);
    if (decal_faces > 0)
      elem_faces_ -= decal_faces;
  }

  // *************************
  // 3) Merge virtual elements if requested
  if (merge_virtual_elements && lataDB.field_exists(id.timestep_, id.name_, "VIRTUAL_ELEMENTS") && id.block_ >= 0) 
    {
      Journal(info_level) << " Merging virtual elements" << endl;
      // joints_virt_elems(sub_block, 0) = index of first virtual element in the VIRTUAL_ELEMENTS array
      IntTab joints_virt_elems;
      // Load the virtual elements (nodes are in global numbering)
      //  First: find the index and number of virtual elements for block number id.block_:
      lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, "JOINTS_VIRTUAL_ELEMENTS", "*"), joints_virt_elems);
      entier nb_virt_elems;
      if (id.block_ < nproc-1)
        nb_virt_elems = joints_virt_elems(id.block_+1, 0) - joints_virt_elems(id.block_, 0);
      else
        nb_virt_elems = lataDB.get_field(id.timestep_, id.name_, "VIRTUAL_ELEMENTS", "*").size_ - joints_virt_elems(id.block_, 0);
      Journal(info_level+1) << " Number of virtual elements for block " << id.block_ << "=" << nb_virt_elems << endl;
      //  Second: load the indexes of the virtual elements to load:
      IntTab virt_elems;
      lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, "VIRTUAL_ELEMENTS", "*"), virt_elems, joints_virt_elems(id.block_,0), nb_virt_elems);
      set_virt_items(LataField_base::ELEM, virt_elems);

      {
        //  Third: load the virtual elements (virt_elems contains the global indexes of the elements to
        //  load and virt_elem_som will contain global nodes indexes of the virtual elements)
        IntTab virt_elem_som;
        lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, "ELEMENTS", "*"), virt_elem_som, virt_elems);
        // Find which virtual nodes are required and load them: virtual nodes to load are
        // all nodes of the virtual elements (they have duplicates).
        ArrOfInt index;
        ArrOfInt & virt_elem_som_array = virt_elem_som; // Array seen as monodimensionnal
        array_sort_indirect(virt_elem_som_array, index);
        // Global nodes indexes of needed virtual nodes 
        ArrOfInt nodes_to_read;
        nodes_to_read.set_smart_resize(1);
        {
          const entier n = index.size_array();
          // Global index of the last loaded node:
          entier last_node = -1;
          // Local index of the new loaded node:
          entier new_node_index = nodes_.dimension(0)-1;
          for (entier i = 0; i < n; i++) {
            // Take nodes to load in ascending order of their global numbers:
            const entier idx = index[i];
            const entier node = virt_elem_som_array[idx];
            if (node != last_node) {
              // Node not yet encountered
              nodes_to_read.append_array(node);
              new_node_index++;
              last_node = node;
            }
            virt_elem_som_array[idx] = new_node_index;
          }
        }
        set_virt_items(LataField_base::SOM, nodes_to_read);
        // Copy virtual elements to elements_
        entier debut = elements_.size_array();
        elements_.resize(elements_.dimension(0) + virt_elem_som.dimension(0),
                         elements_.dimension(1));
        elements_.inject_array(virt_elem_som, virt_elem_som.size_array(), debut);
        // Load virtual nodes
        FloatTab tmp_nodes;
        lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, "SOMMETS", "*"), tmp_nodes, nodes_to_read);
        // Copy to nodes_
        debut = nodes_.size_array();
        nodes_.resize(nodes_.dimension(0) + tmp_nodes.dimension(0),
                      nodes_.dimension(1));
        nodes_.inject_array(tmp_nodes, tmp_nodes.size_array(), debut);
      }

      if (domain_has_faces) {
        // Find which virtual faces are required and load them
        // For each virtual element, index of its faces (like virt_elem_som)
        IntTab virt_elem_faces; 
        lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, "ELEM_FACES", "*"), virt_elem_faces, virt_elems);
        // Build the list of missing faces:
        ArrOfInt index;
        ArrOfInt & virt_elem_faces_array = virt_elem_faces; // Array seen as monodimensionnal
        array_sort_indirect(virt_elem_faces_array, index);
        ArrOfInt faces_to_read;
        faces_to_read.set_smart_resize(1);
        {
          const entier n = index.size_array();
          // Global index of the last loaded face:
          entier last_face = -1;
          // Local index of the new loaded node:
          entier new_face_index = faces_.dimension(0)-1;
          for (entier i = 0; i < n; i++) {
            // Take nodes to load in ascending order of their global numbers:
            const entier idx = index[i];
            const entier face = virt_elem_faces_array[idx];
            if (face != last_face) {
              // Node not yet encountered
              faces_to_read.append_array(face);
              new_face_index++;
              last_face = face;
            }
            virt_elem_faces_array[idx] = new_face_index;
          }
        }
        set_virt_items(LataField_base::FACES, faces_to_read);
        // Copy virtual elem_faces to elem_faces
        entier debut = elem_faces_.size_array();
        elem_faces_.resize(elem_faces_.dimension(0) + virt_elem_faces.dimension(0),
                           elem_faces_.dimension(1));
        elem_faces_.inject_array(virt_elem_faces, virt_elem_faces.size_array(), debut);

        // Load virtual faces
        IntTab tmp_faces_nodes;
        lataDB.read_data(lataDB.get_field(id.timestep_, id.name_, "FACES", "*"), tmp_faces_nodes, faces_to_read);
        // Convert global nodes indexes to local loaded nodes indexes in tmp_faces_nodes
        {
          // sort tmp_faces in ascending order so that the search requires linear time
          ArrOfInt & array_tmp_faces_nodes = tmp_faces_nodes;
          index.reset();
          array_sort_indirect(array_tmp_faces_nodes, index);
          const entier n = array_tmp_faces_nodes.size_array();
          // Take nodes in tmp_faces_nodes in ascending order and find the corresponding node in nodes_to_read
          // (which is also in sorted)
          entier i1; // index in array_tmp_faces_nodes (the current node to convert)
          entier i2 = 0; // index in nodes_to_read
          const entier index_of_first_virtual_node = nodes_.dimension(0) - nb_virt_items(LataField_base::SOM);
          const ArrOfInt & nodes_to_read = get_virt_items(LataField_base::SOM);
          const entier max_i2 = nodes_to_read.size_array();
          for (i1 = 0; i1 < n; i1++) {
            const entier j = index[i1];
            const entier global_node_index_to_find = array_tmp_faces_nodes[j];
            // find the matching node in nodes_to_read (nodes_to_read is in ascending order)
            while (nodes_to_read[i2] != global_node_index_to_find) {
              i2++;
              if (i2 >= max_i2) {
                cerr << "Internal error in DomainUnstructured::fill_domain_from_lataDB:\n"
                     << " node " << global_node_index_to_find << " of a virtual face does not belong to a virtual element" << endl;
//                exit(-1);
              }
            }
            array_tmp_faces_nodes[j] = index_of_first_virtual_node + i2; // index of this node in the local nodes_ array
          }
        }
        // Copy to faces_ array
        debut = faces_.size_array();
        faces_.resize(faces_.dimension(0) + tmp_faces_nodes.dimension(0),
                      faces_.dimension(1));
        faces_.inject_array(tmp_faces_nodes, tmp_faces_nodes.size_array(), debut);
      }
    }
}