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


C++ G_ASSERT函数代码示例

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


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

示例1: GAnimElement

// default constructor with owner
GAnimTRSNode2D::GAnimTRSNode2D(const GElement* Owner) : GAnimElement(Owner) {

	// gPivotPosition is automatically set to (0, 0)
	gPivotRotation = 0;
	gPivotScale.Set(1, 1);
	gFather = NULL;
	gCustomData = NULL;

	// add TRS properties
	GBool alreadyExists;
	GUInt32 index;

	GProperty *tmpProp = AddProperty("transform", G_PROPERTY_CLASSID, GKeyValue(), alreadyExists, index);
	if (tmpProp) {
		G_ASSERT(alreadyExists == G_FALSE);
		// default value for "x" and "y" sub-properties will be set automatically to 0
		tmpProp->AddProperty("position", G_TWOHERMITEPROPERTY1D_CLASSID, GKeyValue(), alreadyExists, index);
		G_ASSERT(alreadyExists == G_FALSE);
		tmpProp->AddProperty("rotation", G_HERMITEPROPERTY1D_CLASSID, GKeyValue((GReal)0), alreadyExists, index);
		G_ASSERT(alreadyExists == G_FALSE);
		// we must impose a default value of 1 to "x" and "y" sub-properties
		GProperty *p = tmpProp->AddProperty("scale", G_TWOHERMITEPROPERTY1D_CLASSID, GKeyValue(), alreadyExists, index);
		G_ASSERT(alreadyExists == G_FALSE);
		p->Property("x")->SetDefaultValue(GKeyValue((GReal)1));
		p->Property("y")->SetDefaultValue(GKeyValue((GReal)1));
	}
}
开发者ID:BackupTheBerlios,项目名称:amanith-svn,代码行数:28,代码来源:ganimtrsnode2d.cpp

示例2: Property

GError GAnimTRSNode2D::SetScale(const GTimeValue TimePos, const GVectBase<GReal, 2>& RelScale) {

	GError err;
	GProperty *tmpProp = Property("transform");

	// this can be the case of a curve not created through a kernel
	if (!tmpProp) {
		err = G_MISSING_KERNEL;
	}
	else {
		// extract position track
		GProperty *scaleProp = tmpProp->Property("scale");
		G_ASSERT(scaleProp);

		GKeyValue tmpValue;
		tmpValue.SetTimePosition(TimePos);

		// set "x" property
		tmpProp = scaleProp->Property("x");
		G_ASSERT(tmpProp != NULL);
		tmpValue.SetValue(RelScale[G_X]);
		err = tmpProp->SetValue(tmpValue, TimePos, G_ABSOLUTE_VALUE);
		if (err != G_NO_ERROR)
			return err;
		// set "y" property
		tmpProp = scaleProp->Property("y");
		G_ASSERT(tmpProp != NULL);
		tmpValue.SetValue(RelScale[G_Y]);
		err = tmpProp->SetValue(tmpValue, TimePos, G_ABSOLUTE_VALUE);
	}
	return err;
}
开发者ID:BackupTheBerlios,项目名称:amanith-svn,代码行数:32,代码来源:ganimtrsnode2d.cpp

示例3: G_ASSERT

// clone properties
GError GAnimElement::CloneProperties(const GAnimElement& Source) {

	const GProperty *srcProp;
	GProperty *tmpProp;
	GBool alreadyExists;
	GUInt32 i;
	GError err;

	G_ASSERT(this != &Source);

	GDynArray<GProperty *>::const_iterator it = Source.gProperties.begin();
	
	// clone every property
	for (; it != Source.gProperties.end(); ++it) {
		srcProp = *it;
		G_ASSERT(srcProp != NULL);

		tmpProp = AddProperty(srcProp->Name(), srcProp->ClassID(), GKeyValue(), alreadyExists, i);
		if (tmpProp) {
			// lets do copy
			err = tmpProp->CopyFrom(*srcProp);
			if (err != G_NO_ERROR)
				RemoveProperty(i);
		}
		else
			G_ASSERT(tmpProp != NULL);
	}
	return G_NO_ERROR;
}
开发者ID:BackupTheBerlios,项目名称:amanith-svn,代码行数:30,代码来源:gelement.cpp

