Пример #1
0
void ImapActivityFactory::BuildScheduledSync(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId, int seconds, bool requireFair)
{
	MojErr err;

	ab.SetName( GetScheduledSyncName(accountId, folderId) );

	MojString desc;
	err = desc.format("Scheduled sync every %d minutes", seconds/60);
	ErrorToException(err);

	ab.SetDescription(desc.data());
	ab.SetExplicit(true);
	ab.SetPersist(true);
	ab.SetImmediate(true, "low");
	SetNetworkRequirements(ab, requireFair);

	// Metadata
	MojObject metadata;
	SetMetadata(metadata, SCHEDULED_SYNC_NAME, accountId, folderId);
	ab.SetMetadata(metadata);

	// Wakeup
	ab.SetSyncInterval(0, seconds);

	// Callback
	MojObject params;
	err = params.put("accountId", accountId);
	ErrorToException(err);

	ab.SetCallback(SCHEDULED_SYNC_CALLBACK, params);
}
CPLErr GDALMultiDomainMetadata::SetMetadataItem( const char *pszName,
                                                 const char *pszValue,
                                                 const char *pszDomain )

{
    if( pszDomain == NULL )
        pszDomain = "";

/* -------------------------------------------------------------------- */
/*      Create the domain if it does not already exist.                 */
/* -------------------------------------------------------------------- */
    int iDomain = CSLFindString( papszDomainList, pszDomain );

    if( iDomain == -1 )
    {
        SetMetadata( NULL, pszDomain );
        iDomain = CSLFindString( papszDomainList, pszDomain );
    }

/* -------------------------------------------------------------------- */
/*      Set the value in the domain list.                               */
/* -------------------------------------------------------------------- */
    papoMetadataLists[iDomain]->SetNameValue( pszName, pszValue );

    return CE_None;
}
Пример #3
0
void ImapActivityFactory::BuildPreferencesWatch(ActivityBuilder& ab, const MojObject& accountId, MojInt64 rev)
{
	MojErr err;

	ab.SetName( GetPreferencesWatchName(accountId) );
	ab.SetDescription("IMAP account preferences watch");
	ab.SetPersist(true);
	ab.SetForeground(true);

	// Metadata
	MojObject metadata;
	SetMetadata(metadata, PREFS_WATCH_NAME, accountId);
	ab.SetMetadata(metadata);

	MojDbQuery trigger;
	err = trigger.from(ImapAccountAdapter::SCHEMA);
	ErrorToException(err);
	err = trigger.where(ImapAccountAdapter::ACCOUNT_ID, MojDbQuery::OpEq, accountId);
	ErrorToException(err);
	err = trigger.where(ImapAccountAdapter::CONFIG_REV, MojDbQuery::OpGreaterThan, rev);
	ErrorToException(err);
	ab.SetDatabaseWatchTrigger(trigger);

	MojObject params;
	err = params.put("accountId", accountId);
	ErrorToException(err);

	ab.SetCallback(PREFS_WATCH_CALLBACK, params);
}
Пример #4
0
CPLErr VRTRasterBand::CopyCommonInfoFrom( GDALRasterBand * poSrcBand )

