Beispiel #1
0
//-------------------------------------
//
//-------------------------------------
IEntity* EntityFactory::GetEntity( const rapidjson::Value* entityInfo, TError& error )
{
    if( !entityInfo->HasMember("Entity") || !entityInfo->HasMember("Params") ) 
    {
        error = ERROR;
        return NULL;
    }

    IEntity* newEntity = NULL;
    TEntity type = GetTypeByName( (*entityInfo)["Entity"].GetString() );
    const rapidjson::Value* param = &(*entityInfo)["Params"];

    switch (type)
	{
#define REG_ENTITY(val, name) \
		case E##val: \
		newEntity = NEW(val##Entity,(param)); \
		  break;
#include "../logic/ENTITY_TYPES.h"
#undef REG_ENTITY
		default:
            error = ERROR;
			break;
	}
   
    return newEntity;
}
Beispiel #2
0
nsresult
nsSchema::ResolveTypePlaceholder(nsIWebServiceErrorHandler* aErrorHandler, 
                                 nsISchemaType* aPlaceholder,
                                 nsISchemaType** aType)
{
  PRUint16 schemaType;

  aPlaceholder->GetSchemaType(&schemaType);
  if (schemaType == nsISchemaType::SCHEMA_TYPE_PLACEHOLDER) {
    nsAutoString name;
    aPlaceholder->GetName(name);
    
    nsresult rv = GetTypeByName(name, aType);
    if (NS_FAILED(rv) || !*aType) {
      *aType = nsnull;
      nsAutoString errorMsg;
      errorMsg.AppendLiteral("Failure resolving schema type, ");
      errorMsg.AppendLiteral("cannot resolve schema type place holder for \"");
      errorMsg.Append(name);
      errorMsg.AppendLiteral("\"");

      NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);

      return NS_ERROR_FAILURE;
    }
  }
  else {
    NS_ADDREF(*aType = aPlaceholder);
  }

  return NS_OK;
}
Beispiel #3
0
XnStatus TypeManager::RegisterNewType(const XnChar* strName, XnProductionNodeType baseType, XnProductionNodeType* pNewType)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	// we only need to lock when adding a new type
	XnAutoCSLocker locker(m_hLock);

	// check if type is already registered
	XnProductionNodeType type;
	if (XN_STATUS_OK == GetTypeByName(strName, &type))
	{
		*pNewType = type;
	}
	else
	{
		if (m_nNextExtendedNodeType >= XN_MAX_TYPES_COUNT)
		{
			XN_LOG_ERROR_RETURN(XN_STATUS_ERROR, XN_MASK_OPEN_NI, "OpenNI does not support more than %u types!", XN_MAX_TYPES_COUNT);
		}

		// add the new type
		nRetVal = AddNewType(strName, m_nNextExtendedNodeType, baseType);
		XN_IS_STATUS_OK(nRetVal);

		// take its type id
		*pNewType = m_nNextExtendedNodeType;

		// increment max type id
		++m_nNextExtendedNodeType;
	}
	
	return (XN_STATUS_OK);
}
Beispiel #4
0
IUnitType* CSpringGame::ToIUnitType(springai::UnitDef* def) {
    if(def) {
        std::string name = def->GetName();
        return GetTypeByName(name);
    } else {
        return NULL;
    }
}
Beispiel #5
0
bool CSTransform::TransformByString(std::string operation, std::string argument, bool concatenate)
{
	unsigned int numArgs;
	int type = GetTypeByName(operation, numArgs);

	if (type<0)
	{
		std::cerr << "CSTransform::TransformByString: Error, unknown transformation: \"" << operation << "\"" << std::endl;
		return false;
	}

	return TransformByType((TransformType)type, argument, concatenate);
}