示例4: G_ASSERT

void Label::setAttachPoint(int p_attachPoint)
{
	G_ASSERT(!((p_attachPoint & AP_LEFT) && (p_attachPoint & AP_RIGHT)) && "bad value");
	G_ASSERT(!((p_attachPoint & AP_TOP) && (p_attachPoint & AP_BOTTOM)) && "bad value");

	m_attachPoint = p_attachPoint;
}
开发者ID:bercik,项目名称:gear,代码行数:7,代码来源:Label.cpp

示例5: G_ASSERT

void ShaderImpl::begin(CL_GraphicContext &p_gc)
{
	G_ASSERT(m_initialized);
	G_ASSERT(!m_began);

	// new texture
	m_drawRect = m_parent->getDrawRect(m_boundRect);
	m_texture = CL_Texture(p_gc, m_drawRect.get_width(), m_drawRect.get_height());

	// attach frame buffer
	m_frameBuffer.attach_color_buffer(0, m_texture);
	p_gc.set_frame_buffer(m_frameBuffer);

	// clear to transparent
	p_gc.clear(CL_Colorf::transparent);

	// set proper matrix
	p_gc.push_modelview();

	// get scaling in count
	const CL_Mat4f &matrix = p_gc.get_modelview();
	const float scaleX = matrix[0];
	const float scaleY = matrix[5];

	p_gc.mult_translate(-m_drawRect.left / scaleX, -m_drawRect.top / scaleY);

	m_began = true;
}
开发者ID:genail,项目名称:gear,代码行数:28,代码来源:Shader.cpp

示例6: GLDisableShaders

void GOpenGLBoard::GrabFrameBuffer(const GAABox2& LogicBox, GLGrabbedRect& Shot) {

	GLDisableShaders();

	GReal left, right, bottom, top;
	Projection(left, right, bottom, top);

	if (LogicBox.Min()[G_X] > left)
		left = LogicBox.Min()[G_X];
	if (LogicBox.Max()[G_X] < right)
		right = LogicBox.Max()[G_X];
	if (LogicBox.Min()[G_Y] > bottom)
		bottom = LogicBox.Min()[G_Y];
	if (LogicBox.Max()[G_Y] < top)
		top = LogicBox.Max()[G_Y];

	GAABox2 tmpBox(GPoint2(left, bottom), GPoint2(right, top));

	GPoint<GInt32, 2> p0 = LogicalToPhysicalInt(tmpBox.Min());
	GPoint<GInt32, 2> p1 = LogicalToPhysicalInt(tmpBox.Max());
	p0[G_X] -= 1;
	p0[G_Y] -= 1;
	p1[G_X] += 1;
	p1[G_Y] += 1;
	GGenericAABox<GInt32, 2> intBox(p0, p1);

	GUInt32 width = (GUInt32)GMath::Abs(p1[G_X] - p0[G_X]);
	GUInt32 height = (GUInt32)GMath::Abs(p1[G_Y] - p0[G_Y]);

	glPixelStorei(GL_PACK_ALIGNMENT, 1);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

	UpdateGrabBuffer(width, height, Shot);

	G_ASSERT(Shot.TexName > 0);
	G_ASSERT(Shot.TexWidth > 0 && Shot.TexHeight > 0);
	G_ASSERT(Shot.TexWidth >= width && Shot.TexHeight >= height);

	SELECT_AND_DISABLE_TUNIT(1)
	SELECT_AND_DISABLE_TUNIT(0)
	glEnable(Shot.Target);
	glBindTexture(Shot.Target, Shot.TexName);
	glCopyTexSubImage2D(Shot.Target, 0, 0, 0, (GLint)intBox.Min()[G_X], (GLint)intBox.Min()[G_Y], (GLsizei)width, (GLsizei)height);

	Shot.Width = width;
	Shot.Height = height;
	Shot.IsEmpty = G_FALSE;

	Shot.gNotExpandedLogicBox = tmpBox;

	GPoint2 q0 = PhysicalToLogical(p0);
	GPoint2 q1 = PhysicalToLogical(p1);
	Shot.gExpandedLogicBox.SetMinMax(q0, q1);

	SELECT_AND_DISABLE_TUNIT(0)
	glPixelStorei(GL_PACK_ALIGNMENT, 4);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
}
开发者ID:BackupTheBerlios,项目名称:amanith-svn,代码行数:58,代码来源:gopenglgroups.cpp