{
    SetMetadata( poSrcBand->GetMetadata() );
    const char* pszNBits = poSrcBand->GetMetadataItem("NBITS", "IMAGE_STRUCTURE");
    SetMetadataItem( "NBITS", pszNBits, "IMAGE_STRUCTURE" );
    const char* pszPixelType = poSrcBand->GetMetadataItem("PIXELTYPE", "IMAGE_STRUCTURE");
    SetMetadataItem( "PIXELTYPE", pszPixelType, "IMAGE_STRUCTURE" );
    SetColorTable( poSrcBand->GetColorTable() );
    SetColorInterpretation(poSrcBand->GetColorInterpretation());
    if( strlen(poSrcBand->GetDescription()) > 0 )
        SetDescription( poSrcBand->GetDescription() );

    int bSuccess;
    double dfNoData;
    dfNoData = poSrcBand->GetNoDataValue( &bSuccess );
    if( bSuccess )
        SetNoDataValue( dfNoData );

    SetOffset( poSrcBand->GetOffset() );
    SetScale( poSrcBand->GetScale() );
    SetCategoryNames( poSrcBand->GetCategoryNames() );
    if( !EQUAL(poSrcBand->GetUnitType(),"") )
        SetUnitType( poSrcBand->GetUnitType() );

    return CE_None;
}
Пример #5
0
void
UsdMayaAdaptor::UnapplySchemaByName(
    const TfToken& schemaName,
    MDGModifier& modifier)
{
    if (!*this) {
        TF_CODING_ERROR("Adaptor is not valid");
        return;
    }

    // Remove from schema list.
    TfTokenVector currentSchemas = GetAppliedSchemas();
    currentSchemas.erase(
            std::remove(
                currentSchemas.begin(), currentSchemas.end(), schemaName),
            currentSchemas.end());
    if (currentSchemas.empty()) {
        ClearMetadata(UsdTokens->apiSchemas, modifier);
    }
    else {
        SetMetadata(
                UsdTokens->apiSchemas,
                _GetListOpForTokenVector(currentSchemas),
                modifier);
    }
}
Пример #6
0
void ImapActivityFactory::BuildStartIdle(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId)
{
	MojErr err;

	ab.SetName( GetStartIdleName(accountId, folderId) );
	ab.SetDescription("Starts a push connection when the network is available");
	ab.SetExplicit(false);
	ab.SetPersist(true);
	ab.SetImmediate(true, "low");
	SetNetworkRequirements(ab, false);

	// Metadata
	MojObject metadata;
	SetMetadata(metadata, MAINTAIN_IDLE_NAME, accountId, folderId);
	ab.SetMetadata(metadata);

	// Callback
	MojObject params;
	err = params.put("accountId", accountId);
	ErrorToException(err);
	err = params.put("folderId", folderId);
	ErrorToException(err);

	ab.SetCallback(MAINTAIN_IDLE_CALLBACK, params);
}
Пример #7
0
void CAlbumFolder::SetCollection(SHA1* pSHA1, CCollectionFile* pCollection)
{
	m_bCollSHA1 = TRUE;
	m_pCollSHA1 = *pSHA1;
	m_sBestView.Empty();

	if ( m_pCollection != NULL )
	{
		delete m_pCollection;
		m_pCollection = NULL;
	}

	if ( CXMLElement* pMetadata = pCollection->GetMetadata() )
	{
		pMetadata = pMetadata->Clone();
		SetMetadata( pMetadata );
		delete pMetadata;
	}

	for ( POSITION pos = LibraryMaps.GetFileIterator() ; pos ; )
	{
		CLibraryFile* pFile = LibraryMaps.GetNextFile( pos );

		if ( pFile->IsAvailable() )
		{
			if ( m_pCollSHA1 == pFile->m_pSHA1 ||
				 pCollection->FindFile( pFile, TRUE ) ) AddFile( pFile );
		}
	}

	m_nUpdateCookie++;
	Library.m_nUpdateCookie++;
}
Пример #8
0
void putObject(ClientPtrType client, String bucketName, String key, String path, Map metadata, size_t loop)
{
    String base = "=== Put Object [" + bucketName + "/" + key;
    std::cout << base << "]: Start ===\n";
    std::cout << "Reading from " << path << "\n";
    auto inpData = Aws::MakeShared<Aws::FStream>("PutObjectInputStream",
            path.c_str(), std::ios_base::in | std::ios_base::binary);
    auto objReq = Aws::S3::Model::PutObjectRequest();
    objReq.WithBucket(bucketName).SetBody(inpData);;
    if (!metadata.empty())
    {
        std::cout << "Map Key\t:\t\tValue\n";
        for(auto& it: metadata)
        {
            auto key = it.first;
            auto value = it.second;
            std::cout << key << "\t:\t\t" << value << "\n";
        }
        objReq.SetMetadata(metadata);
    }
    if (loop == 0)
    {
        auto objRes = client->PutObject(objReq.WithKey(key));
        if (!objRes.IsSuccess())
        {
            std::cout << base << "]: Client Side failure ===\n";
            std::cout << objRes.GetError().GetExceptionName() << "\t" <<
                        objRes.GetError().GetMessage() << "\n";
        }
        if (!std::get<0>(doesObjectExists(client, bucketName, key)))
        {
            std::cout << base << "]: Failed ===\n";
        }
    }
    for (size_t i = 0; i < loop; ++i)
    {
        auto inpData = Aws::MakeShared<Aws::FStream>("PutObjectInputStream",
                path.c_str(), std::ios_base::in | std::ios_base::binary);
        objReq.SetBody(inpData);;
        String key_suffix = std::to_string(i).c_str();
        auto objRes = client->PutObject(objReq.WithKey(key + key_suffix));
        if (!objRes.IsSuccess())
        {
            std::cout << base << key_suffix << "]: Client Side failure ===\n";
            std::cout << objRes.GetError().GetExceptionName() << "\t" <<
                        objRes.GetError().GetMessage() << "\n";
        }
        if (!std::get<0>(doesObjectExists(client, bucketName, key + key_suffix)))
        {
            std::cout << base << key_suffix << "]: Failed ===\n";
        }
    }
    std::cout << base << "]: End ===\n\n";
}
Пример #9
0
HDF5ImageRasterBand::HDF5ImageRasterBand( HDF5ImageDataset *poDS, int nBand,
                                          GDALDataType eType )

