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


C++ RefCountedPtr类代码示例

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


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

示例1: l_sbodypath_new

/*
 * Function: New
 *
 * Creates a new <SystemPath> object
 *
 * > path = SystemPath.New(sectorX, sectorY, sectorZ, systemIndex, bodyIndex)
 *
 * Parameters:
 *
 *   sectorX - galactic sector X coordinate
 *
 *   sectorY - galactic sector Y coordinate
 *
 *   sectorZ - galactic sector Z coordinate
 *
 *   systemIndex - optional. the numeric index of the system within the sector
 *
 *   bodyIndex - optional. the numeric index of a specific body within the
 *               system. Defaults to 0, which typically corresponds to the
 *               primary star.
 *
 * Availability:
 *
 *   alpha 10, alpha 13 (updated)
 *
 * Status:
 *
 *   stable
 */
static int l_sbodypath_new(lua_State *l)
{
	Sint32 sector_x = luaL_checkinteger(l, 1);
	Sint32 sector_y = luaL_checkinteger(l, 2);
	Sint32 sector_z = luaL_checkinteger(l, 3);

	SystemPath path(sector_x, sector_y, sector_z);

	if (lua_gettop(l) > 3) {
		path.systemIndex = luaL_checkinteger(l, 4);

		// if this is a system path, then check that the system exists
		Sector s(sector_x, sector_y, sector_z);
		if (size_t(path.systemIndex) >= s.m_systems.size())
			luaL_error(l, "System %d in sector <%d,%d,%d> does not exist", path.systemIndex, sector_x, sector_y, sector_z);

		if (lua_gettop(l) > 4) {
			path.bodyIndex = luaL_checkinteger(l, 5);

			// and if it's a body path, check that the body exists
			RefCountedPtr<StarSystem> sys = StarSystem::GetCached(path);
			if (size_t(path.bodyIndex) >= sys->m_bodies.size()) {
				luaL_error(l, "Body %d in system <%d,%d,%d : %d ('%s')> does not exist",
					path.bodyIndex, sector_x, sector_y, sector_z, path.systemIndex, sys->GetName().c_str());
			}
		}
	}
	LuaSystemPath::PushToLua(&path);
	return 1;
}
开发者ID:Sunsetjoy,项目名称:pioneer,代码行数:59,代码来源:LuaSystemPath.cpp

示例2: Output

void SystemInfoView::OnBodySelected(SystemBody *b)
{
	{
		Output("\n");
		Output("Gas, liquid, ice: %f, %f, %f\n", b->GetVolatileGas().ToFloat(), b->GetVolatileLiquid().ToFloat(), b->GetVolatileIces().ToFloat());
	}

	SystemPath path = m_system->GetPathOf(b);
	RefCountedPtr<StarSystem> currentSys = Pi::game->GetSpace()->GetStarSystem();
	bool isCurrentSystem = (currentSys && currentSys->GetSystemPath() == m_system->GetSystemPath());

	if (path == m_selectedBodyPath) {
		if (isCurrentSystem) {
			Pi::player->SetNavTarget(0);
		}
	} else {
		if (isCurrentSystem) {
			Body* body = Pi::game->GetSpace()->FindBodyForPath(&path);
			if(body != 0)
				Pi::player->SetNavTarget(body);
		} else if (b->GetSuperType() == SystemBody::SUPERTYPE_STAR) { // We allow hyperjump to any star of the system
			Pi::sectorView->SetSelected(path);
		}
	}

	UpdateIconSelections();
}
开发者ID:starmoth,项目名称:starmoth,代码行数:27,代码来源:SystemInfoView.cpp

示例3: l_sbodypath_get_system_body

/*
 * Method: GetSystemBody
 *
 * Get a <SystemBody> object for the body that this path points to
 *
 * > body = path:GetSystemBody()
 *
 * Return:
 *
 *   body - the <SystemBody>
 *
 * Availability:
 *
 *   alpha 10
 *
 * Status:
 *
 *   stable
 */
static int l_sbodypath_get_system_body(lua_State *l)
{
	SystemPath *path = LuaSystemPath::GetFromLua(1);
	RefCountedPtr<StarSystem> s = StarSystem::GetCached(path);
	SBody *sbody = s->GetBodyByPath(path);
	LuaSBody::PushToLua(sbody);
	return 1;
}
开发者ID:Sunsetjoy,项目名称:pioneer,代码行数:27,代码来源:LuaSystemPath.cpp

示例4: l_sbodypath_get_star_system

