本文整理汇总了C++中ConstCompoundObjectPtr::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstCompoundObjectPtr::copy方法的具体用法?C++ ConstCompoundObjectPtr::copy怎么用?C++ ConstCompoundObjectPtr::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstCompoundObjectPtr
的用法示例。
在下文中一共展示了ConstCompoundObjectPtr::copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeGlobals
IECore::ConstCompoundObjectPtr SubTree::computeGlobals( const Gaffer::Context *context, const ScenePlug *parent ) const
{
ConstCompoundObjectPtr inputGlobals = inPlug()->globalsPlug()->getValue();
const CompoundData *inputSets = inputGlobals->member<CompoundData>( "gaffer:sets" );
if( !inputSets )
{
return inputGlobals;
}
CompoundObjectPtr outputGlobals = inputGlobals->copy();
CompoundDataPtr outputSets = new CompoundData;
outputGlobals->members()["gaffer:sets"] = outputSets;
std::string root = rootPlug()->getValue();
if( !root.size() || root[root.size()-1] != '/' )
{
root += "/";
}
size_t prefixSize = root.size() - 1; // number of characters to remove from front of each declaration
if( includeRootPlug()->getValue() && prefixSize )
{
size_t lastSlashButOne = root.rfind( "/", prefixSize-1 );
if( lastSlashButOne != string::npos )
{
prefixSize = lastSlashButOne;
}
}
for( CompoundDataMap::const_iterator it = inputSets->readable().begin(), eIt = inputSets->readable().end(); it != eIt; ++it )
{
/// \todo This could be more efficient if PathMatcher exposed the internal nodes,
/// and allowed sharing between matchers. Then we could just pick the subtree within
/// the matcher that we wanted.
const PathMatcher &inputSet = static_cast<const PathMatcherData *>( it->second.get() )->readable();
PathMatcher &outputSet = outputSets->member<PathMatcherData>( it->first, /* throwExceptions = */ false, /* createIfMissing = */ true )->writable();
vector<string> inputPaths;
inputSet.paths( inputPaths );
for( vector<string>::const_iterator pIt = inputPaths.begin(), peIt = inputPaths.end(); pIt != peIt; ++pIt )
{
const string &inputPath = *pIt;
if( inputPath.compare( 0, root.size(), root ) == 0 )
{
std::string outputPath( inputPath, prefixSize );
outputSet.addPath( outputPath );
}
}
}
return outputGlobals;
}
示例2: Exception
Parameter::Parameter( const std::string &name, const std::string &description, ObjectPtr defaultValue,
const PresetsContainer &presets, bool presetsOnly, ConstCompoundObjectPtr userData )
: m_name( name ), m_description( description ), m_defaultValue( defaultValue ), m_presetsOnly( presetsOnly ),
m_userData( userData ? userData->copy() : 0 )
{
if ( !defaultValue )
{
throw Exception( "Invalid NULL default value!" );
}
for( PresetsContainer::const_iterator it=presets.begin(); it!=presets.end(); it++ )
{
m_presets.push_back( PresetsContainer::value_type( it->first, it->second->copy() ) );
}
/// \todo If presetsOnly is true, doesn't this allow us to set a defaultValue that isn't in the presets list?
setValue( defaultValue->copy() );
}
示例3: computeGlobals
IECore::ConstCompoundObjectPtr Prune::computeGlobals( const Gaffer::Context *context, const ScenePlug *parent ) const
{
ConstCompoundObjectPtr inputGlobals = inPlug()->globalsPlug()->getValue();
const CompoundData *inputSets = inputGlobals->member<CompoundData>( "gaffer:sets" );
if( !inputSets )
{
return inputGlobals;
}
CompoundObjectPtr outputGlobals = inputGlobals->copy();
CompoundDataPtr outputSets = new CompoundData;
outputGlobals->members()["gaffer:sets"] = outputSets;
ContextPtr tmpContext = new Context( *Context::current() );
Context::Scope scopedContext( tmpContext );
ScenePath path;
for( CompoundDataMap::const_iterator it = inputSets->readable().begin(), eIt = inputSets->readable().end(); it != eIt; ++it )
{
/// \todo This could be more efficient if PathMatcher exposed the internal nodes,
/// and allowed sharing between matchers. Then we could do a really lightweight copy
/// and just trim out the nodes we didn't want.
const PathMatcher &inputSet = static_cast<const PathMatcherData *>( it->second.get() )->readable();
PathMatcher &outputSet = outputSets->member<PathMatcherData>( it->first, /* throwExceptions = */ false, /* createIfMissing = */ true )->writable();
vector<string> inputPaths;
inputSet.paths( inputPaths );
for( vector<string>::const_iterator pIt = inputPaths.begin(), peIt = inputPaths.end(); pIt != peIt; ++pIt )
{
path.clear();
ScenePlug::stringToPath( *pIt, path );
tmpContext->set( ScenePlug::scenePathContextName, path );
if( !(filterPlug()->getValue() & ( Filter::ExactMatch | Filter::AncestorMatch ) ) )
{
outputSet.addPath( *pIt );
}
}
}
return outputGlobals;
}