{
    char          **papszMetaGlobal;
    this->poDS    = poDS;
    this->nBand   = nBand;
    eDataType     = eType;
    bNoDataSet    = FALSE;
    dfNoDataValue = -9999;
    nBlockXSize   = poDS->GetRasterXSize( );
    nBlockYSize   = 1;

/* -------------------------------------------------------------------- */
/*      Take a copy of Global Metadata since  I can't pass Raster       */
/*      variable to Iterate function.                                   */
/* -------------------------------------------------------------------- */
    papszMetaGlobal = CSLDuplicate( poDS->papszMetadata );
    CSLDestroy( poDS->papszMetadata );
    poDS->papszMetadata = NULL;

    if( poDS->poH5Objects->nType == H5G_DATASET ) {
        poDS->CreateMetadata( poDS->poH5Objects, H5G_DATASET );
    }

/* -------------------------------------------------------------------- */
/*      Recover Global Metadat and set Band Metadata                    */
/* -------------------------------------------------------------------- */

    SetMetadata( poDS->papszMetadata );

    CSLDestroy( poDS->papszMetadata );
    poDS->papszMetadata = CSLDuplicate( papszMetaGlobal );
    CSLDestroy( papszMetaGlobal );

    /* check for chunksize and set it as the blocksize (optimizes read) */
    hid_t listid = H5Dget_create_plist(((HDF5ImageDataset * )poDS)->dataset_id);
    if (listid>0)
    {
        if(H5Pget_layout(listid) == H5D_CHUNKED)
        {
            hsize_t panChunkDims[3];
            int nDimSize = H5Pget_chunk(listid, 3, panChunkDims);
            nBlockXSize   = (int) panChunkDims[nDimSize-1];
            nBlockYSize   = (int) panChunkDims[nDimSize-2];
        }
        H5Pclose(listid);
    }

}
Пример #10
0
HDF5ImageRasterBand::HDF5ImageRasterBand( HDF5ImageDataset *poDSIn, int nBandIn,
                                          GDALDataType eType ) :
    bNoDataSet(false),
    dfNoDataValue(-9999.0)
{
    poDS = poDSIn;
    nBand = nBandIn;
    eDataType     = eType;
    nBlockXSize   = poDS->GetRasterXSize( );
    nBlockYSize   = 1;

/* -------------------------------------------------------------------- */
/*      Take a copy of Global Metadata since  I can't pass Raster       */
/*      variable to Iterate function.                                   */
/* -------------------------------------------------------------------- */
    char **papszMetaGlobal = CSLDuplicate( poDSIn->papszMetadata );
    CSLDestroy( poDSIn->papszMetadata );
    poDSIn->papszMetadata = NULL;

    if( poDSIn->poH5Objects->nType == H5G_DATASET ) {
        poDSIn->CreateMetadata( poDSIn->poH5Objects, H5G_DATASET );
    }

/* -------------------------------------------------------------------- */
/*      Recover Global Metadata and set Band Metadata                   */
/* -------------------------------------------------------------------- */

    SetMetadata( poDSIn->papszMetadata );

    CSLDestroy( poDSIn->papszMetadata );
    poDSIn->papszMetadata = CSLDuplicate( papszMetaGlobal );
    CSLDestroy( papszMetaGlobal );

    /* check for chunksize and set it as the blocksize (optimizes read) */
    const hid_t listid = H5Dget_create_plist(poDSIn->dataset_id);
    if (listid>0)
    {
        if(H5Pget_layout(listid) == H5D_CHUNKED)
        {
            hsize_t panChunkDims[3] = {0, 0, 0};
            const int nDimSize = H5Pget_chunk(listid, 3, panChunkDims);
            CPL_IGNORE_RET_VAL(nDimSize);
            CPLAssert(nDimSize == poDSIn->ndims);
            nBlockXSize   = (int) panChunkDims[poDSIn->GetXIndex()];
            nBlockYSize   = (int) panChunkDims[poDSIn->GetYIndex()];
        }

        H5Pclose(listid);
    }
}
Пример #11
0
UsdMayaAdaptor::SchemaAdaptor
UsdMayaAdaptor::ApplySchemaByName(
    const TfToken& schemaName,
    MDGModifier& modifier)
{
    if (!*this) {
        TF_CODING_ERROR("Adaptor is not valid");
        return SchemaAdaptor();
    }

    // Get the schema's TfType; its name should be registered as an alias.
    const TfType schemaType =
            TfType::Find<UsdSchemaBase>().FindDerivedByName(schemaName);

    // Make sure that this is an API schema. Only API schemas can be applied.
    if (!schemaType.IsA<UsdAPISchemaBase>()) {
        TF_CODING_ERROR("'%s' is not a registered API schema",
                schemaName.GetText());
        return SchemaAdaptor();
    }

    // Make sure that this is an "apply" schema.
    if (!UsdSchemaRegistry::GetInstance().IsAppliedAPISchema(schemaType)) {
        TF_CODING_ERROR("'%s' is not an applied API schema",
                schemaName.GetText());
        return SchemaAdaptor();
    }

    // Get the schema definition. If it's registered, there should be a def.
    SdfPrimSpecHandle primDef =
            UsdSchemaRegistry::GetInstance().GetPrimDefinition(schemaName);
    if (!primDef) {
        TF_CODING_ERROR("Can't find schema definition for name '%s'",
                schemaName.GetText());
        return SchemaAdaptor();
    }

    // Add to schema list (if not yet present).
    TfTokenVector currentSchemas = GetAppliedSchemas();
    if (std::find(currentSchemas.begin(), currentSchemas.end(), schemaName) ==
            currentSchemas.end()) {
        currentSchemas.push_back(schemaName);
        SetMetadata(
                UsdTokens->apiSchemas,
                _GetListOpForTokenVector(currentSchemas),
                modifier);
    }

    return SchemaAdaptor(_handle.object(), primDef);
}
Пример #12
0
void ImapActivityFactory::BuildSyncRetry(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId, int seconds, const std::string& reason)
{
	MojErr err;

	ab.SetName( GetSyncRetryName(accountId, folderId) );

	MojString desc;
	err = desc.format("Retry sync after %d seconds", seconds);
	ErrorToException(err);

	ab.SetDescription(desc.data());
	ab.SetExplicit(true);
	ab.SetPersist(true);
	ab.SetImmediate(true, "low");
	SetNetworkRequirements(ab, seconds <= 5 * 60);

	// Metadata
	MojObject metadata;
	SetMetadata(metadata, SYNC_RETRY_NAME, accountId, folderId);
	ab.SetMetadata(metadata);

	// Wakeup
	ab.SetSyncInterval(seconds, 0);

	// Callback
	MojObject params;
	err = params.put("accountId", accountId);
	ErrorToException(err);
	err = params.put("folderId", folderId);
	ErrorToException(err);

	MojObject retry;
	if(!reason.empty()) {
		err = retry.putString("reason", reason.c_str());
		ErrorToException(err);
	}

	err = retry.put("interval", seconds);
	ErrorToException(err);

	err = params.put("retry", retry);
	ErrorToException(err);

	ab.SetCallback(SYNC_RETRY_CALLBACK, params);
}
Пример #13
0
GpxRootElement::GpxRootElement(const wxString &creator, GpxMetadataElement *metadata, ListOfGpxWpts *waypoints, ListOfGpxRoutes *routes, ListOfGpxTracks *tracks, GpxExtensionsElement *extensions) : TiXmlElement("gpx")
{
      my_extensions = NULL;
      my_metadata = NULL;
      first_waypoint = NULL;
      last_waypoint = NULL;
      first_route = NULL;
      last_route = NULL;
      first_track = NULL;
      last_track = NULL;

      SetAttribute ( "version", "1.1" );
      SetAttribute ( "creator", creator.ToUTF8() );
      SetAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
      SetAttribute( "xmlns", "http://www.topografix.com/GPX/1/1" );
      SetAttribute( "xmlns:gpxx", "http://www.garmin.com/xmlschemas/GpxExtensions/v3" );
      SetAttribute( "xsi:schemaLocation", "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" );
      SetMetadata(metadata);
      if (waypoints) {
            wxListOfGpxWptsNode *waypoint = waypoints->GetFirst();
            while (waypoint)
            {
                  AddWaypoint(waypoint->GetData());
                  waypoint = waypoint->GetNext();
            }
      }
      if (routes) {
            wxListOfGpxRoutesNode *route = routes->GetFirst();
            while (route)
            {
                  AddRoute(route->GetData());
                  route = route->GetNext();
            }
      }
      if (tracks) {
            wxListOfGpxTracksNode *track = tracks->GetFirst();
            while (track)
            {
                  AddTrack(track->GetData());
                  track = track->GetNext();
            }
      }
      SetExtensions(extensions);
}
Пример #14
0
bool ExportFFmpeg::AddTags(const Tags *tags)
{
   if (tags == NULL)
   {
      return false;
   }

   SetMetadata(tags, "author", TAG_ARTIST);
   SetMetadata(tags, "album", TAG_ALBUM);
   SetMetadata(tags, "comment", TAG_COMMENTS);
   SetMetadata(tags, "genre", TAG_GENRE);
   SetMetadata(tags, "title", TAG_TITLE);
   SetMetadata(tags, "year", TAG_YEAR);
   SetMetadata(tags, "track", TAG_TRACK);

   return true;
}
Пример #15
0
void GIFAbstractDataset::CollectXMPMetadata()

