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


C++ Shared类代码示例

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


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

示例1: LogBuffer

		Ref<Image> Image::load_from_data (const Ptr<IData> data) {
			static Stopwatch t;
			static unsigned count = 0; ++count;

			Ref<Image> loaded_image;
			Shared<Buffer> buffer;

			t.start();

			buffer = data->buffer();

			switch (buffer->mimetype()) {
			case IMAGE_JPEG:
				loaded_image = load_jpeg_image(data);
				break;
			case IMAGE_PNG:
				loaded_image = load_png_image(data);
				break;
			//case Data::IMAGE_DDS:
			//	loaded_image = load_ddsimage(data);
			default:
				logger()->log(LOG_ERROR, "Could not load image: Unsupported image format.");
			}

			t.pause();

			logger()->log(LOG_INFO, LogBuffer() << "*** Total time to load " << count << " images: " << t.time() << "s");

			return loaded_image;
		}
开发者ID:rdcastan,项目名称:dream,代码行数:30,代码来源:Image.Load.cpp

示例2: ns2ClassA_memberFunction_9

void ns2ClassA_memberFunction_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
  typedef boost::shared_ptr<ns2::ClassA> Shared;
  checkArguments("memberFunction",nargout,nargin-1,0);
  Shared obj = unwrap_shared_ptr<ns2::ClassA>(in[0], "ptr_ns2ClassA");
  out[0] = wrap< double >(obj->memberFunction());
}
开发者ID:haidai,项目名称:gtsam,代码行数:7,代码来源:testNamespaces_wrapper.cpp

示例3: SaveToFile

CC_FILE_ERROR FileIOFilter::SaveToFile(	ccHObject* entities,
										const QString& filename,
										SaveParameters& parameters,
										Shared filter)
{
	if (!entities || filename.isEmpty() || !filter)
		return CC_FERR_BAD_ARGUMENT;

	//if the file name has no extension, we had a default one!
	QString completeFileName(filename);
	if (QFileInfo(filename).suffix().isEmpty())
		completeFileName += QString(".%1").arg(filter->getDefaultExtension());

	CC_FILE_ERROR result = CC_FERR_NO_ERROR;
	try
	{
		result = filter->saveToFile(entities, completeFileName, parameters);
	}
	catch(...)
	{
		ccLog::Warning(QString("[I/O] CC has caught an unhandled exception while saving file '%1'").arg(filename));
		result = CC_FERR_CONSOLE_ERROR;
	}

	if (result == CC_FERR_NO_ERROR)
	{
		ccLog::Print(QString("[I/O] File '%1' saved successfully").arg(filename));
	}
	else
	{
		DisplayErrorMessage(result,"saving",filename);
	}

	return result;
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例4: main

int main()
{
    Shared<Car> a;
    auto age1 = a.execute([](Car & c) -> unsigned { return c.increment_age(); });
    auto age2 = a.execute([](Car & c) -> unsigned { return c.increment_age(); });
    auto age3 = a.execute([](Car & c) -> unsigned { return c.increment_age(); });
    std::cout << age1.get() << ", " << age2.get() << ", " << age3.get() << std::endl;
}
开发者ID:CCJY,项目名称:coliru,代码行数:8,代码来源:main.cpp

示例5: ns2ClassA_nsArg_10

void ns2ClassA_nsArg_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
  typedef boost::shared_ptr<ns2::ClassA> Shared;
  checkArguments("nsArg",nargout,nargin-1,1);
  Shared obj = unwrap_shared_ptr<ns2::ClassA>(in[0], "ptr_ns2ClassA");
  ns1::ClassB& arg = *unwrap_shared_ptr< ns1::ClassB >(in[1], "ptr_ns1ClassB");
  out[0] = wrap< int >(obj->nsArg(arg));
}
开发者ID:haidai,项目名称:gtsam,代码行数:8,代码来源:testNamespaces_wrapper.cpp

示例6:

		/// Create a buffer from a given input stream
		BufferedData::BufferedData (std::istream & stream)
		{
			Shared<DynamicBuffer> buffer = new DynamicBuffer;

			buffer->append(std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>());

			_buffer = buffer;
		}
开发者ID:DerDolch,项目名称:dream,代码行数:9,代码来源:Data.cpp

示例7: ns2ClassA_nsReturn_11

void ns2ClassA_nsReturn_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
  typedef boost::shared_ptr<ns2::ns3::ClassB> SharedClassB;
  typedef boost::shared_ptr<ns2::ClassA> Shared;
  checkArguments("nsReturn",nargout,nargin-1,1);
  Shared obj = unwrap_shared_ptr<ns2::ClassA>(in[0], "ptr_ns2ClassA");
  double q = unwrap< double >(in[1]);
  out[0] = wrap_shared_ptr(SharedClassB(new ns2::ns3::ClassB(obj->nsReturn(q))),"ns2.ns3.ClassB", false);
}
开发者ID:haidai,项目名称:gtsam,代码行数:9,代码来源:testNamespaces_wrapper.cpp

