Ejemplo n.º 1
0
void test_table(void) {
  catdb::DBase::Database database("Billy_database");
  catdb::DBase::Database database1("Johnny_database");
  catdb::Column* temp = database.find_column("Cool");

  std::cout << temp->display_list() << std::endl;
  delete temp;
  temp = NULL;
  catdb::Container* container(new catdb::Container("Alex"));
  catdb::Container container1("Billy");
  catdb::Container container2("Fred");
  catdb::Container container3("Zen");

  container->insert_new_element("12.2", "Cool");
  container1.insert_new_element("14.3", "Cool");
  container2.insert_new_element("99.9", "Cool");
  container3.insert_new_element("80.2", "Cool");
  std::cout << container->obtain_element("12.2")->get_attribute() << std::endl;
  // not implemented yet!!
  database.add_container(container);
  database.add_container(&container1);
  database.add_container(&container2);
  database.add_container(&container3);

  std::cout << database.get_container("Alex")->get_container_name() << std::endl;
  std::cout << "Here is a list of stuff in this column" << std::endl;
  catdb::Column* column = database.find_column("Cool");
  catdb::Element* element = column->inspect_element("12.2", "Cool");
  column->sort_column(tools::sorting::quick_sort, tools::sorting::SORT_LITTLE_ENDIAN);
  std::cout << column->display_list() << std::endl;
  database.remove_container("Alex");
  database.remove_container("Billy");
  database.remove_container("Fred");
  database.remove_container("Zen");
  delete column;
  column = NULL;

  database1 = database;
  catdb::GreaterComparator<catdb::Element> _g;
  catdb::Comparator<catdb::Element>& _comp = catdb::LesserComparator<catdb::Element>();
  catdb::Element el1("Cooler", "Bool", "Mang");
  catdb::Element el2("Alex", "Benson", "Kol");
  std::cout << _comp(el1, el2) << std::endl;
  tools::data_structures::hash_map<int, int> mapping;


  //	if (database.get_container("Alex") == NULL)
  //	   std::cout << "Alex is deleted!" << std::endl;

  //	database.folder_create();
  //	catdb::DBase::display_db_error_msg();
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
	SDL_Init(SDL_INIT_EVERYTHING);
		
	ekran = SDL_SetVideoMode( 800, 600, 32, SDL_SWSURFACE );
	DrawableSDL::surface = ekran;
    SDL_Flip( ekran );
	SDL_CDOpen(0);
	ekran->pixels;
	SDL_Event e;
	int frame_time;
	SDL_PollEvent(&e);

	FontFactory::initializeFont("simplePix", "pixelart.ttf", 10);

	SDL_Rect rect;
	rect.x=100;
	rect.y=10;
	rect.w=100;
	rect.h=100;

	TTF_Init();

	Rectangle object1;
	object1.setColor(0xff, 0xff, 0xff);
	
	Rectangle object2;
	object2.setColor(0xf1, 0x00, 0xda);
	object2.setX(50);

	object1.setX(10);

	Container helping(100,30);
	//helping.add(&object1);

	Container root(10,10);

	SimpleScrollBar scroll(100, 100, 10, 150, 0, 1000, Orientation::horizontal);
	SimpleScrollBar scroll2(100, 85, 10, 150, 0, 1000, Orientation::horizontal);
	root.add(&scroll);
	Button ok(100, 100, 60, 20, "Here i am");
	ok.setBorderSize(2);
	ok.setBackground(255,225,255);
	ok.setBorderColor(10,100,10);
	ok.setFontName("simplePix");
	smth e_inst;
	ok+= *(new Delegate(&e_inst));

	Button ok2(200, 200, 80, 20, "I am not here");
	ok2.setBorderSize(2);
	ok2.setBackground(255,225,255);
	ok2.setBorderColor(10,100,10);
	ok2.setFontName("simplePix");
	root.add(&ok);
	root.add(&scroll2);
	root.add(&ok2);
	//ok.setEnable(false);

	ListBoxElementSDL el(50);
	el.setText("hello");
	el.setSelection(false);
	el.cut(4, down);
	ListBoxElementSDL el1(50);
	el1.setText("welcome");
	el1.setSelection(false);
	ListBoxElementSDL el2(50);
	el2.setText("hejo");
	el2.setSelection(false);
	ListBoxElementSDL el3(50);
	el3.setText("hejo2");
	ListBoxElementSDL el4(50);
	el4.setText("hejo1");
	ListBoxElementSDL el5(50);
	el5.setText("hejo3");
	ListBoxElementSDL el6(50);
	el6.setText("Witam");
	ListBoxElementSDL el7(50);
	el7.setText("Witam");

	ListBoxSDL list(500, 200, 100, 50, 2);
	list.add(&el);
	list.add(&el1);
	list.add(&el2);
	list.add(&el3);
	list.add(&el4);
	list.add(&el5);
	list.add(&el6);
	list.add(&el7);
	root.add(&list);
	MovingRectangle movrect;
	MovingRectangle movrect2;
	movrect2.setColor(0x43, 0x52, 0xFF);

	//root.add(&movrect);
	//root.add(&movrect2);
	Uint32 color = SDL_MapRGB(ekran->format, 0xff, 0xff, 0xff);
	Uint32 color2 = SDL_MapRGB(ekran->format, 0x00, 0xff, 0xff);
	short int r=0,g=0,b=0;
	while(true)
	{
		frame_time = SDL_GetTicks();
		ok.setX(scroll.getValue());
		ok.setY(scroll2.getValue());
		SDL_FillRect(ekran, &(ekran->clip_rect), color2);
		root.draw(0,0);

		if(SDL_PollEvent(&e))
		{
			if(e.type == SDL_QUIT)
			{
				SDL_Quit();
				return 0;
			}
			root.spreadEvent(e);
		}
		SDL_Flip(ekran);
		if((SDL_GetTicks() - frame_time) < 1000/FPS)
			SDL_Delay(1000/FPS - (SDL_GetTicks() - frame_time));

	}


	return 0;
}
Ejemplo n.º 3
0
int main (int argc, char *argv[])
{


  
  std::vector<double> punto1(1,0.0);
  std::vector<double> punto2(1,1.0);
  std::vector<double> punto3(1,2.0);
  std::vector<double> punto4(1,3.0);

  Punto<1> pt1(punto1);
  Punto<1> pt2(punto2);
  Punto<1> pt3(punto3);
  Punto<1> pt4(punto4);

  std::vector<Punto<1> >element1;
  element1.push_back(pt1);
  element1.push_back(pt2);
  std::vector<Punto<1> >element2;
  element2.push_back(pt2);
  element2.push_back(pt3);
  std::vector<Punto<1> >element3;
  element3.push_back(pt3);
  element3.push_back(pt4);
 
    myelement<1> el1(element1);
    myelement<1> el2(element2);
    myelement<1> el3(element3);

    std::vector<myelement<1> > raccoltael;
  raccoltael.push_back(el1);
  raccoltael.push_back(el2);
  raccoltael.push_back(el3);
  std::cout<<raccoltael.size()<<std::endl;
  mymesh<myelement<1> > dominiop(raccoltael);
  std::cout<<dominiop.size_element()<<std::endl;

  QuadFactory::RulesFactory & rulesFactory(QuadFactory::RulesFactory::Instance());
  const Quadrature1D * therule = rulesFactory.create("Trapezi");
  therule->ShowMe();
  NumericalQuad<1> integrale(therule,dominiop);
  std::cout<<integrale.apply(&xquad)<<std::endl;
  /*therule = rulesFactory.create("Simpson");
  therule->ShowMe();
  integrale.SetRule(therule);
  std::cout<<integrale.apply(&xquad)<<std::endl;
  therule = rulesFactory.create("MidPoint");
  therule->ShowMe();
  integrale.SetRule(therule);
  std::cout<<integrale.apply(&xquad)<<std::endl;
  */
/*
  MidPoint mid;
  Trapezi trap;
  Simpson simp;
 

  std::vector<double> dominio;
  double a = 0;
  double b = 6;
  double step = 0;
  double value = 0;

  NumericalQuad integrale;

  std::ofstream file("Errori.txt");

  unsigned int maxit = 15;
  for(size_t i(2);i<maxit;i++)
    {
      dominio.resize(i+1);
      step = (b-a)/i;
      for(size_t k(0);k<=i;k++) dominio[k]=a+k*step;

      integrale.SetDom(dominio);

      integrale.SetRule(&mid);
      value = integrale.apply(&xquad);
      std::cout<<"Midpoint = "<<value<<std::endl;
      file<<fabs(value - 6*6*6*6*6)<<'\t';

      integrale.SetRule(&trap);
      value = integrale.apply(&xquad);
      std::cout<<"Trapezi = "<<value<<std::endl;
      file<<fabs(value - 6*6*6*6*6)<<'\t';

      integrale.SetRule(&simp);
      value =  integrale.apply(&xquad);
      std::cout<<"Simpson = "<<value<<std::endl;
      file<<fabs(value - 6*6*6*6*6);

      file<<std::endl;
    }

    file.close();*/
  return 0;
}