/*
 * Method: GetStarSystem
 *
 * Get a <StarSystem> object for the system that this path points to
 *
 * > system = path:GetStarSystem()
 *
 * Return:
 *
 *   system - the <StarSystem>
 *
 * Availability:
 *
 *   alpha 10
 *
 * Status:
 *
 *   stable
 */
static int l_sbodypath_get_star_system(lua_State *l)
{
	SystemPath *path = LuaObject<SystemPath>::CheckFromLua(1);
	RefCountedPtr<StarSystem> s = StarSystem::GetCached(path);
	// LuaObject<StarSystem> shares ownership of the StarSystem,
	// because LuaAcquirer<LuaObject<StarSystem>> uses IncRefCount and DecRefCount
	LuaObject<StarSystem>::PushToLua(s.Get());
	return 1;
}
开发者ID:Luomu,项目名称:pioneer,代码行数:28,代码来源:LuaSystemPath.cpp

示例5: Dump

void Galaxy::Dump(FILE* file, Sint32 centerX, Sint32 centerY, Sint32 centerZ, Sint32 radius)
{
    for (Sint32 sx = centerX - radius; sx <= centerX + radius; ++sx) {
        for (Sint32 sy = centerY - radius; sy <= centerY + radius; ++sy) {
            for (Sint32 sz = centerZ - radius; sz <= centerZ + radius; ++sz) {
                RefCountedPtr<const Sector> sector = Pi::GetGalaxy()->GetSector(SystemPath(sx, sy, sz));
                sector->Dump(file);
            }
            m_starSystemAttic.ClearCache();
        }
    }
}
开发者ID:Jamil20,项目名称:pioneer,代码行数:12,代码来源:Galaxy.cpp

示例6: PROFILE_SCOPED

RefCountedPtr<T> GalaxyObjectCache<T,CompareT>::GetIfCached(const SystemPath& path)
{
	PROFILE_SCOPED()

	RefCountedPtr<T> s;
	typename AtticMap::iterator i = m_attic.find(path);
	if (i != m_attic.end()) {
		s.Reset(i->second);
	}

	return s;
}
开发者ID:giriko,项目名称:pioneer,代码行数:12,代码来源:GalaxyCache.cpp

示例7: LoadDDSFromFile

static size_t LoadDDSFromFile(const std::string &filename, PicoDDS::DDSImage& dds)
{
	RefCountedPtr<FileSystem::FileData> filedata = FileSystem::gameDataFiles.ReadFile(filename);
	if (!filedata) {
		Output("LoadDDSFromFile: %s: could not read file\n", filename.c_str());
		return 0;
	}

	// read the dds file
	const size_t sizeRead = dds.Read( filedata->GetData(), filedata->GetSize() );
	return sizeRead;
}
开发者ID:AmesianX,项目名称:pioneer,代码行数:12,代码来源:TextureBuilder.cpp

示例8: l_sbodypath_get_star_system

/*
 * Method: GetStarSystem
 *
 * Get a <StarSystem> object for the system that this path points to
 *
 * > system = path:GetStarSystem()
 *
 * Return:
 *
 *   system - the <StarSystem>
 *
 * Availability:
 *
 *   alpha 10
 *
 * Status:
 *
 *   stable
 */
static int l_sbodypath_get_star_system(lua_State *l)
{
	SystemPath *path = LuaObject<SystemPath>::CheckFromLua(1);

	if (path->IsSectorPath())
		return luaL_error(l, "SystemPath:GetStarSystem() self argument does not refer to a system");

	RefCountedPtr<StarSystem> s = Pi::game->GetGalaxy()->GetStarSystem(path);
	// LuaObject<StarSystem> shares ownership of the StarSystem,
	// because LuaAcquirer<LuaObject<StarSystem>> uses IncRefCount and DecRefCount
	LuaObject<StarSystem>::PushToLua(s.Get());
	return 1;
}
开发者ID:nozmajner,项目名称:pioneer,代码行数:32,代码来源:LuaSystemPath.cpp

示例9: m_galaxy

