Esempio n. 1
0
int main() {
  Buffer buf;
  Network n1 = {1, 1};
  Network n2 = {1, 2};
  Network n3 = {2, 1};
  buf[n1] = Frames();
  buf[n2] = Frames();
  buf[n3] = Frames();
  std::cout << "Size, Capacity: " << buf[n1].size() << ", " << buf[n1].capacity() << std::endl;
  std::cout << "Size, Capacity: " << buf[n2].size() << ", " << buf[n2].capacity() << std::endl;
  std::cout << "Size, Capacity: " << buf[n3].size() << ", " << buf[n3].capacity() << std::endl;
  for (auto i = 0; i < 500000; ++i) {
    buf[n1].emplace_back(i + 1, i + 0, RawData(20, 'A'));
  } 
  for (auto i = 0; i < 1000000; ++i) {
    buf[n2].emplace_back(i + 3, i + 2, RawData(20, 'B'));
  } 
  for (auto i = 0; i < 1000000; ++i) {
    buf[n3].emplace_back(i + 5, i + 4, RawData(76, 'C'));
  } 
  std::cout << "Size, Capacity: " << buf[n1].size() << ", " << buf[n1].capacity() << std::endl;
  std::cout << "Size, Capacity: " << buf[n2].size() << ", " << buf[n2].capacity() << std::endl;
  std::cout << "Size, Capacity: " << buf[n3].size() << ", " << buf[n3].capacity() << std::endl;

  int size = sizeof(buf);
  int sizem = sizeof(buf);
  for (const auto& n: buf) {
    size += sizeof(n);
    sizem += sizeof(n);
    for (const auto& f: n.second) {
      size += sizeof(f);
      sizem += sizeof(f);
      sizem += f.data.size();
    }
  }
  std::cout << "Total size: " << size << ", " << sizem << std::endl;

  return 0;
}
Esempio n. 2
0
int
DohEqual(const DOH *obj1, const DOH *obj2) {
  DohBase *b1 = (DohBase *) obj1;
  DohBase *b2 = (DohBase *) obj2;
  if (!b1) {
    return !b2;
  } else if (!b2) {
    return 0;
  } else {
    DohObjInfo *b1info = 0;
    DohObjInfo *b2info = 0;
    if (DohCheck(b1)) {
      b1info = b1->type;
      if (DohCheck(b2)) {
	b2info = b2->type;
      } else {
	int len = (b1info->doh_len)(b1);
	char *cobj = (char *) obj2;
	return len == (int)strlen(cobj) ? (memcmp(RawData(b1), cobj, len) == 0) : 0;
      }
    } else if (DohCheck(b2)) {
      int len = (b2->type->doh_len)(b2);
      char *cobj = (char *) obj1;
      return len == (int)strlen(cobj) ? (memcmp(RawData(b2), cobj, len) == 0) : 0;
    } else {
      return strcmp((char*) obj1, (char*) obj2) == 0;
    }
    
    if (!b1info) {
      return obj1 == obj2;
    } else if ((b1info == b2info)) {
      return b1info->doh_equal ? (b1info->doh_equal)(b1,b2) : 
	(b1info->doh_cmp ? (b1info->doh_cmp)(b1,b2) == 0 : (b1 == b2));
    } else {
      return 0;
    }
  }
}
Esempio n. 3
0
int
DohCmp(const DOH *obj1, const DOH *obj2) {
  DohBase *b1, *b2;
  DohObjInfo *b1info, *b2info;
  int c1, c2;
  b1 = (DohBase *) obj1;
  b2 = (DohBase *) obj2;
  c1 = DohCheck(b1);
  c2 = DohCheck(b2);
  /* most of the times, obj2 is a plain c string */  
  if (!c1 || !c2) {
    if ((b1 == 0) && (b2 == 0)) return 0;
    if (b1 && !b2) return 1;
    if (!b1 &&  b2) return -1;
    return strcmp((char *) (c1 ? RawData(b1) : (void*) obj1),
		  (char *) (c2 ? RawData(b2) : (void*) obj2));
  }
  b1info = b1->type;
  b2info = b2->type;
  if ((b1info == b2info) && (b1info->doh_cmp)) 
    return (b1info->doh_cmp)(b1,b2);
  return 1;
}
Esempio n. 4
0
	SketchExample(void)
	 : transf_prog()
	 , sketch_prog()
	 , plane(
		transf_prog,
		shapes::Plane(
			Vec3f(0, 0, 0),
			Vec3f(9, 0, 0),
			Vec3f(0, 0,-9),
			9, 9
		)
	), torus(transf_prog, shapes::WickerTorus())
	 , sketch_tex_layers(8)
	 , shadow_tex_side(1024)
	{

		NoProgram().Use();

		shadow_pp.Bind();
		shadow_pp.UseStages(transf_prog).Vertex();
		shadow_pp.UseStages(shadow_prog).Fragment();

		sketch_pp.Bind();
		sketch_pp.UseStages(transf_prog).Vertex();
		sketch_pp.UseStages(sketch_prog).Fragment();

		line_pp.Bind();
		line_pp.UseStages(transf_prog).Vertex();
		line_pp.UseStages(line_prog).Geometry().Fragment();

		Texture::Active(0);
		sketch_prog.sketch_tex.Set(0);
		{
			auto bound_tex = gl.Bound(Texture::Target::_3D, sketch_texture);

			for(GLuint i=0; i<sketch_tex_layers; ++i)
			{
				auto image = images::BrushedMetalUByte(
					512, 512,
					64 + i*128,
					-(2+i*4), +(2+i*4),
					64, 256-i*4
				);
				if(i == 0)
				{
					bound_tex.Image3D(
						0,
						PixelDataInternalFormat::RGB,
						image.Width(),
						image.Height(),
						sketch_tex_layers,
						0,
						image.Format(),
						image.Type(),
						nullptr
					);
				}
				bound_tex.SubImage3D(
					0,
					0, 0, i,
					image.Width(),
					image.Height(),
					1,
					image.Format(),
					image.Type(),
					image.RawData()
				);
			}
			bound_tex.GenerateMipmap();
			bound_tex.MinFilter(TextureMinFilter::LinearMipmapLinear);
			bound_tex.MagFilter(TextureMagFilter::Linear);
			bound_tex.WrapS(TextureWrap::Repeat);
			bound_tex.WrapT(TextureWrap::Repeat);
			bound_tex.WrapR(TextureWrap::ClampToEdge);
		}

		Texture::Active(1);
		sketch_prog.shadow_tex.Set(1);

		gl.Bound(Texture::Target::_2D, shadow_tex)
			.MinFilter(TextureMinFilter::Linear)
			.MagFilter(TextureMagFilter::Linear)
			.WrapS(TextureWrap::ClampToEdge)
			.WrapT(TextureWrap::ClampToEdge)
			.CompareMode(TextureCompareMode::CompareRefToTexture)
			.Image2D(
				0,
				PixelDataInternalFormat::DepthComponent32,
				shadow_tex_side, shadow_tex_side,
				0,
				PixelDataFormat::DepthComponent,
				PixelDataType::Float,
				nullptr
			);

		gl.Bound(Framebuffer::Target::Draw, frame_shadow_fbo)
			.AttachTexture(
				FramebufferAttachment::Depth,
				shadow_tex,
				0
			);

		gl.ClearDepth(1.0f);
		gl.Enable(Capability::DepthTest);
		gl.Enable(Capability::CullFace);

		gl.DepthFunc(CompareFn::LEqual);
		gl.BlendFunc(BlendFn::SrcAlpha, BlendFn::OneMinusSrcAlpha);

		gl.PolygonOffset(1.0, 1.0);
		gl.LineWidth(1.5);

	}
Esempio n. 5
0
///In the overview block, the bytes in the two certificates do not count for the checksum calculation
RawData VuOverview::signedBytes() const {
	return RawData(start + 2 + 194*2, size() - 128 - 2 - 194*2);
}
Esempio n. 6
0
RawData VuBlock::signedBytes() const {
	return RawData(start + 2, size() - 128 - 2);
}