• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ shared_array类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GeneralActionCommand

void NaoActionControl::GeneralActionCommand()
{
    stringstream ss;

    const shared_array<Robot::Link> link = NAO->GetLink();
    if (link.get() != 0)
    {
        for (int i = NAO->GetJointMin(); i <= NAO->GetJointMax(); ++i)
        {
            if (i == Robot::JID_ROOT) continue;
            /** NOTE if the link is the top one or not been set
             * up correctly, its joint velocity will not be sent */
            // if (link[i].mother == 0) continue;
            int twin = link[i].twin;
            if (twin == 0) // hinge joint effector
            {
                ss << "(" << link[i].eff_name;
                ss << " " << Precision(mJointVel[i]) << ")";
            }
            else // universal joint effector
            {
                int child = link[i].child;
                if (twin == child) // first twin
                {
                    ss << "(" << link[i].eff_name;
                    ss << " " << Precision(mJointVel[i]);
                    ss << " " << Precision(mJointVel[twin]) << ")";
                }
            }
        }
    }
    mActionCommand = ss.str();
    aLOG << mActionCommand << endl;
    aLOG << "****************************************the end of send message****************************************" << endl;
}
开发者ID:WenbinWang,项目名称:strive3d,代码行数:35,代码来源:NaoActionControl.cpp


示例2: Java_nl_ru_ai_projects_parrot_dronecontrol_groundstation_GroundStation_getFrontCameraImage0

JNIEXPORT jobject JNICALL Java_nl_ru_ai_projects_parrot_dronecontrol_groundstation_GroundStation_getFrontCameraImage0(JNIEnv* env, jobject obj) {
  lock_guard<recursive_mutex> dcoLock(droneControlObjectMutex);
  int imageSize = droneControlObject->getImageWidth() * droneControlObject->getImageHeight() * 3;

  if (imageSize == 0) {
    return NULL;
  }

  if (imageSize != allocatedFrontImageBufferData) {
    if (frontImageBufferData != NULL) {
      env->DeleteGlobalRef(frontImageBufferData);
      frontImageBufferData = NULL;
    }

    allocatedFrontImageBufferData = imageSize;
    if (imageSize > 0) {
      droneFrontImageData = shared_array<char>(new char[allocatedFrontImageBufferData]);
      frontImageBufferData = env->NewDirectByteBuffer(droneFrontImageData.get(), allocatedFrontImageBufferData);
      if (frontImageBufferData == NULL) {
        return NULL;
      }
    }
  }
  char* imageData = droneControlObject->getImageData();
  memcpy(droneFrontImageData.get(), imageData, imageSize);

  return frontImageBufferData;
}
开发者ID:SaiVineethKS,项目名称:BioMAV,代码行数:28,代码来源:GroundStation.cpp


示例3: sprintf

/**
 * save tga images
 * @param name - file name to which data should be saved
 * @param data - smart array containing data to be stored (must be 32Bit per Pixel)
 * @param width,height - size of the image data
 * @return 0 if no error occurs
 */
int nrCTextureLoader::save_tga(const string& name,const shared_array<byte>& data,int width,int height) {
	
	char nname[1024];
	sprintf(nname, "%s%s", nrVFS.getPathToFileSystem(), name.c_str());
	FILE *file = fopen(nname,"wb");
	if(!file) {
		nrLog.Log(NR_LOG_ENGINE, "nrCTextureLoader::save_tga(): error create '%s' file",name.c_str());
		return 0;
	}
	shared_array<byte> buf(new byte[18 + width * height * 4]);
	memset(buf.get(),0,18);
	buf[2] = 2;
	buf[12] = width % 256;
	buf[13] = width / 256;
	buf[14] = height % 256;
	buf[15] = height / 256;
	buf[16] = 32;
	buf[17] = 0x28;
	memcpy(buf.get() + 18,data.get(),width * height * 4);

	// rgba->bgra
	for(int i = 18; i < 18 + width * height * 4; i += 4) {
		byte c = buf[i];
		buf[i] = buf[i + 2];
		buf[i + 2] = c;
	}
	fwrite(buf.get(),1,18 + width * height * 4,file);
	fclose(file);
	return 1;
}
开发者ID:BackupTheBerlios,项目名称:stunts2005,代码行数:37,代码来源:nrCTextureLoader.cpp