Game::Game(const SystemPath &path, double time) :
	m_galaxy(GalaxyGenerator::Create()),
	m_time(time),
	m_state(STATE_NORMAL),
	m_wantHyperspace(false),
	m_timeAccel(TIMEACCEL_1X),
	m_requestedTimeAccel(TIMEACCEL_1X),
	m_forceTimeAccel(false)
{
	// Now that we have a Galaxy, check the starting location
	if (!path.IsBodyPath())
		throw InvalidGameStartLocation("SystemPath is not a body path");
	RefCountedPtr<const Sector> s = m_galaxy->GetSector(path);
	if (size_t(path.systemIndex) >= s->m_systems.size()) {
		char buf[128];
		std::sprintf(buf, "System %u in sector <%d,%d,%d> does not exist",
			unsigned(path.systemIndex), int(path.sectorX), int(path.sectorY), int(path.sectorZ));
		throw InvalidGameStartLocation(std::string(buf));
	}
	RefCountedPtr<StarSystem> sys = m_galaxy->GetStarSystem(path);
	if (path.bodyIndex >= sys->GetNumBodies()) {
		char buf[256];
		std::sprintf(buf, "Body %d in system <%d,%d,%d : %d ('%s')> does not exist", unsigned(path.bodyIndex),
			int(path.sectorX), int(path.sectorY), int(path.sectorZ), unsigned(path.systemIndex), sys->GetName().c_str());
		throw InvalidGameStartLocation(std::string(buf));
	}

	m_space.reset(new Space(this, m_galaxy, path));

	Body *b = m_space->FindBodyForPath(&path);
	assert(b);

	m_player.reset(new Player("kanara"));

	m_space->AddBody(m_player.get());

	m_player->SetFrame(b->GetFrame());

	if (b->GetType() == Object::SPACESTATION) {
		m_player->SetDockedWith(static_cast<SpaceStation*>(b), 0);
	} else {
		const SystemBody *sbody = b->GetSystemBody();
		m_player->SetPosition(vector3d(0, 1.5*sbody->GetRadius(), 0));
		m_player->SetVelocity(vector3d(0,0,0));
	}
	Polit::Init(m_galaxy);

	CreateViews();

	EmitPauseState(IsPaused());
}
开发者ID:ZeframCochrane,项目名称:pioneer,代码行数:51,代码来源:Game.cpp

示例10: Apply

bool SectorCustomSystemsGenerator::Apply(Random& rng, RefCountedPtr<Galaxy> galaxy, RefCountedPtr<Sector> sector, GalaxyGenerator::SectorConfig* config)
{
	PROFILE_SCOPED()

	const int sx = sector->sx;
	const int sy = sector->sy;
	const int sz = sector->sz;

	if ((sx >= -m_customOnlyRadius) && (sx <= m_customOnlyRadius-1) &&
		(sy >= -m_customOnlyRadius) && (sy <= m_customOnlyRadius-1) &&
		(sz >= -m_customOnlyRadius) && (sz <= m_customOnlyRadius-1))
		config->isCustomOnly = true;

	const std::vector<const CustomSystem*> &systems = galaxy->GetCustomSystems()->GetCustomSystemsForSector(sx, sy, sz);
	if (systems.size() == 0) return true;

	Uint32 sysIdx = 0;
	for (std::vector<const CustomSystem*>::const_iterator it = systems.begin(); it != systems.end(); ++it, ++sysIdx) {
		const CustomSystem *cs = *it;
		Sector::System s(sector.Get(), sx, sy, sz, sysIdx);
		s.m_pos = Sector::SIZE*cs->pos;
		s.m_name = cs->name;
		for (s.m_numStars=0; s.m_numStars<cs->numStars; s.m_numStars++) {
			if (cs->primaryType[s.m_numStars] == 0) break;
			s.m_starType[s.m_numStars] = cs->primaryType[s.m_numStars];
		}
		s.m_customSys = cs;
		s.m_seed = cs->seed;
		if (cs->want_rand_explored) {
			/*
			 * 0 - ~500ly from sol: explored
			 * ~500ly - ~700ly (65-90 sectors): gradual
			 * ~700ly+: unexplored
			 */
			int dist = isqrt(1 + sx*sx + sy*sy + sz*sz);
			if (((dist <= 90) && ( dist <= 65 || rng.Int32(dist) <= 40)) || galaxy->GetFactions()->IsHomeSystem(SystemPath(sx, sy, sz, sysIdx)))
				s.m_explored = StarSystem::eEXPLORED_AT_START;
			else
				s.m_explored = StarSystem::eUNEXPLORED;
		} else {
			if (cs->explored)
				s.m_explored = StarSystem::eEXPLORED_AT_START;
			else
				s.m_explored = StarSystem::eUNEXPLORED;
		}
		sector->m_systems.push_back(s);
	}
	return true;
}
开发者ID:Ikesters,项目名称:pioneer,代码行数:49,代码来源:SectorGenerator.cpp

示例11: Node

Label3D::Label3D(Graphics::Renderer *r, RefCountedPtr<Text::DistanceFieldFont> font)
: Node(r, NODE_SOLID) //appropriate for alpha testing
, m_font(font)
{
	Graphics::MaterialDescriptor matdesc;
	matdesc.textures = 1;
	matdesc.alphaTest = true;
	matdesc.lighting = true;
	m_geometry.Reset(font->CreateVertexArray());
	m_material.Reset(r->CreateMaterial(matdesc));
	m_material->texture0 = font->GetTexture();
	m_material->diffuse = Color::WHITE;
	m_material->emissive = Color(0.15f);
	m_material->specular = Color::WHITE;
}
开发者ID:Loki999,项目名称:pioneer,代码行数:15,代码来源:Label3D.cpp