示例8: deserialize

		void Dictionary::deserialize (Ref<IData> data)
		{
			Shared<Buffer> buffer = data->buffer();
			std::size_t offset = 0;

			while (offset < buffer->size()) {
				KeyT key = TypeSerialization<TI_STRING>::read_from_buffer(*buffer, offset);
				_values[key] = Value::read_from_buffer(*buffer, offset);
			}
		}
开发者ID:kurocha,项目名称:dream,代码行数:10,代码来源:Dictionary.cpp

示例9: load_jpeg_image

		static Ref<Image> load_jpeg_image (const Ptr<IData> data) {
			jpeg_decompress_struct cinfo;
			jpeg_error_mgr jerr;

			Ref<Image> result_image;
			DataType data_type = DataType::BYTE;
			
			Shared<Buffer> buffer = data->buffer();

			unsigned width, height;

			try {
				//memset (&cinfo, 0, sizeof (cinfo));
				memset (&jerr, 0, sizeof (jerr));

				cinfo.err = jpeg_std_error(&jerr);

				jpeg_create_decompress(&cinfo);
				jpeg_memory_src(&cinfo, buffer->begin(), buffer->size());

				jpeg_read_header(&cinfo, TRUE);

				width = cinfo.image_width;
				height = cinfo.image_height;

				unsigned row_width = 0;
				PixelFormat pixel_format;
				
				if (cinfo.jpeg_color_space == JCS_GRAYSCALE) {
					row_width = width;
					pixel_format = PixelFormat::L;
				} else {
					row_width = 3 * width;
					pixel_format = PixelFormat::RGB;
				}

				result_image = new Image(Vec2u(width, height), pixel_format, data_type);

				ByteT *line = result_image->data();
				jpeg_start_decompress(&cinfo);

				// read jpeg image
				while (cinfo.output_scanline < cinfo.output_height) {
					jpeg_read_scanlines(&cinfo, &line, 1);
					line += row_width;
				}

				jpeg_finish_decompress(&cinfo);
				jpeg_destroy_decompress(&cinfo);
			} catch (std::exception &e) {
			}

			return result_image;
		};
开发者ID:rdcastan,项目名称:dream,代码行数:54,代码来源:Image.Load.cpp

示例10: load_wave_data

		Ref<Object> Sound::Loader::load_from_data (const Ptr<IData> data, const ILoader * loader)
		{
			Shared<Buffer> buffer = data->buffer();

			Mimetype mt = buffer->mimetype();

			if (mt == AUDIO_XWAV) {
				return load_wave_data(data);
			} else {
				throw LoadError("Could not load audio data");
			}
		}
开发者ID:kurocha,项目名称:dream-audio-openal,代码行数:12,代码来源:Sound.cpp

示例11: main

int main()
{
	Shared shlib;
	Static stlib;

	std::cout << "Static library subtract(5, 3): ";
	std::cout << stlib.subtract(5, 3) << std::endl;

	std::cout << "Shared library add(4, 5): ";
	std::cout << shlib.add(4, 5) << std::endl;

	return EXIT_SUCCESS;
}
开发者ID:michelm,项目名称:chihuahua,代码行数:13,代码来源:program.cpp

示例12: property

			Shared<Buffer> Program::info_log() {
				GLint length;
				property(GL_INFO_LOG_LENGTH, &length);

				if (length > 0) {
					Shared<MutableBuffer> buffer = PackedBuffer::new_buffer(length);

					glGetProgramInfoLog(_handle, length, NULL, (GLchar *)buffer->begin());

					return buffer;
				} else {
					return NULL;
				}
			}
开发者ID:DerDolch,项目名称:dream,代码行数:14,代码来源:ShaderManager.cpp

示例13:

	Shared<ui::Font> FontAsset::createFont() const
	{
		Shared<Texture2D> atlasTex = Shared<Texture2D>::alloc();
		atlasTex->alloc();

		atlasTex->set_texels(atlas, 0);

		return Shared<ui::Font>::alloc(
			std::move(atlasTex),
			entries,
			defaultEntry,
			lineHeight,
			tabWidth,
			spaceWidth);
	}
开发者ID:RmbRT,项目名称:re,代码行数:15,代码来源:FontAsset.cpp

示例14: init

 void init(
         const Shared & shared,
         const Group & group,
         rng_t & rng) {
     Shared post = shared.plus_group(group);
     mean = sample_gamma(rng, post.alpha, 1.f / post.inv_beta);
 }
开发者ID:akkinenirajesh,项目名称:distributions,代码行数:7,代码来源:gp.hpp

示例15: init

 void init(
         const Shared & shared,
         const Group & group,
         rng_t & rng) {
     Shared post = shared.plus_group(group);
     beta = sample_beta(rng, post.alpha, post.beta);
 }
开发者ID:datamicroscopes,项目名称:distributions,代码行数:7,代码来源:bnb.hpp


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