{
    if (fp == nullptr || bHasReadXMPMetadata)
        return;

    CPLString osXMP = GIFCollectXMPMetadata(fp);
    if (!osXMP.empty() )
    {
        /* Avoid setting the PAM dirty bit just for that */
        int nOldPamFlags = nPamFlags;

        char *apszMDList[2];
        apszMDList[0] = (char*) osXMP.c_str();
        apszMDList[1] = nullptr;
        SetMetadata(apszMDList, "xml:XMP");

        nPamFlags = nOldPamFlags;
    }

    bHasReadXMPMetadata = TRUE;
}
Пример #16
0
void ImapActivityFactory::BuildDraftsWatch(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId, MojInt64 rev)
{
	MojErr err;

	ab.SetName( GetDraftsWatchName(accountId, folderId) );
	ab.SetDescription("Watches for updates to draft emails");
	ab.SetPersist(true);
	ab.SetExplicit(true);
	ab.SetForeground(true);

	// Metadata
	MojObject metadata;
	SetMetadata(metadata, DRAFTS_WATCH_NAME, accountId, folderId);
	ab.SetMetadata(metadata);

	MojDbQuery query;

	err = query.from(EmailSchema::Kind::EMAIL);
	ErrorToException(err);
	err = query.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, folderId);
	ErrorToException(err);

	MojString editedDraftFlag;
	editedDraftFlag.format("%s.%s", EmailSchema::FLAGS, EmailSchema::Flags::EDITEDDRAFT);
	err = query.where(editedDraftFlag.data(), MojDbQuery::OpEq, true);
	ErrorToException(err);

	ab.SetDatabaseWatchTrigger(query);

	// Callback
	MojObject callbackParams;
	err = callbackParams.put("accountId", accountId);
	ErrorToException(err);
	err = callbackParams.put("folderId", accountId);
	ErrorToException(err);

	ab.SetCallback(DRAFTS_WATCH_CALLBACK, callbackParams);
}
Пример #17
0
void ImapActivityFactory::BuildFolderWatch(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId, MojInt64 rev)
{
	MojErr err;
	MojDbQuery query;

	ab.SetName( GetFolderWatchName(accountId, folderId) );
	ab.SetDescription("Watches for updates to emails");
	ab.SetExplicit(true);
	ab.SetPersist(true);
	SetNetworkRequirements(ab, true);
	ab.SetImmediate(true, "low");

	// Metadata
	MojObject metadata;
	SetMetadata(metadata, FOLDER_WATCH_NAME, accountId, folderId);
	ab.SetMetadata(metadata);

	// Query
	err = query.from(ImapEmailAdapter::IMAP_EMAIL_KIND);
	ErrorToException(err);
	err = query.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, folderId);
	ErrorToException(err);
	err = query.where(ImapEmailAdapter::UPSYNC_REV, MojDbQuery::OpGreaterThan, rev);
	ErrorToException(err);
	err = query.includeDeleted(true);
	ErrorToException(err);

	ab.SetDatabaseWatchTrigger(query);

	// Callback
	MojObject callbackParams;
	err = callbackParams.put("accountId", accountId);
	ErrorToException(err);
	err = callbackParams.put("folderId", folderId);
	ErrorToException(err);

	ab.SetCallback(FOLDER_WATCH_CALLBACK, callbackParams);
}
Пример #18
0
CPLErr VRTRasterBand::CopyCommonInfoFrom( GDALRasterBand * poSrcBand )