示例7: Q_ASSERT_X

 /**
  * @brief Realization::clear
  */
 void Realization::clear()
 {
     Entity::SharedClass head = std::dynamic_pointer_cast<Entity::Class>(G_ASSERT(headClass()));
     Q_ASSERT_X(head, "Realization::clear", "head class not found or not Class");
     for (auto method : m_Methods) {
         head->removeMethods(method->name());
         G_ASSERT(tailClass())->removeMethods(method->name());
     }
 }
开发者ID:vt4a2h,项目名称:uml-tool,代码行数:12,代码来源:realization.cpp

示例8: G_ASSERT

void RaceScene::initializeOnline(const CL_String &p_hostname, int p_port)
{
	G_ASSERT(p_hostname.length() > 0);
	G_ASSERT(p_port > 0 && p_port <= 0xFFFF);

	if (!m_initialized) {
		m_logic = new Race::OnlineRaceLogic(p_hostname, p_port);
		initCommon();
	}

}
开发者ID:bercik,项目名称:gear,代码行数:11,代码来源:RaceScene.cpp

示例9: hm_watch_finalize

/*
 * Event source function - destructor of the source, called 
 *  before the source object destroyed. we decrease the reference
 *  count of ioc channel since the source object owes the count
 *  of it.
*/
static void
hm_watch_finalize(GSource *source)
{
    HmWatch *watch;
    G_ASSERT(source != NULL);

    g_atomic_int_add(&total_watch_count, -1);

    watch = (HmWatch*)source;

    hm_debug(
        "Net IO '%p' finalized. total %d left.",
        NET_IO(watch), g_atomic_int_get(&total_watch_count)
    );

    if (watch->funcs && watch->funcs->finalize)
    {
        (*watch->funcs->finalize)(watch);
    }

    hm_watch_destroy_private(watch->priv_data);
    watch->priv_data = NULL;

    if (watch->conn)    /* we need to flush the rest of data!!! */
    {
        hm_connection_close(watch->conn);
    }

    if (watch->buffer)
    {
        hm_net_buf_free(watch->buffer);
    }

    g_mutex_free(watch->lock);
}
开发者ID:dulton,项目名称:hm-platform,代码行数:41,代码来源:hm_watch.c

示例10: m_initialized

OnlineRaceLogic::OnlineRaceLogic(const CL_String &p_host, int p_port) :
	m_initialized(false),
	m_host(p_host),
	m_port(p_port),
	m_client(&Game::getInstance().getNetworkConnection()),
	m_localPlayer(Game::getInstance().getPlayer()),
	m_voteRunning(false)
{
	G_ASSERT(p_port > 0 && p_port <= 0xFFFF);

	m_client->setServerAddr(m_host);
	m_client->setServerPort(m_port);

	// connect signal and slots from player's car
	Car &car = m_localPlayer.getCar();

	m_slots.connect(car.sig_inputChanged(), this, &OnlineRaceLogic::onInputChange);

	// connect signals and slots from client
	m_slots.connect(m_client->sig_connected(),         this, &OnlineRaceLogic::onConnected);
	m_slots.connect(m_client->sig_disconnected(),      this, &OnlineRaceLogic::onDisconnected);
	m_slots.connect(m_client->sig_goodbyeReceived(),   this, &OnlineRaceLogic::onGoodbye);
	m_slots.connect(m_client->sig_playerJoined(),      this, &OnlineRaceLogic::onPlayerJoined);
	m_slots.connect(m_client->sig_playerLeaved(),      this, &OnlineRaceLogic::onPlayerLeaved);
	m_slots.connect(m_client->sig_gameStateReceived(), this, &OnlineRaceLogic::onGameState);
	m_slots.connect(m_client->sig_carStateReceived(),  this, &OnlineRaceLogic::onCarState);
	m_slots.connect(m_client->sig_raceStartReceived(), this, &OnlineRaceLogic::onRaceStart);
	m_slots.connect(m_client->sig_voteStarted(),       this, &OnlineRaceLogic::onVoteStarted);
	m_slots.connect(m_client->sig_voteEnded(),         this, &OnlineRaceLogic::onVoteEnded);
	m_slots.connect(m_client->sig_voteTickReceived(),  this, &OnlineRaceLogic::onVoteTick);
}
开发者ID:bercik,项目名称:gear,代码行数:31,代码来源:OnlineRaceLogic.cpp