示例4: Update

void NaoActionControl::Update()
{
    const shared_array<Robot::Link> link = NAO->GetLink();
    if (link.get() != 0)
    {
        for (int i = NAO->GetJointMin(); i <= NAO->GetJointMax(); ++i)
        {
            //cerr << "ActionControl::Update----" << "i:" << i << endl;
            if (i == Robot::JID_ROOT) continue;
            /** NOTE if the link is the top one or not been
            * set up correctly, it will not be updated */
            // if (link[i].mother == 0) continue;
            mJointAngle[i] = link[i].q;
        }
    }

    for (int i = NAO->GetJointMin(); i <= NAO->GetJointMax(); ++i)
    {
        mJointVel[i] = 0.0f;
    }
}
开发者ID:WenbinWang,项目名称:strive3d,代码行数:21,代码来源:NaoActionControl.cpp


示例5: release

	void release()
	{
		// Note that if two OpenCLBuffers point to the same thing, then this
		// only disconnects one side - the other one should be fine as both
		// cl::Buffer and boost::shared_array are reference counted.
		m_buffer=cl::Buffer();
		m_pElts=NULL;
		if(m_pStg)
			m_pStg->Release();
		m_pStg=0;
		m_n=0;
		m_cb=0;
		m_name="<empty>";
	}
开发者ID:alcides,项目名称:pcg_cl,代码行数:14,代码来源:opencl_buffer.hpp


示例6: print

void print(shared_array<char> text)
{
	std::cout << text.get() << std::endl;
}
开发者ID:taiyang-li,项目名称:learning_boost,代码行数:4,代码来源:ex1.cpp


示例7: swap

template<class T> void swap(shared_array<T> & a, shared_array<T> & b) // never throws
{
    a.swap(b);
}
开发者ID:4ukuta,项目名称:core,代码行数:4,代码来源:shared_array.hpp


示例8:

template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) // never throws
{
    return std::less<T*>()(a.get(), b.get());
}
开发者ID:4ukuta,项目名称:core,代码行数:4,代码来源:shared_array.hpp


示例9: TEST_CASE

#include "TestHeader.hpp"
#include <Core/SharedArray.hpp>


TEST_CASE("Shared Array Basics", "[shared_array]")
{
  test_allocator _Allocator;
  allocator_interface* Allocator = &_Allocator;

  shared_array<int> Arr{};
  Arr.Allocator = Allocator;

  REQUIRE( Arr.Num() == 0 );

  SECTION("Reserve")
  {
    Reserve(Arr, 10);
    REQUIRE( Arr.Num() == 0 );
    REQUIRE( Arr.Capacity() >= 10 );
    REQUIRE( Arr.Ptr() != nullptr );
  }

  SECTION("PushBack")
  {
    Expand(Arr) = 42;
    REQUIRE( Arr.Num() == 1 );
    REQUIRE( Arr[0] == 42 );
  }
}

TEST_CASE("Shared Array Reserve", "[shared_array]")
开发者ID:Manuzor,项目名称:VulkanExperiments,代码行数:31,代码来源:Test_SharedArray.cpp


示例10: swap

template<class T> void swap(shared_array<T> & a, shared_array<T> & b)
{
    a.swap(b);
}
开发者ID:ALuehmann,项目名称:labstreaminglayer,代码行数:4,代码来源:shared_array_nmt.hpp


示例11:

template<class T, class U> inline bool operator!=(shared_array<T> const & a, shared_array<U> const & b)
{
    return a.get() != b.get();
}
开发者ID:ALuehmann,项目名称:labstreaminglayer,代码行数:4,代码来源:shared_array_nmt.hpp