{
    int bSuccess;
    double dfNoData;

    SetMetadata( poSrcBand->GetMetadata() );
    SetColorTable( poSrcBand->GetColorTable() );
    SetColorInterpretation(poSrcBand->GetColorInterpretation());
    if( strlen(poSrcBand->GetDescription()) > 0 )
        SetDescription( poSrcBand->GetDescription() );
    dfNoData = poSrcBand->GetNoDataValue( &bSuccess );
    if( bSuccess )
        SetNoDataValue( dfNoData );

    SetOffset( poSrcBand->GetOffset() );
    SetScale( poSrcBand->GetScale() );
    SetCategoryNames( poSrcBand->GetCategoryNames() );
    if( !EQUAL(poSrcBand->GetUnitType(),"") )
        SetUnitType( poSrcBand->GetUnitType() );

    return CE_None;
}
Пример #19
0
void ImapActivityFactory::BuildOutboxWatch(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId, MojInt64 rev)
{
	MojErr err;

	ab.SetName( GetOutboxWatchName(accountId, folderId) );
	ab.SetDescription("Watches for sent emails in outbox");
	ab.SetPersist(true);
	ab.SetExplicit(true);
	ab.SetForeground(true);

	// Metadata
	MojObject metadata;
	SetMetadata(metadata, OUTBOX_WATCH_NAME, accountId, folderId);
	ab.SetMetadata(metadata);

	MojDbQuery query;

	err = query.from(EmailSchema::Kind::EMAIL);
	ErrorToException(err);
	err = query.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, folderId);
	ErrorToException(err);

	// sendStatus.sent
	MojString sentProp;
	sentProp.format("%s.%s",EmailSchema::SEND_STATUS, EmailSchema::SendStatus::SENT);
	err = query.where(sentProp.data(), MojDbQuery::OpEq, true);
	ErrorToException(err);

	ab.SetDatabaseWatchTrigger(query);

	// Callback
	MojObject callbackParams;
	err = callbackParams.put("accountId", accountId);
	ErrorToException(err);

	ab.SetCallback(OUTBOX_WATCH_CALLBACK, callbackParams);
}
Пример #20
0
bool
UsdProperty::SetDisplayGroup(const std::string& displayGroup) const
{
    return SetMetadata(SdfFieldKeys->DisplayGroup, displayGroup);
}
Пример #21
0
bool
UsdProperty::SetCustom(bool isCustom) const
{
    return SetMetadata(SdfFieldKeys->Custom, isCustom);
}
Пример #22
0
bool
UsdProperty::SetDisplayName(const std::string& newDisplayName) const
{
    return SetMetadata(SdfFieldKeys->DisplayName, newDisplayName);
}
/****************************************************************************************************
 * @fn      FormatSensorDataPacket
 *          Using the sensor sample data, this function creates the HIF Sensor Data Packet for
 *          sending to Host in the buffer provided.
 *
 * @param   [OUT]pDestPacket - Destination buffer supplied by the caller. This buffer size must be at least
 *                  sizeof(HifSensorDataRaw_t) in length
 * @param   [IN]pSrc - Data structure carrying the sensor sample (typically from driver)
 * @param   [IN]sensorPacketType - Sensor Packet type ID corresponding to members in the type union
 * @param   [IN]metaData - Meta data for the sensor type used (not applicable for all sensor types)
 * @param   [IN]sType - Sensor Type for the sensor data presented
 * @param   [IN]subType - Sub type for the sensor type used (not applicable for all sensor types)
 *
 * @return  Size of the formatted packet or -Error code enum corresponding to the error encountered
 *
 ***************************************************************************************************/
int32_t FormatSensorDataPacket( HostIFPackets_t *pDestPacket, const uint8_t *pSrc,
    uint8_t sensorPacketType, uint8_t metaData,
    ASensorType_t sType, uint8_t subType )
{
    const SensorPktDesc_t *pSPD = &(sensorPacketDescriptions[sensorPacketType]);
    uint8_t *pDest = (uint8_t *) pDestPacket;
    uint8_t tsSize, elemSize;
    uint32_t i, j;           // i = dest index, j = src index.

    /* Sanity checks... */
    if (pDest == NULL || pSrc == NULL)
    {
        return SET_ERROR( OSP_STATUS_NULL_POINTER );
    }

    /* clear header before setting bits in it */
    pDestPacket->GenericControlPkt.Q.ControlByte    = 0;
    pDestPacket->GenericControlPkt.Q.SensorIdByte   = 0;
    pDestPacket->GenericControlPkt.Q.AttributeByte  = 0;

    /* Set Sensor enumeration type Android or User defined */
    if ( IsPrivateNotAndroid( sType ) )
    {
        SetPrivateField( &(pDestPacket->GenericControlPkt.Q.ControlByte) );
    }

    /* Setup Control Byte */
    SetPacketID( pDest, PKID_SENSOR_DATA );
    SetDataFormatSensor( pDest, pSPD->DataFormat );
    SetTimeFormatSensor( pDest, pSPD->TimeFormat );

    /* Setup Sensor ID Byte */
    SetMetadata( pDest, metaData );
    SetSensorTypeField( pDest, sType );

    /* Setup Attribute Byte */
    SetSensorSubType( pDest, subType );
    SetSensorDataDataSize( pDest, pSPD->DataSz );
    SetSensorDataTimeStampSize( pDest, pSPD->TStampSz );

    i = PKT_TIMESTAMP_OFFSET;           //  offset of timestamp in destination packet
    j = LOCAL_PACKET_TIMESTAMP_OFFSET;  //  offset of timestamp in source packet

    /* Copy timestamp */
    tsSize = (pSPD->TStampSz == TIME_STAMP_32_BIT ? sizeof(int32_t) : sizeof(int64_t));

    /* NOTE: TODO-BUGFIX - The logic below will fail for BE machine for 32-bit timestamp as it
       will copy the higher 32-bit of the 64-bit TS */
    SwapEndian(pDest + i, pSrc + j, tsSize);
    i += tsSize;           // dest packet TS 32 or 64 bits.
    j += sizeof(int64_t);  // src packet TS 64 bits, or TS 32 + spare 32.

    /* Copy payload */
    elemSize = pSPD->ElementSz;

    if (elemSize != 0)
    {
        /* Data bytes */
        uint16_t nElem = pSPD->NumElements;
        uint16_t nBytesToCopy;

        if ( SENSOR_DOUBLE_PAYLOAD_SIZE_FOR_METADATA( sensorPacketType, metaData ) )
        {
            /* Special handling for SENSOR_DATA_UNCALIBRATED_FIXP packet */
            /* Check if metadata is available  if it is available then add it to HIF packet */
            /* Add it by doubling the payload size before endian swap/copy. */

            nElem *= 2;  // double the payload size by doubling the number of elements.
        }

        nBytesToCopy = nElem * elemSize;

        if (pSPD->IsBigEndian)
        {
            SwapEndianX( pDest + i, pSrc + j, elemSize, nElem );
        }
        else
        {
            SH_MEMCPY( pDest + i, pSrc + j, nBytesToCopy );
        }

        i += nBytesToCopy;
    }

    /*  set CRC flag and append CRC, if indicated  */
    if (FORMAT_WITH_CRC_ENABLED)
    {
        i += CRC_SIZE;
        FormatPacketCRC( pDestPacket, i );
    }

    return i;
}
Пример #24
0
int GDALMultiDomainMetadata::XMLInit( CPLXMLNode *psTree, CPL_UNUSED int bMerge )
{
    CPLXMLNode *psMetadata;

/* ==================================================================== */
/*      Process all <Metadata> elements, each for one domain.           */
/* ==================================================================== */
    for( psMetadata = psTree->psChild; 
         psMetadata != NULL; psMetadata = psMetadata->psNext )
    {
        CPLXMLNode *psMDI;
        const char *pszDomain, *pszFormat;

        if( psMetadata->eType != CXT_Element
            || !EQUAL(psMetadata->pszValue,"Metadata") )
            continue;

        pszDomain = CPLGetXMLValue( psMetadata, "domain", "" );
        pszFormat = CPLGetXMLValue( psMetadata, "format", "" );

        // Make sure we have a CPLStringList for this domain, 
        // without wiping out an existing one.
        if( GetMetadata( pszDomain ) == NULL )  
            SetMetadata( NULL, pszDomain );

        int iDomain = CSLFindString( papszDomainList, pszDomain );
        CPLAssert( iDomain != -1 );
        
        CPLStringList *poMDList = papoMetadataLists[iDomain];

/* -------------------------------------------------------------------- */
/*      XML format subdocuments.                                        */
/* -------------------------------------------------------------------- */
        if( EQUAL(pszFormat,"xml") )
        {
            CPLXMLNode *psSubDoc;

            /* find first non-attribute child of current element */
            psSubDoc = psMetadata->psChild;
            while( psSubDoc != NULL && psSubDoc->eType == CXT_Attribute )
                psSubDoc = psSubDoc->psNext;
            
            char *pszDoc = CPLSerializeXMLTree( psSubDoc );

            poMDList->Clear();
            poMDList->AddStringDirectly( pszDoc );
        }

/* -------------------------------------------------------------------- */
/*      Name value format.                                              */
/*      <MDI key="...">value_Text</MDI>                                 */
/* -------------------------------------------------------------------- */
        else
        {
            for( psMDI = psMetadata->psChild; psMDI != NULL;
                 psMDI = psMDI->psNext )
            {
                if( !EQUAL(psMDI->pszValue,"MDI")
                    || psMDI->eType != CXT_Element
                    || psMDI->psChild == NULL
                    || psMDI->psChild->psNext == NULL
                    || psMDI->psChild->eType != CXT_Attribute
                    || psMDI->psChild->psChild == NULL )
                    continue;

                char* pszName = psMDI->psChild->psChild->pszValue;
                char* pszValue = psMDI->psChild->psNext->pszValue;
                if( pszName != NULL && pszValue != NULL )
                    poMDList->SetNameValue( pszName, pszValue );
            }
        }
    }

    return CSLCount(papszDomainList) != 0;
}
Пример #25
0
void
UsdPrim::SetPropertyOrder(const TfTokenVector &order) const
{
    SetMetadata(SdfFieldKeys->PropertyOrder, order);
}
Пример #26
0
CPLErr GDALPamRasterBand::CloneInfo( GDALRasterBand *poSrcBand, 
                                     int nCloneFlags )

{
    int bOnlyIfMissing = nCloneFlags & GCIF_ONLY_IF_MISSING;
    int bSuccess;
    int nSavedMOFlags = GetMOFlags();

    PamInitialize();

/* -------------------------------------------------------------------- */
/*      Supress NotImplemented error messages - mainly needed if PAM    */
/*      disabled.                                                       */
/* -------------------------------------------------------------------- */
    SetMOFlags( nSavedMOFlags | GMO_IGNORE_UNIMPLEMENTED );

/* -------------------------------------------------------------------- */
/*      Metadata                                                        */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_BAND_METADATA )
    {
        if( poSrcBand->GetMetadata() != NULL )
        {
            if( !bOnlyIfMissing 
             || CSLCount(GetMetadata()) != CSLCount(poSrcBand->GetMetadata()) )
            {
                SetMetadata( poSrcBand->GetMetadata() );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Band description.                                               */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_BAND_DESCRIPTION )
    {
        if( strlen(poSrcBand->GetDescription()) > 0 )
        {
            if( !bOnlyIfMissing || strlen(GetDescription()) == 0 )
                GDALPamRasterBand::SetDescription( poSrcBand->GetDescription());
        }
    }

/* -------------------------------------------------------------------- */
/*      NODATA                                                          */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_NODATA )
    {
        double dfNoData = poSrcBand->GetNoDataValue( &bSuccess );
        
        if( bSuccess )
        {
            if( !bOnlyIfMissing 
                || GetNoDataValue( &bSuccess ) != dfNoData 
                || !bSuccess )
                GDALPamRasterBand::SetNoDataValue( dfNoData );
        }
    }

/* -------------------------------------------------------------------- */
/*      Offset/scale                                                    */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_SCALEOFFSET )
    {
        double dfOffset = poSrcBand->GetOffset( &bSuccess );
        
        if( bSuccess )
        {
            if( !bOnlyIfMissing || GetOffset() != dfOffset )
                GDALPamRasterBand::SetOffset( dfOffset );
        }

        double dfScale = poSrcBand->GetScale( &bSuccess );
        
        if( bSuccess )
        {
            if( !bOnlyIfMissing || GetScale() != dfScale )
                GDALPamRasterBand::SetScale( dfScale );
        }
    }

