Exemplo n.º 1
0
void		ModuleSDL::display(map_t const & map)
{
  uint		x, y;
  int		r;

  y = 0;
  r = SDL_FillRect(this->s_ecran, NULL, SDL_MapRGB(this->s_ecran->format, 0, 0, 0));
  if (r == -1)
    throw Exception(SDL_GetError());
  for (std::vector<std::vector<slot_t> >::const_iterator it_y = map.begin(); it_y != map.end(); ++it_y)
    {
      x = 0;
      for (std::vector<slot_t>::const_iterator it_x = (*it_y).begin(); it_x != (*it_y).end(); ++it_x)
	{
	  display_slot(x, y, (*it_x));
	  ++x;
	}
      ++y;
    }
  r = SDL_Flip(this->s_ecran);
  if (r == -1)
    throw Exception(SDL_GetError());
}
Exemplo n.º 2
0
void		ModuleOpenGL::display(map_t const & map)
{
    uint		x;
    uint		y = 0;

    glClear(GL_COLOR_BUFFER_BIT);
    glViewport(0, 0, this->width, this->height);
    xglBegin(GL_QUADS);
    glColor3ub(51, 51, 51);
    glVertex2d(-1,-1);
    glVertex2d(-1,1);
    glColor3ub(30, 30, 30);
    glVertex2d(1,1);
    glVertex2d(1,-1);
    xglEnd();
    for (std::vector<std::vector<slot_t> >::const_iterator it_y = map.begin(); it_y != map.end(); ++it_y)
    {
        x = 0;
        for (std::vector<slot_t>::const_iterator it_x = (*it_y).begin(); it_x != (*it_y).end(); ++it_x)
        {
            display_slot(x, y, (*it_x));
            ++x;
        }
        ++y;
    }
    xglFlush();
    SDL_GL_SwapBuffers();
}
Exemplo n.º 3
0
 const_iterator end() const noexcept { return map_index_n.end(); }
Exemplo n.º 4
0
		bool set_fields_if_equals(doid_t do_id, const map_t &equals, map_t &values)
		{
			m_log->trace() << "Setting fields if equals on obj-" << do_id << endl;

			YAML::Node document;
			if(!load(do_id, document))
			{
				values.clear();
				return false;
			}

			// Get current field values from the file
			const Class* dcc = g_dcf->get_class_by_name(document["class"].as<string>());
			ObjectData dbo(dcc->get_id());
			YAML::Node existing = document["fields"];
			for(auto it = existing.begin(); it != existing.end(); ++it)
			{
				const Field* field = dcc->get_field_by_name(it->first.as<string>());
				if(!field)
				{
					m_log->warning() << "Field '" << it->first.as<string>()
					                 << "', loaded from '" << filename(do_id)
					                 << "', does not exist." << endl;
					continue;
				}
				vector<uint8_t> value = read_yaml_field(field, it->second, do_id);
				if(value.size() > 0)
				{
					dbo.fields[field] = value;
				}
			}

			// Check if equals matches current values
			bool fail = false;
			for(auto it = equals.begin(); it != equals.end(); ++it)
			{
				auto found = dbo.fields.find(it->first);
				if(found == dbo.fields.end())
				{
					values.erase(it->first);
					fail = true;
				}
				else if(it->second != found->second)
				{
					values.erase(it->first);
					fail = true;
				}
			}

			// Return current values on failure
			if(fail)
			{
				for(auto it = values.begin(); it != values.end(); ++it)
				{
					it->second = dbo.fields[it->first];
				}
				return false;
			}

			// Update existing values on success
			for(auto it = values.begin(); it != values.end(); ++it)
			{
				dbo.fields[it->first] = it->second;
			}
			write_yaml_object(do_id, dcc, dbo);
			return true;
		}
Exemplo n.º 5
0
 bool has_key(std::string const & key) const { return object_map.find(key) != object_map.end();}
Exemplo n.º 6
0
 ///parameters class-like element access
 _object const & operator[](std::string const & key) const {
  auto it = object_map.find(key);
  if ( it== object_map.end()) TRIQS_RUNTIME_ERROR<<"Key : "<< key<< " not found";
  return it->second;
 }
Exemplo n.º 7
0
 iterator end() { return object_map.end();}
Exemplo n.º 8
0
 const_iterator end()  const { return object_map.end();}
Exemplo n.º 9
0
 // end
 typename map_t::const_iterator end() const {
   return map->end();
 }
Exemplo n.º 10
0
 void write()
 {
     static comma::csv::output_stream< interval_t< From, To > > ostream( std::cout, ocsv );
     static comma::csv::ascii< from_t< std::string > > from_ascii( ascii_csv );
     static comma::csv::ascii< to_t< std::string > > to_ascii( ascii_csv );
     for( typename map_t::iterator it = map.begin(); it != map.end(); ++it )
     {
         bound_t< bound_type > from = it->first.lower();
         bound_t< bound_type > to = it->first.upper();
         interval_t< From, To > interval;
         bool from_has_value = true;
         bool to_has_value = true;
         if( from.value ) { interval.from.value = *from.value; }
         else if( use_limits ) { interval.from.value = limits< From >::lowest(); }
         else if( empty ) { interval.from.value = static_cast< From >( *empty ); }
         else { from_has_value = false; }
         if( to.value ) { interval.to.value = *to.value; }
         else if( use_limits ) { interval.to.value = limits< To >::max(); }
         else if( empty ) { interval.to.value = static_cast< To >( *empty ); }
         else { to_has_value = false; }
         const set_t& s = it->second;
         if( s.size() < min_overlap_count || s.size() > max_overlap_count ) { continue; }
         if( append )
         {
             if( csv.binary() )
             {
                 for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v )
                 { 
                     std::cout.write( &( *v )[0], v->size() );
                     ostream.write( interval );
                 }
                 ostream.flush(); // todo: use csv.flush flag
             }
             else
             {
                 //std::ostringstream oss;
                 //comma::csv::output_stream< interval_t< From, To > > osstream( oss ); // todo! quick and dirty, watch performance!
                 if( !from_has_value || !to_has_value ) { std::cerr << "csv-interval: support for empty from/to values for --append: todo" << std::endl; exit( 1 ); }
                 for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v )
                 {
                     std::cout << *v << csv.delimiter;
                     ostream.write( interval );
                 }
             }
         }
         else
         {
             if( csv.binary() )
             {
                 if( intervals_only ) { ostream.write( interval ); ostream.flush(); continue; }
                 for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v ) { ostream.write( interval, *v ); }
                 ostream.flush();
             }
             else
             {
                 for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v )
                 {
                     std::string payload( intervals_only ? "" : *v );
                     ostream.ascii().ascii().put( interval, payload );
                     if( !from_has_value ) { from_ascii.put( from_t< std::string >(), payload ); }
                     if( !to_has_value ) { to_ascii.put( to_t< std::string >(), payload); }
                     std::cout << payload << std::endl;
                     if( intervals_only ) { break; }
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
		map_t::iterator end() //const
		{
			return map.end();
		}