示例11: getPlayer

void OnlineRaceLogic::onPlayerLeaved(const CL_String &p_name)
{
	// get the player
	Player &player = getPlayer(p_name);

	// remove from level
	getLevel().removeCar(&player.getCar());

	// remove from game
	removePlayer(player);

	TPlayerList::iterator itor;
	bool found = false;

	for (itor = m_remotePlayers.begin(); itor != m_remotePlayers.end(); ++itor) {

		if (reinterpret_cast<unsigned> (itor->get()) == reinterpret_cast<unsigned> (&player)) {
			m_remotePlayers.erase(itor);
			found = true;
			break;
		}
	}

	G_ASSERT(found);
	display(cl_format("Player %1 leaved", p_name));
}
开发者ID:bercik,项目名称:gear,代码行数:26,代码来源:OnlineRaceLogic.cpp

示例12: nmp_io_new

__export NmpIO *
nmp_io_new(NmpConnection *conn, NmpPacketProto *proto, 
	NmpIOFuncs *funcs, gsize size)
{
	NmpIO *io;
	G_ASSERT(conn != NULL && proto != NULL && funcs != NULL);

	if (nmp_connection_is_blocked(conn))
	{
		nmp_warning(
			"Net create io on blocked connection '%p'.",
			conn
		);
		return NULL;		
	}

	io = (NmpIO*)nmp_watch_create(
		conn, &nmp_io_watch_funcs, size);
	if (!io)
	{
		nmp_warning(
			"Net create watch failed."
		);
		return NULL;
	}

	nmp_io_initialize(io, 0);

	io->proto = proto;
	io->funcs = funcs;

	return io;
}
开发者ID:dulton,项目名称:nampu,代码行数:33,代码来源:nmp_share_io.c

示例13: hm_watch_unref

__export void
hm_watch_unref(HmWatch *watch)
{
    G_ASSERT(watch != NULL);

    g_source_unref((GSource*)watch);
}
开发者ID:dulton,项目名称:hm-platform,代码行数:7,代码来源:hm_watch.c

示例14: nmp_sysmsg_default_priv_des

static void
nmp_sysmsg_default_priv_des(gpointer priv, gsize size)
{
    G_ASSERT(priv != NULL);

    nmp_mem_kfree(priv, size);
}
开发者ID:dulton,项目名称:nampu,代码行数:7,代码来源:nmp_sysmsg.c

示例15: nmp_sysmsg_set_userdata

gint
nmp_sysmsg_set_userdata(NmpSysMsg *msg, gpointer data, gsize size)
{
	gpointer p;
	G_ASSERT(NMP_IS_SYSMSG(msg));

	if (data && size)
	{
		p = nmp_mem_kalloc(size);
		if (!p)
		{
			return -ENOMEM;
		}

		if (msg->user_data)
		{
			nmp_mem_kfree(msg->user_data, msg->user_size);
		}

		msg->user_data = p;
		msg->user_size = size;
		memcpy(msg->user_data, data, size);
		return 0;
	}

	return -EINVAL;
}
开发者ID:dulton,项目名称:nampu,代码行数:27,代码来源:nmp_sysmsg.c


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