示例12: l_sbody_attr_parent

/*
 * Attribute: parent
 *
 * The parent of the body, as a <SystemBody>. A body orbits its parent.
 *
 * Availability:
 *
 *   alpha 14
 *
 * Status:
 *
 *   stable
 */
static int l_sbody_attr_parent(lua_State *l)
{
	SystemBody *sbody = LuaObject<SystemBody>::CheckFromLua(1);

	// sbody->parent is 0 as it was cleared by the acquirer. we need to go
	// back to the starsystem proper to get what we need.
	RefCountedPtr<StarSystem> s = Pi::game->GetGalaxy()->GetStarSystem(sbody->GetPath());
	SystemBody *live_sbody = s->GetBodyByPath(sbody->GetPath());

	if (!live_sbody->GetParent())
		return 0;

	LuaObject<SystemBody>::PushToLua(live_sbody->GetParent());
	return 1;
}
开发者ID:irigi,项目名称:pioneer,代码行数:28,代码来源:LuaSystemBody.cpp

示例13: l_sbody_attr_parent

/*
 * Attribute: parent
 *
 * The parent of the body, as a <SystemBody>. A body orbits its parent.
 *
 * Availability:
 *
 *   alpha 14
 *
 * Status:
 *
 *   stable
 */
static int l_sbody_attr_parent(lua_State *l)
{
	SystemBody *sbody = LuaSystemBody::CheckFromLua(1);

	// sbody->parent is 0 as it was cleared by the acquirer. we need to go
	// back to the starsystem proper to get what we need.
	RefCountedPtr<StarSystem> s = StarSystem::GetCached(sbody->path);
	SystemBody *live_sbody = s->GetBodyByPath(sbody->path);

	if (!live_sbody->parent)
		return 0;

	LuaSystemBody::PushToLua(live_sbody->parent);
	return 1;
}
开发者ID:Metamartian,项目名称:pioneer,代码行数:28,代码来源:LuaSystemBody.cpp

示例14: UpdateIconSelections

void SystemInfoView::UpdateIconSelections()
{
	//navtarget can be only set in current system
	for (std::vector<std::pair<std::string, BodyIcon*> >::iterator it = m_bodyIcons.begin();
		 it != m_bodyIcons.end(); ++it) {
			 (*it).second->SetSelected(false);

		RefCountedPtr<StarSystem> currentSys = Pi::game->GetSpace()->GetStarSystem();
		if (currentSys && currentSys->GetPath() == m_system->GetPath() &&
			Pi::player->GetNavTarget() &&
			(*it).first == Pi::player->GetNavTarget()->GetLabel()) {

			(*it).second->SetSelected(true);
		}
	}
}
开发者ID:AaronSenese,项目名称:pioneer,代码行数:16,代码来源:SystemInfoView.cpp

示例15: CBLOGERR

/**
   take in a configuration xml document and a system 
   context and initialize the transport
*/
int 
RpcHttpClientTransport::init( 
    const DOMNode* config, 
    RefCountedPtr<SysContext>& ctx )
{
	REFCOUNTED_CAST(iSysComponent, StdLogger, ctx->getComponent( StdLogger::getRegistryName()), _logger);
    ASSERT_D(_logger != NULL);
	
    // parsing for proxy server
    if ( config->getNodeType() == DOMNode::ELEMENT_NODE )
    {
        const DOMElement* configElem = (const DOMElement*)config;
        // look for the listening port setting
        String val;
        Mapping attrs;

        DOMNodeList* nodes = DomUtils::getNodeList( configElem, RPC_PROXY_NAME );
        if ( DomUtils::getNodeValue( (const DOMElement*)nodes->item( 0 ), &val, &attrs ) )
        {
            Mapping::const_iterator it = attrs.find( RPC_PROXY_PORTATTR );
            if( it != attrs.end() )
            {
                _proxy = val;
                _proxyPort = StringUtils::toInt( (*it).second );
            }
            else
            {
                CBLOGERR(_logger,
                         NTEXT("RpcHttpClientTransport::init: can't find attributes to configure Proxy Port"));
            }
        }
    }

    return 0;
}
开发者ID:CSanchezAustin,项目名称:cslib,代码行数:39,代码来源:RpcHttpClientTransport.cpp


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