bool UsdRelationship::_GetForwardedTargets(SdfPathSet* visited, SdfPathSet* uniqueTargets, SdfPathVector* targets, bool includeForwardingRels) const { // Track recursive composition errors, starting with the first batch of // targets. SdfPathVector curTargets; bool success = GetTargets(&curTargets); // Process all targets at this relationship. for (SdfPath const &target: curTargets) { if (target.IsPrimPropertyPath()) { // Resolve forwarding if this target points at a relationship. if (UsdPrim prim = GetStage()->GetPrimAtPath(target.GetPrimPath())) { if (UsdRelationship rel = prim.GetRelationship(target.GetNameToken())) { if (visited->insert(rel.GetPath()).second) { // Only do this rel if we've not yet seen it. success &= rel._GetForwardedTargets( visited, uniqueTargets, targets, includeForwardingRels); } if (!includeForwardingRels) continue; } } } if (uniqueTargets->insert(target).second) targets->push_back(target); } return success; }
NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(nsISupportsArray *aFlavorList, PRInt32 aWhichClipboard, PRBool *_retval) { *_retval = PR_FALSE; PRUint32 length = 0; aFlavorList->Count(&length); if (!length) return NS_OK; GtkSelectionData *selection_data = GetTargets(GetSelectionAtom(aWhichClipboard)); if (!selection_data) return NS_OK; gint n_targets = 0; GdkAtom *targets = NULL; if (!gtk_selection_data_get_targets(selection_data, &targets, &n_targets) || !n_targets) return NS_OK; // Walk through the provided types and try to match it to a // provided type. for (PRUint32 i = 0; i < length && !*_retval; i++) { nsCOMPtr<nsISupports> genericFlavor; aFlavorList->GetElementAt(i, getter_AddRefs(genericFlavor)); nsCOMPtr<nsISupportsCString> flavorWrapper; flavorWrapper = do_QueryInterface(genericFlavor); if (flavorWrapper) { nsXPIDLCString myStr; flavorWrapper->ToString(getter_Copies(myStr)); // We special case text/unicode here. if (!strcmp(myStr, kUnicodeMime) && gtk_selection_data_targets_include_text(selection_data)) { *_retval = PR_TRUE; break; } for (PRInt32 j = 0; j < n_targets; j++) { gchar *atom_name = gdk_atom_name(targets[j]); if (!strcmp(atom_name, (const char *)myStr)) *_retval = PR_TRUE; g_free(atom_name); if (*_retval) break; } } } gtk_selection_data_free(selection_data); g_free(targets); return NS_OK; }
/***** * Primary control loop for this controller object. This function will execute * the CPFA logic using the CPFA enumeration flag once per frame. *****/ void iAnt_controller::ControlStep() { if(Stop()) { return; } if(isHoldingFood == false) { /* draws target rays every 2 seconds */ if((data->DrawTargetRays < 4) && (data->SimTime % (data->TicksPerSecond * 2)) == 0 ) { CVector3 position3d(GetPosition().GetX(), GetPosition().GetY(), 0.02); CVector3 target3d(GetTarget().GetX(), GetTarget().GetY(), 0.02); CRay3 targetRay(target3d, position3d); data->TargetRayList.push_back(targetRay); } } /* Checks if the robot found a food */ SetHoldingFood(); /* If it didn't continue in a sprial */ if(IsHoldingFood() == false) { GetTargets(); /* Initializes targets positions. */ } else { /* Check if it is near the nest then set isHoldingFood to false */ if((GetPosition() - data->NestPosition).SquareLength() < data->NestRadiusSquared) { isHoldingFood = false; } else { ApproachTheTarget(data->NestPosition); } } }
NS_IMETHODIMP nsHTTPIndex::GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsISimpleEnumerator **_retval) { nsresult rv = NS_ERROR_UNEXPECTED; if (mInner) { rv = mInner->GetTargets(aSource, aProperty, aTruthValue, _retval); } else { rv = NS_NewEmptyEnumerator(_retval); } if ((aProperty == kNC_Child) && isWellknownContainerURI(aSource)) { PRBool doNetworkRequest = PR_TRUE; if (NS_SUCCEEDED(rv) && (_retval)) { // check and see if we already have data for the search in question; // if we do, don't bother doing the search again PRBool hasResults; if (NS_SUCCEEDED((*_retval)->HasMoreElements(&hasResults)) && hasResults) doNetworkRequest = PR_FALSE; } // Note: if we need to do a network request, do it out-of-band // (because the XUL template builder isn't re-entrant) // by using a global connection list and an immediately-firing timer if (doNetworkRequest && mConnectionList) { PRInt32 connectionIndex = mConnectionList->IndexOf(aSource); if (connectionIndex < 0) { // add aSource into list of connections to make mConnectionList->AppendElement(aSource); // if we don't have a timer about to fire, create one // which should fire as soon as possible (out-of-band) if (!mTimer) { mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a timer"); if (NS_SUCCEEDED(rv)) { mTimer->InitWithFuncCallback(nsHTTPIndex::FireTimer, this, 1, nsITimer::TYPE_ONE_SHOT); // Note: don't addref "this" as we'll cancel the // timer in the httpIndex destructor } } } } } return(rv); }
bool LockAction::Perform() { svn::Client client(GetContext()); std::string messageUtf8(LocalToUtf8(m_message)); client.lock(GetTargets(), m_stealLock, messageUtf8.c_str()); return true; }
NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength, PRInt32 aWhichClipboard, PRBool *_retval) { if (!aFlavorList || !_retval) return NS_ERROR_NULL_POINTER; *_retval = PR_FALSE; GtkSelectionData *selection_data = GetTargets(GetSelectionAtom(aWhichClipboard)); if (!selection_data) return NS_OK; gint n_targets = 0; GdkAtom *targets = NULL; if (!gtk_selection_data_get_targets(selection_data, &targets, &n_targets) || !n_targets) return NS_OK; // Walk through the provided types and try to match it to a // provided type. for (PRUint32 i = 0; i < aLength && !*_retval; i++) { // We special case text/unicode here. if (!strcmp(aFlavorList[i], kUnicodeMime) && gtk_selection_data_targets_include_text(selection_data)) { *_retval = PR_TRUE; break; } for (PRInt32 j = 0; j < n_targets; j++) { gchar *atom_name = gdk_atom_name(targets[j]); if (!atom_name) continue; if (!strcmp(atom_name, aFlavorList[i])) *_retval = PR_TRUE; // X clipboard wants image/jpeg, not image/jpg if (!strcmp(aFlavorList[i], kJPEGImageMime) && !strcmp(atom_name, "image/jpeg")) *_retval = PR_TRUE; g_free(atom_name); if (*_retval) break; } } gtk_selection_data_free(selection_data); g_free(targets); return NS_OK; }
bool UpdateAction::Perform() { svn::Revision revision(svn::Revision::HEAD); // Did the user request a specific revision?: if (!m_data.useLatest) { TrimString(m_data.revision); if (!m_data.revision.IsEmpty()) { svn_revnum_t revnum; m_data.revision.ToLong(&revnum, 10); // If this fails, revnum is unchanged. revision = svn::Revision(revnum); } } const wxString & dir = Utf8ToLocal(GetPath().c_str()); if (!dir.empty()) wxSetWorkingDirectory(dir); svn::Client client(GetContext()); svn_depth_t depth = svn_depth_unknown; switch (m_data.depth) { default: case UPDATE_WORKING_COPY: depth = svn_depth_unknown; break; case UPDATE_FULLY_RECURSIVE: depth = svn_depth_infinity; break; case UPDATE_IMMEDIATES: depth = svn_depth_immediates; break; case UPDATE_FILES: depth = svn_depth_files; break; case UPDATE_EMPTY: depth = svn_depth_empty; break; } client.update(GetTargets(), revision, depth, m_data.stickyDepth, m_data.ignoreExternals); return true; }
/***** * Primary control loop for this controller object. This function will execute * the CPFA logic using the CPFA enumeration flag once per frame. *****/ void DSA_controller::ControlStep() { if(IsHoldingFood() == false && DSA == SEARCHING) { /* draws target rays every 2 seconds */ if((loopFunctions.SimTime % (loopFunctions.TicksPerSecond)) == 0) { CVector3 position3d(GetPosition().GetX(), GetPosition().GetY(), 0.02); CVector3 target3d(GetTarget().GetX(), GetTarget().GetY(), 0.02); CRay3 targetRay(target3d, position3d); myTrail.push_back(targetRay); // loopFunctions.TargetRayList.push_back(myTrail); loopFunctions.TargetRayList.insert(loopFunctions.TargetRayList.end(), myTrail.begin(), myTrail.end()); } } if(Stop() == true) { return;//motorActuator->SetLinearVelocity(0.0, 0.0); } else { /* Checks if the robot found a food */ SetHoldingFood(); /* If it didn't continue in a sprial */ if(IsHoldingFood() == false) { GetTargets(); /* Initializes targets positions. */ } else { /* Check if it is near the nest then set isHoldingFood to false */ DSA = RETURNING; if((GetPosition() - loopFunctions.NestPosition).SquareLength() < loopFunctions.NestRadiusSquared) { isHoldingFood = false; } else { ApproachTheTarget(loopFunctions.NestPosition); } } } }