示例12: BlasiusFixture

    BlasiusFixture()
        : code_Ma(1.5)
        , blasius_u(suzerain_blasius_u(Re_x))
        , blasius_v(suzerain_blasius_v(Re_x))
        , accel(gsl_interp_accel_alloc())
        , b(k,
            bspline::from_breakpoints(),
            suzerain_blasius_extended_size,
            blasius_u->x + /*UGLY HACK uses Nnegative from blasius.c */10)
        , op(b, 0, SUZERAIN_BSPLINEOP_COLLOCATION_GREVILLE)
        , lu(op)
        , u (new double[b.n()])
        , v (new double[b.n()])
        , ke(new double[b.n()])
        , H0(new double[b.n()])
    {
        lu.factor_mass(op);

        // Prepare Blasius profile information as coefficients
        for (int i = 0; i < b.n(); ++i) {
            u[i]  = gsl_spline_eval(blasius_u, b.collocation_point(i), accel);
            v[i]  = gsl_spline_eval(blasius_v, b.collocation_point(i), accel);
            ke[i] = (u[i]*u[i] + v[i]*v[i]) / 2;
            H0[i] = u[i] + code_Ma*code_Ma*ke[i]; // h = u => delta2 = deltaH0
        }

        BOOST_REQUIRE_EQUAL(SUZERAIN_SUCCESS, lu.solve(1, u .get(), 1, b.n()));
        BOOST_REQUIRE_EQUAL(SUZERAIN_SUCCESS, lu.solve(1, v .get(), 1, b.n()));
        BOOST_REQUIRE_EQUAL(SUZERAIN_SUCCESS, lu.solve(1, ke.get(), 1, b.n()));
        BOOST_REQUIRE_EQUAL(SUZERAIN_SUCCESS, lu.solve(1, H0.get(), 1, b.n()));
    }
开发者ID:RhysU,项目名称:suzerain,代码行数:31,代码来源:test_bl.cpp


示例13: loadMovieResource

void QuickTimeSampleApp::loadMovieResource()
{
	try {
		loadResourceMemory( "Upgrade_U_small.mov", RES_UPGADE_U_MOV, "MOV", &data, &dataSize );
		
		mMovie = qtime::MovieGL( data.get(), dataSize, "Upgrade_U_small.mov", "video/quicktime" );
		std::cout << "Dimensions:" << mMovie.getWidth() << " x " << mMovie.getHeight() << std::endl;
		std::cout << "Duration:  " << mMovie.getDuration() << " seconds" << std::endl;
		std::cout << "Frames:    " << mMovie.getNumFrames() << std::endl;
		std::cout << "Framerate: " << mMovie.getFramerate() << std::endl;				
		mMovie.setLoop( true, true );
		
#ifdef USE_DISPLAY_LINK
		mMovie.enableDisplayLink( getDisplayLink() );
#endif
		mMovie.setNewFrameCallback( newFrameCallback, &mMovie );
		mMovie.play();
	}
	catch( ... ) {
		std::cout << "Unable to load the movie." << std::endl;
		mMovie.reset();
	}

	mTexture.reset();
}
开发者ID:AaronMeyers,项目名称:Cinder,代码行数:25,代码来源:quickTimeSample.cpp


示例14: cleanupOpenSSL

void TSSLSocketFactory::cleanupOpenSSL() {
  if (!initialized) {
    return;
  }
  initialized = false;
#if (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_NO_THREAD_ID)
  CRYPTO_set_id_callback(NULL);
#endif
  CRYPTO_set_locking_callback(NULL);
  CRYPTO_set_dynlock_create_callback(NULL);
  CRYPTO_set_dynlock_lock_callback(NULL);
  CRYPTO_set_dynlock_destroy_callback(NULL);
  CRYPTO_cleanup_all_ex_data();
  ERR_free_strings();
  EVP_cleanup();
  ERR_remove_state(0);
  mutexes.reset();
}
开发者ID:danigrmartinez,项目名称:thrift,代码行数:18,代码来源:TSSLSocket.cpp


示例15: two_bit_color_map

 explicit two_bit_color_map(std::size_t n, const IndexMap& index = IndexMap())
   : n(n), index(index), data(new unsigned char[(n + 3) / 4])
 {
   // Fill to white
   std::fill(data.get(), data.get() + (n + 3) / 4, 0);
 }
开发者ID:JupiterSmalltalk,项目名称:openqwaq,代码行数:6,代码来源:two_bit_color_map.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ shared_ptr类代码示例发布时间:2022-05-31
下一篇:
C++ shaderCommands_t类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap