本文整理汇总了C++中Manifest类的典型用法代码示例。如果您正苦于以下问题:C++ Manifest类的具体用法?C++ Manifest怎么用?C++ Manifest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Manifest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: merge
void Manifest::merge(const Manifest& other)
{
if (size() != other.size()) error("Invalid manifest sizes for merging.");
FileStats fileStats;
for (std::size_t i(0); i < size(); ++i)
{
FileInfo& ours(m_fileInfo[i]);
const FileInfo& theirs(other.m_fileInfo[i]);
if (ours.path() != theirs.path()) error("Invalid manifest paths");
if (
ours.status() == FileInfo::Status::Outstanding &&
theirs.status() != FileInfo::Status::Outstanding)
{
ours.status(theirs.status());
switch (theirs.status())
{
case FileInfo::Status::Inserted: fileStats.addInsert(); break;
case FileInfo::Status::Omitted: fileStats.addOmit(); break;
case FileInfo::Status::Error: fileStats.addError(); break;
default: throw std::runtime_error("Invalid file status");
}
}
ours.pointStats().add(theirs.pointStats());
}
m_pointStats.add(other.pointStats());
m_fileStats.add(fileStats);
}
示例2: linkInUniqueIdLut
/// @pre uniqueIdLut has been initialized and is large enough!
void linkInUniqueIdLut(Manifest &manifest)
{
DENG2_ASSERT(&manifest.scheme() == thisPublic); // sanity check.
int uniqueId = manifest.uniqueId();
DENG_ASSERT(uniqueIdInLutRange(uniqueId));
uniqueIdLut[uniqueId - uniqueIdBase] = &manifest;
}
示例3: NS_ENSURE_TRUE
MPAPI::Decoder *AndroidMediaPluginHost::CreateDecoder(MediaResource *aResource,
const MediaContentType& aMimeType)
{
NS_ENSURE_TRUE(aResource, nullptr);
nsAutoPtr<Decoder> decoder(new Decoder());
if (!decoder) {
return nullptr;
}
const char *chars;
size_t len = NS_CStringGetData(aMimeType.Type().AsString(), &chars, nullptr);
for (size_t n = 0; n < mPlugins.Length(); ++n) {
Manifest *plugin = mPlugins[n];
const char* const *codecs;
if (!plugin->CanDecode(chars, len, &codecs)) {
continue;
}
nsCString url;
nsresult rv = mResourceServer->AddResource(aResource, url);
if (NS_FAILED (rv)) continue;
decoder->mResource = strdup(url.get());
if (plugin->CreateDecoder(&sPluginHost, decoder, chars, len)) {
return decoder.forget();
}
}
return nullptr;
}
示例4: CycNegQtyException
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Manifest ResourceBuff::popQty(double qty) {
if (qty - quantity() > STORE_EPS) {
throw CycNegQtyException("Removal quantity larger than store tot quantity.");
}
if (qty < 0.0) {
throw CycNegQtyException("Removal quantity cannot be negative.");
}
Manifest manifest;
rsrc_ptr mat, leftover;
double left = qty;
double quan;
while (left > STORE_EPS) {
mat = mats_.front();
mats_.pop_front();
quan = mat->quantity();
if ((quan - left) > STORE_EPS) {
// too big - split the mat before pushing
leftover = mat->clone();
leftover->setQuantity(quan - left);
mat->setQuantity(left);
mats_.push_front(leftover);
}
manifest.push_back(mat);
left -= quan;
}
return manifest;
}
示例5: unlinkInUniqueIdLut
/// @pre uniqueIdMap is large enough if initialized!
void unlinkInUniqueIdLut(Manifest const &manifest)
{
DENG2_ASSERT(&manifest.scheme() == thisPublic); // sanity check.
// If the lut is already considered 'dirty' do not unlink.
if(!uniqueIdLutDirty)
{
int uniqueId = manifest.uniqueId();
DENG2_ASSERT(uniqueIdInLutRange(uniqueId));
uniqueIdLut[uniqueId - uniqueIdBase] = 0;
}
}
示例6: NS_CStringGetData
bool MediaPluginHost::FindDecoder(const nsACString& aMimeType, const char* const** aCodecs)
{
const char *chars;
size_t len = NS_CStringGetData(aMimeType, &chars, nullptr);
for (size_t n = 0; n < mPlugins.Length(); ++n) {
Manifest *plugin = mPlugins[n];
const char* const *codecs;
if (plugin->CanDecode(chars, len, &codecs)) {
if (aCodecs)
*aCodecs = codecs;
return true;
}
}
return false;
}
示例7: deindex
void deindex(Manifest &manifest)
{
/// @todo Only destroy the resource if this is the last remaining reference.
manifest.clearResource();
unlinkInUniqueIdLut(manifest);
}
示例8: write_manifest
void
write_manifest(ostream& os)
{
os << "@prefix lv2: <http://lv2plug.in/ns/lv2core#> ." << endl;
os << "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ." << endl;
os << "@prefix uiext: <http://lv2plug.in/ns/extensions/ui#> ." << endl << endl;
for (Manifest::iterator i = manifest.begin(); i != manifest.end(); ++i) {
Record& r = i->second;
os << "<" << i->first << ">\n\ta lv2:Plugin ;" << endl;
os << "\trdfs:seeAlso <" << r.base_name << ".ttl> ;" << endl;
os << "\tlv2:binary <" << r.base_name << ".so> ";
for (Record::UIs::iterator j = r.uis.begin(); j != r.uis.end(); ++j)
os << ";" << endl << "\tuiext:ui <" << *j << "> ";
os << "." << endl << endl;
}
}
示例9: new
void AssetsManagerEx::loadLocalManifest(const std::string& manifestUrl)
{
Manifest *cachedManifest = nullptr;
// Find the cached manifest file
if (_fileUtils->isFileExist(_cacheManifestPath))
{
cachedManifest = new (std::nothrow) Manifest();
if (cachedManifest) {
cachedManifest->parse(_cacheManifestPath);
if (!cachedManifest->isLoaded())
{
_fileUtils->removeFile(_cacheManifestPath);
CC_SAFE_RELEASE(cachedManifest);
cachedManifest = nullptr;
}
}
}
// Load local manifest in app package
_localManifest->parse(_manifestUrl);
if (_localManifest->isLoaded())
{
// Compare with cached manifest to determine which one to use
if (cachedManifest) {
if (strcmp(_localManifest->getVersion().c_str(), cachedManifest->getVersion().c_str()) > 0)
{
// Recreate storage, to empty the content
_fileUtils->removeDirectory(_storagePath);
_fileUtils->createDirectory(_storagePath);
CC_SAFE_RELEASE(cachedManifest);
}
else
{
CC_SAFE_RELEASE(_localManifest);
_localManifest = cachedManifest;
}
}
prepareLocalManifest();
}
// Fail to load local manifest
if (!_localManifest->isLoaded())
{
CCLOG("AssetsManagerEx : No local manifest file found error.\n");
dispatchUpdateEvent(EventAssetsManagerEx::EventCode::ERROR_NO_LOCAL_MANIFEST);
}
}
示例10: NS_CStringGetData
bool AndroidMediaPluginHost::FindDecoder(const MediaContentType& aMimeType,
MediaCodecs* aCodecs)
{
const char *chars;
size_t len = NS_CStringGetData(aMimeType.Type().AsString(), &chars, nullptr);
for (size_t n = 0; n < mPlugins.Length(); ++n) {
Manifest *plugin = mPlugins[n];
const char* const *codecs;
if (plugin->CanDecode(chars, len, &codecs)) {
if (aCodecs) {
nsString codecsString;
for (const char* const* codec = codecs; *codec; ++codec) {
if (codecsString.IsEmpty()) {
codecsString += ',';
}
codecsString.AppendASCII(*codec);
}
*aCodecs = MediaCodecs(codecsString);
}
return true;
}
}
return false;
}
示例11: pushAll
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ResourceBuff::pushAll(Manifest mats) {
double tot_qty = 0;
for (int i = 0; i < mats.size(); i++) {
tot_qty += mats.at(i)->quantity();
}
if (tot_qty - space() > STORE_EPS && unlimited_ != true) {
throw CycOverCapException("Material pushing breaks capacity limit.");
}
std::list<rsrc_ptr>::iterator iter;
for (iter = mats_.begin(); iter != mats_.end(); iter++) {
for (int i = 0; i < mats.size(); i++) {
if ((*iter) == mats.at(i)) {
throw CycDupResException("Duplicate material pushing attempted.");
}
}
}
for (int i = 0; i < mats.size(); i++) {
mats_.push_back(mats.at(i));
}
}
示例12: logMftAct
ManifestDisposition
ManifestCache::applyManifest (Manifest m)
{
std::lock_guard<std::mutex> applyLock{apply_mutex_};
/*
before we spend time checking the signature, make sure the
sequence number is newer than any we have.
*/
auto const iter = map_.find(m.masterKey);
if (iter != map_.end() &&
m.sequence <= iter->second.sequence)
{
/*
A manifest was received for a validator we're tracking, but
its sequence number is not higher than the one already stored.
This will happen normally when a peer without the latest gossip
connects.
*/
if (auto stream = j_.debug())
logMftAct(stream, "Stale", m.masterKey, m.sequence, iter->second.sequence);
return ManifestDisposition::stale; // not a newer manifest, ignore
}
if (! m.verify())
{
/*
A manifest's signature is invalid.
This shouldn't happen normally.
*/
if (auto stream = j_.warn())
logMftAct(stream, "Invalid", m.masterKey, m.sequence);
return ManifestDisposition::invalid;
}
std::lock_guard<std::mutex> readLock{read_mutex_};
bool const revoked = m.revoked();
if (iter == map_.end ())
{
/*
This is the first received manifest for a trusted master key
(possibly our own). This only happens once per validator per
run.
*/
if (auto stream = j_.info())
logMftAct(stream, "AcceptedNew", m.masterKey, m.sequence);
if (! revoked)
signingToMasterKeys_[m.signingKey] = m.masterKey;
map_.emplace (std::make_pair(m.masterKey, std::move (m)));
}
else
{
/*
An ephemeral key was revoked and superseded by a new key.
This is expected, but should happen infrequently.
*/
if (auto stream = j_.info())
logMftAct(stream, "AcceptedUpdate",
m.masterKey, m.sequence, iter->second.sequence);
signingToMasterKeys_.erase (iter->second.signingKey);
if (! revoked)
signingToMasterKeys_[m.signingKey] = m.masterKey;
iter->second = std::move (m);
}
if (revoked)
{
/*
A validator master key has been compromised, so its manifests
are now untrustworthy. In order to prevent us from accepting
a forged manifest signed by the compromised master key, store
this manifest, which has the highest possible sequence number
and therefore can't be superseded by a forged one.
*/
if (auto stream = j_.warn())
logMftAct(stream, "Revoked", m.masterKey, m.sequence);
}
return ManifestDisposition::accepted;
}
示例13: assert
void ManifestTest::testManifest()
{
Manifest<MfTestBase> manifest;
assert (manifest.empty());
assert (manifest.size() == 0);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject1")));
assert (!manifest.empty());
assert (manifest.size() == 1);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject2")));
MetaObject<MfTestObject, MfTestBase>* pMeta = new MetaObject<MfTestObject, MfTestBase>("MfTestObject2");
assert (!manifest.insert(pMeta));
delete pMeta;
assert (!manifest.empty());
assert (manifest.size() == 2);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject3")));
assert (manifest.size() == 3);
assert (manifest.find("MfTestObject1") != manifest.end());
assert (manifest.find("MfTestObject2") != manifest.end());
assert (manifest.find("MfTestObject3") != manifest.end());
assert (manifest.find("MfTestObject4") == manifest.end());
std::set<std::string> classes;
Manifest<MfTestBase>::Iterator it = manifest.begin();
assert (it != manifest.end());
classes.insert(it->name());
++it;
assert (it != manifest.end());
classes.insert(it->name());
++it;
assert (it != manifest.end());
classes.insert(it->name());
it++;
assert (it == manifest.end());
assert (classes.find("MfTestObject1") != classes.end());
assert (classes.find("MfTestObject2") != classes.end());
assert (classes.find("MfTestObject3") != classes.end());
manifest.clear();
assert (manifest.empty());
assert (manifest.size() == 0);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject4")));
assert (!manifest.empty());
assert (manifest.size() == 1);
it = manifest.begin();
assert (it != manifest.end());
assert (std::string(it->name()) == "MfTestObject4");
++it;
assert (it == manifest.end());
}
示例14: new
void AssetsManagerEx::loadLocalManifest(const std::string& /*manifestUrl*/)
{
Manifest *cachedManifest = nullptr;
// Find the cached manifest file
if (_fileUtils->isFileExist(_cacheManifestPath))
{
cachedManifest = new (std::nothrow) Manifest();
if (cachedManifest) {
cachedManifest->parse(_cacheManifestPath);
if (!cachedManifest->isLoaded())
{
_fileUtils->removeFile(_cacheManifestPath);
CC_SAFE_RELEASE(cachedManifest);
cachedManifest = nullptr;
}
}
}
// Ensure no search path of cached manifest is used to load this manifest
std::vector<std::string> searchPaths = _fileUtils->getSearchPaths();
if (cachedManifest)
{
std::vector<std::string> cacheSearchPaths = cachedManifest->getSearchPaths();
std::vector<std::string> trimmedPaths = searchPaths;
for (auto path : cacheSearchPaths)
{
const auto pos = std::find(trimmedPaths.begin(), trimmedPaths.end(), path);
if (pos != trimmedPaths.end())
{
trimmedPaths.erase(pos);
}
}
_fileUtils->setSearchPaths(trimmedPaths);
}
// Load local manifest in app package
_localManifest->parse(_manifestUrl);
if (cachedManifest) {
// Restore search paths
_fileUtils->setSearchPaths(searchPaths);
}
if (_localManifest->isLoaded())
{
// Compare with cached manifest to determine which one to use
if (cachedManifest) {
bool localNewer = _localManifest->versionGreater(cachedManifest, _versionCompareHandle);
if (localNewer)
{
// Recreate storage, to empty the content
_fileUtils->removeDirectory(_storagePath);
_fileUtils->createDirectory(_storagePath);
CC_SAFE_RELEASE(cachedManifest);
}
else
{
CC_SAFE_RELEASE(_localManifest);
_localManifest = cachedManifest;
}
}
prepareLocalManifest();
}
// Fail to load local manifest
if (!_localManifest->isLoaded())
{
CCLOG("AssetsManagerEx : No local manifest file found error.\n");
dispatchUpdateEvent(EventAssetsManagerEx::EventCode::ERROR_NO_LOCAL_MANIFEST);
}
}
示例15: write_plugin
void
write_plugin(AudioEffectX* effect, const string& lib_file_name)
{
const string base_name = lib_file_name.substr(0, lib_file_name.find_last_of("."));
const string data_file_name = base_name + ".ttl";
fstream os(data_file_name.c_str(), ios::out);
effect->getProductString(name_buf);
os << "@prefix lv2: <http://lv2plug.in/ns/lv2core#> ." << endl;
os << "@prefix doap: <http://usefulinc.com/ns/doap#> ." << endl << endl;
os << "<" << effect->getURI() << ">" << endl;
os << "\tlv2:symbol \"" << effect->getUniqueID() << "\" ;" << endl;
os << "\tdoap:name \"" << name_buf << "\" ;" << endl;
os << "\tdoap:license <http://usefulinc.com/doap/licenses/gpl> ;" << endl;
os << "\tlv2:pluginProperty lv2:hardRTCapable";
uint32_t num_params = effect->getNumParameters();
uint32_t num_audio_ins = effect->getNumInputs();
uint32_t num_audio_outs = effect->getNumOutputs();
uint32_t num_ports = num_params + num_audio_ins + num_audio_outs;
if (num_ports > 0)
os << " ;" << endl << "\tlv2:port [" << endl;
else
os << " ." << endl;
uint32_t idx = 0;
for (uint32_t i = idx; i < num_params; ++i, ++idx) {
effect->getParameterName(i, name_buf);
os << "\t\ta lv2:InputPort, lv2:ControlPort ;" << endl;
os << "\t\tlv2:index" << " " << idx << " ;" << endl;
os << "\t\tlv2:name \"" << name_buf << "\" ;" << endl;
os << "\t\tlv2:symbol \"" << symbolify(name_buf) << "\" ;" << endl;
os << "\t\tlv2:default " << lvz_translate_parameter(effect, i, effect->getParameter(i)) << " ;" << endl;
os << "\t\tlv2:minimum " << lvz_translate_parameter(effect, i, 0.0f) << " ;" << endl;
os << "\t\tlv2:maximum " << lvz_translate_parameter(effect, i, 1.0f) << " ;" << endl;
os << ((idx == num_ports - 1) ? "\t] ." : "\t] , [") << endl;
}
for (uint32_t i = 0; i < num_audio_ins; ++i, ++idx) {
os << "\t\ta lv2:InputPort, lv2:AudioPort ;" << endl;
os << "\t\tlv2:index" << " " << idx << " ;" << endl;
os << "\t\tlv2:symbol \"in" << i+1 << "\" ;" << endl;
os << "\t\tlv2:name \"Input " << i+1 << "\" ;" << endl;
os << ((idx == num_ports - 1) ? "\t] ." : "\t] , [") << endl;
}
for (uint32_t i = 0; i < num_audio_outs; ++i, ++idx) {
os << "\t\ta lv2:OutputPort, lv2:AudioPort ;" << endl;
os << "\t\tlv2:index " << idx << " ;" << endl;
os << "\t\tlv2:symbol \"out" << i+1 << "\" ;" << endl;
os << "\t\tlv2:name \"Output " << i+1 << "\" ;" << endl;
os << ((idx == num_ports - 1) ? "\t] ." : "\t] , [") << endl;
}
os.close();
Manifest::iterator i = manifest.find(effect->getURI());
if (i != manifest.end()) {
i->second.base_name = base_name;
} else {
manifest.insert(std::make_pair(effect->getURI(), Record(base_name)));
}
if (effect->getNumPrograms() > 1) {
std::string preset_file = base_name + "-presets.ttl";
fstream pos(preset_file.c_str(), ios::out);
pos << "@prefix lv2: <http://lv2plug.in/ns/lv2core#> ." << endl;
pos << "@prefix pset: <http://lv2plug.in/ns/ext/presets#> ." << endl;
pos << "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ." << endl << endl;
for (int32_t i = 0; i < effect->getNumPrograms(); ++i) {
effect->setProgram(i);
effect->getProgramName(name_buf);
if (!strcmp(name_buf, "Empty Patch"))
continue;
std::string preset_uri = string("http://moddevices.com/plugins/mda/presets#") + base_name + "-" + symbolify(name_buf, '-');
// Write manifest entry
std::cout << "<" << preset_uri << ">"
<< "\n\ta pset:Preset ;\n\tlv2:appliesTo <"
<< effect->getURI() << "> ;\n\t"
<< "rdfs:seeAlso <" << preset_file << "> .\n" << std::endl;
// Write preset file
pos << "<" << preset_uri << ">"
<< "\n\ta pset:Preset ;\n\tlv2:appliesTo <"
<< effect->getURI() << "> ;\n\t"
<< "rdfs:label \"" << name_buf << "\"";
for (uint32_t i = 0; i < num_params; ++i) {
effect->getParameterName(i, name_buf);
pos << " ;\n\tlv2:port [" << endl;
pos << "\t\tlv2:symbol \"" << symbolify(name_buf) << "\" ;" << endl;
pos << "\t\tpset:value " << lvz_translate_parameter(effect, i, effect->getParameter(i)) << " ;" << endl;
pos << "\t]";
}
//.........这里部分代码省略.........