/* -------------------------------------------------------------------- */
/*      Unittype.                                                       */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_UNITTYPE )
    {
        if( strlen(poSrcBand->GetUnitType()) > 0 )
        {
            if( !bOnlyIfMissing 
                || !EQUAL(GetUnitType(),poSrcBand->GetUnitType()) )
            {
                GDALPamRasterBand::SetUnitType( poSrcBand->GetUnitType() );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      ColorInterp                                                     */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_COLORINTERP )
    {
        if( poSrcBand->GetColorInterpretation() != GCI_Undefined )
        {
            if( !bOnlyIfMissing
                || poSrcBand->GetColorInterpretation() 
                != GetColorInterpretation() )
                GDALPamRasterBand::SetColorInterpretation( 
                    poSrcBand->GetColorInterpretation() );
        }
    }

/* -------------------------------------------------------------------- */
/*      color table.                                                    */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_COLORTABLE )
    {
        if( poSrcBand->GetColorTable() != NULL )
        {
            if( !bOnlyIfMissing || GetColorTable() == NULL )
            {
                GDALPamRasterBand::SetColorTable( 
                    poSrcBand->GetColorTable() );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Raster Attribute Table.                                         */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_RAT )
    {
        const GDALRasterAttributeTable *poRAT = poSrcBand->GetDefaultRAT();

        if( poRAT != NULL )
        {
            if( !bOnlyIfMissing || GetDefaultRAT() == NULL )
            {
                GDALPamRasterBand::SetDefaultRAT( poRAT );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Restore MO flags.                                               */
/* -------------------------------------------------------------------- */
    SetMOFlags( nSavedMOFlags );

    return CE_None;
}
Пример #27
0
bool
UsdPrim::SetPayload(const SdfLayerHandle& layer, const SdfPath& primPath) const
{
    return SetMetadata(SdfFieldKeys->Payload,
                       SdfPayload(layer->GetIdentifier(), primPath));
}
Пример #28
0
bool
UsdPrim::SetPayload(const std::string& assetPath, const SdfPath& primPath) const
{
    return SetMetadata(SdfFieldKeys->Payload, SdfPayload(assetPath, primPath));
}
Пример #29
0
bool
UsdPrim::SetPayload(const SdfPayload& payload) const
{
    return SetMetadata(SdfFieldKeys->Payload, payload);
}
Пример #30
0
void
RasterImage::NotifyDecodeComplete(const DecoderFinalStatus& aStatus,
                                  const ImageMetadata& aMetadata,
                                  const DecoderTelemetry& aTelemetry,
                                  Progress aProgress,
                                  const IntRect& aInvalidRect,
                                  const Maybe<uint32_t>& aFrameCount,
                                  DecoderFlags aDecoderFlags,
                                  SurfaceFlags aSurfaceFlags)
{
  MOZ_ASSERT(NS_IsMainThread());

  // If the decoder detected an error, log it to the error console.
  if (aStatus.mShouldReportError && !aStatus.mWasAborted) {
    ReportDecoderError();
  }

  // Record all the metadata the decoder gathered about this image.
  bool metadataOK = SetMetadata(aMetadata, aStatus.mWasMetadataDecode);
  if (!metadataOK) {
    // This indicates a serious error that requires us to discard all existing
    // surfaces and redecode to recover. We'll drop the results from this
    // decoder on the floor, since they aren't valid.
    RecoverFromInvalidFrames(mSize,
                             FromSurfaceFlags(aSurfaceFlags));
    return;
  }

  MOZ_ASSERT(mError || mHasSize || !aMetadata.HasSize(),
             "SetMetadata should've gotten a size");

  if (!aStatus.mWasMetadataDecode && aStatus.mFinished && !aStatus.mWasAborted) {
    // Flag that we've been decoded before.
    mHasBeenDecoded = true;
  }

  // Send out any final notifications.
  NotifyProgress(aProgress, aInvalidRect, aFrameCount,
                 aDecoderFlags, aSurfaceFlags);

  if (!(aDecoderFlags & DecoderFlags::FIRST_FRAME_ONLY) &&
      mHasBeenDecoded && mAnimationState) {
    // We've finished a full decode of all animation frames and our AnimationState
    // has been notified about them all, so let it know not to expect anymore.
    mAnimationState->SetDoneDecoding(true);
  }

  if (!aStatus.mWasMetadataDecode && aTelemetry.mChunkCount) {
    Telemetry::Accumulate(Telemetry::IMAGE_DECODE_CHUNKS, aTelemetry.mChunkCount);
  }

  if (aStatus.mFinished) {
    // Do some telemetry if this isn't a metadata decode.
    if (!aStatus.mWasMetadataDecode) {
      Telemetry::Accumulate(Telemetry::IMAGE_DECODE_TIME,
                            int32_t(aTelemetry.mDecodeTime.ToMicroseconds()));

      if (aTelemetry.mSpeedHistogram) {
        Telemetry::Accumulate(*aTelemetry.mSpeedHistogram, aTelemetry.Speed());
      }
    }

    // Detect errors.
    if (aStatus.mHadError && !aStatus.mWasAborted) {
      DoError();
    } else if (aStatus.mWasMetadataDecode && !mHasSize) {
      DoError();
    }

    // If we were waiting to fire the load event, go ahead and fire it now.
    if (mLoadProgress && aStatus.mWasMetadataDecode) {
      NotifyForLoadEvent(*mLoadProgress);
      mLoadProgress = Nothing();
      NotifyProgress(FLAG_ONLOAD_UNBLOCKED);
    }
  }

  // If we were a metadata decode and a full decode was requested, do it.
  if (aStatus.mFinished && aStatus.mWasMetadataDecode && mWantFullDecode) {
    mWantFullDecode = false;
    RequestDecodeForSize(mSize, DECODE_FLAGS_DEFAULT);
  }
}