Ejemplo n.º 1
0
const CResourceDescription* CResourceHandler::GetResource(int resourceId) const
{
	if (IsValidId(resourceId))
		return &resources[resourceId];

	return NULL;
}
Ejemplo n.º 2
0
const CResource* CResourceHandler::GetResource(int resourceId) const
{
	if (IsValidId(resourceId)) {
		return &resources[resourceId];
	} else {
		return NULL;
	}
}
 FunctionInfo *
 JavascriptBuiltInFunction::GetFunctionInfo(Js::LocalFunctionId builtinId)
 {
     if (IsValidId(builtinId))
     {
         return builtInFunctionInfo[builtinId];
     }
     return nullptr;
 }
Ejemplo n.º 4
0
const CResourceMapAnalyzer* CResourceHandler::GetResourceMapAnalyzer(int resourceId) {

	if (!IsValidId(resourceId))
		return NULL;

	CResourceMapAnalyzer* rma = resourceMapAnalyzers[resourceId];

	if (rma == NULL) {
		rma = new CResourceMapAnalyzer(resourceId);
		resourceMapAnalyzers[resourceId] = rma;
	}

	return rma;
}
Ejemplo n.º 5
0
bool LocalAssetProvider::RequestAsset(const std::string& asset_id, const std::string& asset_type, request_tag_t tag)
{
    if (!IsValidId(asset_id, asset_type))
        return false;
    
    Foundation::ServiceManagerPtr service_manager = framework_->GetServiceManager();
    boost::shared_ptr<Foundation::AssetServiceInterface> asset_service =
        service_manager->GetService<Foundation::AssetServiceInterface>(Foundation::Service::ST_Asset).lock();
    if (!asset_service)
        return false;
    
    AssetModule::LogDebug("New local asset request: " + asset_id);
    
    // Strip file:
    std::string filepath = asset_dir_ + asset_id.substr(7);
    
    boost::filesystem::path file_path(filepath);
    std::ifstream filestr(file_path.native_directory_string().c_str(), std::ios::in | std::ios::binary);
    if (filestr.good())
    {
        filestr.seekg(0, std::ios::end);
        uint length = filestr.tellg();
        filestr.seekg(0, std::ios::beg);
        
        if (length > 0)
        {
            RexAsset* new_asset = new RexAsset(asset_id, asset_type);
            Foundation::AssetPtr asset_ptr(new_asset);
            
            RexAsset::AssetDataVector& data = new_asset->GetDataInternal();
            data.resize(length);
            filestr.read((char *)&data[0], length);
            filestr.close();
            
            // Store to cache
            asset_service->StoreAsset(asset_ptr);
            // Send asset_ready event as delayed
            Events::AssetReady* event_data = new Events::AssetReady(asset_ptr->GetId(), asset_ptr->GetType(), asset_ptr, tag);
            framework_->GetEventManager()->SendDelayedEvent(event_category_, Events::ASSET_READY, Foundation::EventDataPtr(event_data));
            
            return true;
        }
        else
            filestr.close();
    }
    
    AssetModule::LogInfo("Failed to load local asset " + asset_id.substr(7));
    return false;
}
Ejemplo n.º 6
0
bool UDPAssetProvider::RequestAsset(const std::string& asset_id, const std::string& asset_type, request_tag_t tag)
{
    if (!IsValidId(asset_id, asset_type))
        return false;

    RexUUID uuid(asset_id);
    if (uuid.IsNull())
        return false;

    // The UDP asset provider only understands the fixed set of asset types used in OpenSim. If the string type is something
    // else, we can't satisfy the request.
    asset_type_t asset_type_int = GetAssetTypeFromTypeName(asset_type);
    if (asset_type_int < 0)
        return false;

    AssetRequest new_request;
    new_request.asset_id_ = asset_id;
    new_request.asset_type_ = asset_type_int;
    new_request.tags_.push_back(tag);
    pending_requests_.push_back(new_request);

    return true;
}
Ejemplo n.º 7
0
static OtherLineInfoPtr s_ParseOtherLine (CharPtr lineStr)
{
  Char             ch;
  CharPtr          otherStr;
  Int4             otherPosition;
  Int4             position;
  Int2             state;
  Int4             wordCount;
  OtherLineInfoPtr otherLinePtr;

  /* Parse the line character by character */

  otherStr = (CharPtr) MemNew (StringLen(lineStr)+1);
  otherPosition = 0;
  state     = OTHER_PRE_DATA;
  wordCount = 0;

  for (position = 0; lineStr[position] != '\0'; position++)
    {
      ch = lineStr[position];

      switch (state)
	{
	case OTHER_PRE_DATA :
	  if (IS_WHITESP(ch))
	    continue;
	  else
	    {
	      wordCount = 1;
	      state = OTHER_DATA;
	      otherStr[otherPosition] = ch;
	      otherPosition++;
	    }
	  break;
	case OTHER_DATA : 
	  if (IS_WHITESP(ch))	
	    wordCount++;
	  otherStr[otherPosition] = ch;
	  otherPosition++;
	  break;
	default:
	  break;
	}
    }

  /* Check for blank line */
  
  if (state == OTHER_PRE_DATA)
    {
      MemFree(otherStr);
      return NULL;
    }
  
  /* If we made it to here, then */
  /* it's a valid definition line. */

  otherStr[otherPosition]   = '\0';

  otherLinePtr = (OtherLineInfoPtr) MemNew (sizeof (OtherLineInfo));
  if ((wordCount == 1) && IsValidId(otherStr))
    {
      otherLinePtr->id    = otherStr;
      otherLinePtr->other = NULL;
    }
  else
    {
      otherLinePtr->id    = NULL;
      otherLinePtr->other = otherStr;
    }

  /* Return successfully */

  return otherLinePtr;
}
Ejemplo n.º 8
0
static SeqLineInfoPtr s_ParseSequenceLine (CharPtr lineStr,
					   AliConfigInfoPtr configPtr)
{
  CharPtr        seqStr;
  Int4           seqPosition = 0;
  CharPtr        idStr;
  Int4           idPosition = 0;
  Int4           firstWordLen = 0;
  Char           ch;
  Int2           state = PRE_DATA;
  Int4           position;
  Boolean        firstWordNotSequence = FALSE;
  Boolean        sequenceFound = FALSE;
  CharPtr        tempStr;
  Boolean        corruptSequence = FALSE;
  SeqLineInfoPtr seqLinePtr;

  if (StringLen(lineStr) == 0)
    return NULL;

  seqStr = (CharPtr) MemNew (StringLen(lineStr)+1);
  idStr  = (CharPtr) MemNew (StringLen(lineStr)+1);

  for (position = 0; lineStr[position] != '\0'; position++)
    {
      ch = lineStr[position];

      switch (state)
	{
	case PRE_DATA :

	  /* If it's the first non-whitespace char */
	  /* then we've found our first word.      */

	  if (!IS_WHITESP(ch))
	    {
	      state = FIRST_WORD;
	      if (!IsSequenceChar(ch,
				  configPtr->gapChar,
				  configPtr->missingChar,
				  configPtr->unalignedChar))
		firstWordNotSequence = TRUE;
	      idStr[idPosition] = ch;
	      idPosition++;
	      firstWordLen++;
	    }
	  break;
	case FIRST_WORD :
	  if (IS_WHITESP(ch))
	    {
	      state = SEQUENCE_DATA;
	      if ((idPosition > 0)   &&
		  (firstWordNotSequence == FALSE))
		{
		  tempStr = seqStr;
		  seqStr  = idStr;
		  idStr   = tempStr;
		  seqPosition = idPosition;
		  idPosition  = 0;
		  sequenceFound = TRUE;
		}
	    }
	  else
	    {
	      /* If we find a non-sequence char in the */
	      /* first word then it might be an ID,    */
	      /* with the sequence following.          */
	      
	      if (!IsSequenceChar(ch,
				  configPtr->gapChar,
				  configPtr->missingChar,
				  configPtr->unalignedChar))
		firstWordNotSequence = TRUE;
	      idStr[idPosition] = ch;
	      idPosition++;
	      firstWordLen++;
	    }
	  break;
	case SEQUENCE_DATA :
	  if (IS_WHITESP(ch))
	    continue;
	    
	  /* If we're in a sequence, then a non-sequence */
	  /* char invalidates it, although we do allow   */
	  /* 'junk' at the end.                          */
	  
	  if (!IsSequenceChar(ch,
			      configPtr->gapChar,
			      configPtr->missingChar,
			      configPtr->unalignedChar))
	    {
	      if ((lineStr[position - 1] == ' ') && sequenceFound)
		state = EOL_JUNK;
	      else if ((corruptSequence == TRUE) ||
		       (s_MightBeCorruptSequence (seqPosition,
						  &(lineStr[position]),
						  configPtr)))
		{
		  seqStr[seqPosition] = ch;
		  seqPosition++;
		  sequenceFound = TRUE;
		  corruptSequence = TRUE;
		}
	      else
		{
		  MemFree(seqStr);
		  MemFree(idStr);
		  return NULL;
		}
	    }
	  else
	    {
	      seqStr[seqPosition] = ch;
	      seqPosition++;
	      sequenceFound = TRUE;
	    }
	  break;
	case EOL_JUNK :
	  if (IS_WHITESP(ch))
	    state = POST_JUNK;
	  break;
	case POST_JUNK :

	  /* Only one 'word' of junk allowed */

	  if (!IS_WHITESP(ch))
	    {
	      MemFree(seqStr);
	      MemFree(idStr);
	      return NULL;
	    }
	  break;
	}
    }

  /* Check for blank line */
  
  if (state == PRE_DATA)
    {
      MemFree(seqStr);
      MemFree(idStr);
      return NULL;
    }
  
  if (state == FIRST_WORD)
    {

      /* If there was just one word, and it isn't */
      /* a sequence string, then this isn't a     */
      /* sequence line.                           */
      
      if (firstWordNotSequence == TRUE)
	{
	  MemFree(seqStr);
	  MemFree(idStr);
	  return NULL;
	}
      
      /* If there was just one word, and it IS a sequence */
      /* then the idStr is actually the seqStr.           */
      
      else
	{
	  tempStr = seqStr;
	  seqStr  = idStr;
	  idStr   = tempStr;
	  seqPosition = idPosition;
	  idPosition  = 0;
	}
    }

  /* If still no sequence string, */
  /* then not a sequence line.    */

  if (StringLen(seqStr) == 0)
    {
      MemFree(seqStr);
      MemFree(idStr);
      return NULL;
    }

  /* Check to see if the ID is a valid one */

  idStr[idPosition]   = '\0';
  seqStr[seqPosition] = '\0';

  if ((idPosition > 0) &&
      (IsValidId (idStr) == FALSE) &&
      (IsNumString (idStr) == FALSE))
    {
      MemFree(idStr);
      MemFree(seqStr);
      return NULL;
    }

  /* If we made it to here, then */
  /* it's a valid sequence line. */

  seqLinePtr = (SeqLineInfoPtr) MemNew (sizeof (SeqLineInfo));

  seqLinePtr->firstWordLen = firstWordLen;

  if (StringLen (seqStr) != 0)
    seqLinePtr->sequence = seqStr;
  else
    {
      seqLinePtr->sequence = NULL;
      MemFree (seqStr);
    }

  if (StringLen (idStr) != 0)
    seqLinePtr->id = idStr;
  else
    {
      seqLinePtr->id = NULL;
      MemFree (idStr);
    }

  if (corruptSequence)
    seqLinePtr->maybe  = TRUE;
  else
    seqLinePtr->maybe  = FALSE;

  return seqLinePtr;
}
Ejemplo n.º 9
0
void Ali_ChangeRowToOther (ValNodePtr rowPtr)
{
  DefLineInfoPtr   defLinePtr;
  SeqLineInfoPtr   seqLinePtr;
  OtherLineInfoPtr otherLinePtr;

  /* Sequence line to Other Line */

  if (rowPtr->choice == ALI_SEQLINE)
    {
      otherLinePtr = (OtherLineInfoPtr) MemNew (sizeof(OtherLineInfo));
      seqLinePtr = (SeqLineInfoPtr) rowPtr->data.ptrvalue;

      if (seqLinePtr->junk != NULL)
	sprintf(seqLinePtr->sequence,"%s%s",seqLinePtr->sequence,
		seqLinePtr->junk);

      if ((seqLinePtr->sequence != NULL) && (seqLinePtr->id == NULL))
	{
	  if (IsValidId(seqLinePtr->sequence))
	    {
	      otherLinePtr->id    = seqLinePtr->sequence;
	      otherLinePtr->other = NULL;
	    }
	  else
	    {
	      otherLinePtr->id    = NULL;
	      otherLinePtr->other = seqLinePtr->sequence;
	    }
	}
      else
	{
	  otherLinePtr->other = seqLinePtr->sequence;
	  otherLinePtr->id    = seqLinePtr->id;
	}

      otherLinePtr->rowNum = seqLinePtr->rowNum;

      MemFree(seqLinePtr);
      rowPtr->data.ptrvalue = otherLinePtr;
      rowPtr->choice = ALI_OTHERLINE;
    }


  /* Definition line to Other line */

  else if (rowPtr->choice == ALI_DEFLINE)
    {
      otherLinePtr = (OtherLineInfoPtr) MemNew (sizeof(OtherLineInfo));
      defLinePtr = (DefLineInfoPtr) rowPtr->data.ptrvalue;

      otherLinePtr->other = defLinePtr->definitions;
      otherLinePtr->id    = defLinePtr->id;
      otherLinePtr->rowNum   = defLinePtr->rowNum;

      MemFree(defLinePtr);
      rowPtr->data.ptrvalue = otherLinePtr;
      rowPtr->choice = ALI_OTHERLINE;
    }

  /* Return successfully */

  return;
}
 bool
 JavascriptBuiltInFunction::CanChangeEntryPoint(Js::LocalFunctionId builtInId)
 {
     return IsValidId(builtInId);
 }