本文整理汇总了C++中node::Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: insert
/*
* Adds node to routing table
*/
bool KBucket::insert(const Node::Ptr& node)
{
if(node->isInList)
return true; // node is already in the table
string ip = node->getIdentity().getIp();
string port = node->getIdentity().getUdpPort();
// allow only one same IP:port
bool isAcceptable = (ipMap.find(ip + ":" + port) == ipMap.end());
if((nodes.size() < (K * ID_BITS)) && isAcceptable)
{
nodes.push_back(node);
node->isInList = true;
ipMap.insert(ip + ":" + port);
if(DHT::getInstance())
DHT::getInstance()->setDirty();
return true;
}
return isAcceptable;
}
开发者ID:pk2010,项目名称:eiskaltdcpp,代码行数:28,代码来源:KBucket.cpp
示例2: addToPutSet
void XercesUpdateFactory::addToPutSet(const Node::Ptr &node, const LocationInfo *location, DynamicContext *context)
{
Node::Ptr root = node->root(context);
Sequence docURISeq = root->dmDocumentURI(context);
const XMLCh *docuri = 0;
if(!docURISeq.isEmpty()) {
docuri = docURISeq.first()->asString(context);
}
PutItem item(docuri, root, location, context);
std::pair<PutSet::iterator, bool> res = putSet_.insert(item);
if(!res.second && !res.first->node->equals(item.node)) {
if(context->getMessageListener() != 0) {
context->getMessageListener()->warning(X("In the context of this expression"), res.first->location);
}
XMLBuffer buf;
buf.append(X("Document writing conflict for URI \""));
buf.append(item.uri);
buf.append(X("\""));
XQThrow3(ASTException, X("XercesUpdateFactory::addToPutSet"), buf.getRawBuffer(), location);
}
}
开发者ID:xubingyue,项目名称:xqilla,代码行数:26,代码来源:XercesUpdateFactory.cpp
示例3: revConnectToMe
/*
* Sends request to create connection with me
*/
void ConnectionManager::revConnectToMe(const Node::Ptr& node, const AdcCommand& cmd)
{
// don't allow connection if we didn't proceed a handshake
//if(!node->isOnline())
// return;
// this is valid for active-passive connections only
if(!ClientManager::getInstance()->isActive())
return;
const string& protocol = cmd.getParam(1);
const string& token = cmd.getParam(2);
bool secure;
if(protocol == CLIENT_PROTOCOL)
{
secure = false;
}
else if(protocol == SECURE_CLIENT_PROTOCOL_TEST && CryptoManager::getInstance()->TLSOk())
{
secure = true;
}
else
{
AdcCommand sta(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_UNSUPPORTED, "Protocol unknown", AdcCommand::TYPE_UDP);
sta.addParam("PR", protocol);
sta.addParam("TO", token);
DHT::getInstance()->send(sta, node->getIdentity().getIp(), static_cast<uint16_t>(Util::toInt(node->getIdentity().getUdpPort())),
node->getUser()->getCID(), node->getUdpKey());
return;
}
connect(node, token, secure);
}
开发者ID:BackupTheBerlios,项目名称:rsxplusplus-svn,代码行数:38,代码来源:ConnectionManager.cpp
示例4: createSequence
Sequence FunctionLocalname::createSequence(DynamicContext* context, int flags) const
{
XPath2MemoryManager* memMgr = context->getMemoryManager();
Node::Ptr ctxNode;
if(getNumArgs() == 1) {
Sequence arg=getParamNumber(1,context)->toSequence(context);
if(arg.isEmpty())
return Sequence(context->getItemFactory()->createString(XERCES_CPP_NAMESPACE_QUALIFIER XMLUni::fgZeroLenString, context), memMgr);
ctxNode=arg.first();
}
else {
const Item::Ptr item = context->getContextItem();
if(item==NULLRCP)
XQThrow(FunctionException, X("FunctionLocalName::createSequence"),X("Undefined context item in fn:local-name [err:XPDY0002]"));
if(!item->isNode())
XQThrow(FunctionException, X("FunctionLocalName::createSequence"),X("The context item is not a node [err:XPTY0004]"));
ctxNode=item;
}
ATQNameOrDerived::Ptr name = ctxNode->dmNodeName(context);
if(name.notNull())
return Sequence(context->getItemFactory()->createString(((const ATQNameOrDerived*)name.get())->getName(), context), memMgr);
return Sequence(context->getItemFactory()->createString(XERCES_CPP_NAMESPACE_QUALIFIER XMLUni::fgZeroLenString, context), memMgr);
}
开发者ID:kanbang,项目名称:Colt,代码行数:26,代码来源:FunctionLocalname.cpp
示例5: reset
Item::Ptr UTransform::TransformResult::next(DynamicContext *context)
{
context->testInterrupt();
AutoVariableStoreReset reset(context, &scope_);
if(toDo_) {
toDo_ = false;
NodeSet copiedNodes = NodeSet(nodecompare(context));
VectorOfCopyBinding::const_iterator end = transform_->getBindings()->end();
for(VectorOfCopyBinding::const_iterator it = transform_->getBindings()->begin();
it != end; ++it) {
if((*it)->qname_ == 0) continue;
Sequence values = (*it)->expr_->createResult(context)->toSequence(context);
// Keep a record of the nodes that have been copied
Result valIt = values;
Item::Ptr val;
while((val = valIt->next(context)).notNull()) {
copiedNodes.insert((Node*)val.get());
}
scope_.setVar((*it)->uri_, (*it)->name_, values);
}
// Get the pending update list
PendingUpdateList pul = transform_->getModifyExpr()->createUpdateList(context);
// Check that the targets of the pending updates are copied nodes
for(PendingUpdateList::const_iterator i = pul.begin(); i != pul.end(); ++i) {
Node::Ptr target = i->getTarget();
while(copiedNodes.find(target) == copiedNodes.end()) {
target = target->dmParent(context);
if(target.isNull()) {
XQThrow3(StaticErrorException,X("UTransform::staticTyping"),
X("The target node of an update expression in the transform expression is not a node from the copy clauses [err:XUDY0014]"), &(*i));
}
}
}
// Apply the updates
AutoDelete<UpdateFactory> ufactory(context->createUpdateFactory());
ufactory->applyUpdates(pul, context, transform_->getRevalidationMode());
// Execute the return expression
result_ = transform_->getReturnExpr()->createResult(context);
}
Item::Ptr result = result_->next(context);
if(result.isNull()) {
result_ = 0;
return 0;
}
return result;
}
开发者ID:kanbang,项目名称:Colt,代码行数:60,代码来源:UTransform.cpp
示例6: createUpdateList
PendingUpdateList UInsertAsLast::createUpdateList(DynamicContext *context) const
{
Node::Ptr node = (Node*)target_->createResult(context)->next(context).get();
if(node->dmNodeKind() != Node::element_string &&
node->dmNodeKind() != Node::document_string)
XQThrow(XPath2TypeMatchException,X("UInsertAsLast::createUpdateList"),
X("It is a type error for the target expression of an insert as last expression not to be a single element "
"or document [err:XUTY0005]"));
Sequence alist(context->getMemoryManager());
Sequence clist(context->getMemoryManager());
Result value = source_->createResult(context);
Item::Ptr item;
while((item = value->next(context)).notNull()) {
if(((Node*)item.get())->dmNodeKind() == Node::attribute_string) {
if(!clist.isEmpty())
XQThrow(ASTException,X("UInsertAsLast::createUpdateList"),
X("Attribute nodes must occur before other nodes in the source expression for an insert as last expression [err:XUTY0004]"));
// b. No attribute node in $alist may have a QName whose implied namespace binding conflicts with a namespace
// binding in the "namespaces" property of $target [err:XUDY0023].
ATQNameOrDerived::Ptr qname = ((Node*)item.get())->dmNodeName(context);
if(qname->getURI() != 0 && *(qname->getURI()) != 0) {
ATAnyURIOrDerived::Ptr uri = FunctionNamespaceURIForPrefix::uriForPrefix(qname->getPrefix(), node, context, this);
if(uri.notNull() && !XPath2Utils::equals(uri->asString(context), qname->getURI())) {
XMLBuffer buf;
buf.append(X("Implied namespace binding for the insert as last expression (\""));
buf.append(qname->getPrefix());
buf.append(X("\" -> \""));
buf.append(qname->getURI());
buf.append(X("\") conflicts with those already existing on the parent element of the target attribute [err:XUDY0023]"));
XQThrow3(DynamicErrorException, X("UInsertInto::createUpdateList"), buf.getRawBuffer(), this);
}
}
alist.addItem(item);
}
else
clist.addItem(item);
}
PendingUpdateList result;
if(!alist.isEmpty()) {
// 3. If $alist is not empty and into is specified, the following checks are performed:
// a. $target must be an element node [err:XUTY0022].
if(node->dmNodeKind() == Node::document_string)
XQThrow(XPath2TypeMatchException,X("UInsertInto::createUpdateList"),
X("It is a type error if an insert expression specifies the insertion of an attribute node into a document node [err:XUTY0022]"));
result.addUpdate(PendingUpdate(PendingUpdate::INSERT_ATTRIBUTES, node, alist, this));
}
if(!clist.isEmpty()) {
result.addUpdate(PendingUpdate(PendingUpdate::INSERT_INTO_AS_LAST, node, clist, this));
}
return result;
}
开发者ID:kanbang,项目名称:Colt,代码行数:59,代码来源:UInsertAsLast.cpp
示例7: createUpdateList
PendingUpdateList UReplaceValueOf::createUpdateList(DynamicContext *context) const
{
Node::Ptr node = (Node*)target_->createResult(context)->next(context).get();
if(node->dmNodeKind() == Node::document_string)
XQThrow(XPath2TypeMatchException,X("UReplaceValueOf::createUpdateList"),
X("The target expression of a replace expression does not return a single "
"node that is not a document node [err:XUTY0008]"));
XMLBuffer buf;
XQDOMConstructor::getStringValue(expr_, buf, context);
// If $target is a comment node, and $string contains two adjacent hyphens or ends with a hyphen, a dynamic error is raised [err:XQDY0072].
if(node->dmNodeKind() == Node::comment_string) {
bool foundOne = false;
for(const XMLCh *str = buf.getRawBuffer(); *str; ++str) {
if(*str == '-') {
if(foundOne) {
XQThrow(DynamicErrorException,X("UReplaceValueOf::createUpdateList"),
X("The replace value of expression would result in a comment node whose content contains two adjacent hyphens [err:XQDY0072]"));
}
else foundOne = true;
}
else {
foundOne = false;
}
}
if(foundOne) {
XQThrow(DynamicErrorException,X("UReplaceValueOf::createUpdateList"),
X("The replace value of expression would result in a comment node whose content ends with a hyphen [err:XQDY0072]"));
}
}
// If $target is a processing instruction node, and $string contains the substring "?>", a dynamic error is raised [err:XQDY0026].
else if(node->dmNodeKind() == Node::processing_instruction_string) {
bool foundQuestion = false;
for(const XMLCh *str = buf.getRawBuffer(); *str; ++str) {
if(*str == '?') {
foundQuestion = true;
}
else {
if(foundQuestion && *str == '>') {
XQThrow(DynamicErrorException,X("UReplaceValueOf::createUpdateList"),
X("The replace value of expression would result in a processing instruction node whose content includes the string \"?>\" [err:XQDY0026]"));
}
foundQuestion = false;
}
}
}
Item::Ptr value = context->getItemFactory()->createString(buf.getRawBuffer(), context);
if(node->dmNodeKind() == Node::element_string) {
return PendingUpdate(PendingUpdate::REPLACE_ELEMENT_CONTENT, node, value, this);
}
else {
return PendingUpdate(PendingUpdate::REPLACE_VALUE, node, value, this);
}
}
开发者ID:xubingyue,项目名称:xqilla,代码行数:59,代码来源:UReplaceValueOf.cpp
示例8: operator
bool operator()(const Node::Ptr& lhs, const Node::Ptr& rhs)
{
auto costFgv1 = lhs->costFgv();
auto costFgv2 = rhs->costFgv();
if (costFgv1 == costFgv2) {
return lhs->time < rhs->time;
}
return costFgv1 > costFgv2;
}
开发者ID:martong,项目名称:nng2014,代码行数:10,代码来源:PrioNodeQueue.hpp
示例9: connect
void ConnectionManager::connect(const Node::Ptr& node, const string& token, bool secure)
{
// don't allow connection if we didn't proceed a handshake
if(!node->isOnline())
{
// do handshake at first
DHT::getInstance()->info(node->getIdentity().getIp(), node->getIdentity().getUdpPort(),
DHT::PING | DHT::MAKE_ONLINE, node->getUser()->getCID(), node->getUdpKey());
return;
}
bool active = ClientManager::getInstance()->isActive();
// if I am not active, send reverse connect to me request
AdcCommand cmd(active ? AdcCommand::CMD_CTM : AdcCommand::CMD_RCM, AdcCommand::TYPE_UDP);
cmd.addParam(secure ? SECURE_CLIENT_PROTOCOL_TEST : CLIENT_PROTOCOL);
if(active)
{
string port = secure ? dcpp::ConnectionManager::getInstance()->getSecurePort() : dcpp::ConnectionManager::getInstance()->getPort();
cmd.addParam(port);
}
cmd.addParam(token);
DHT::getInstance()->send(cmd, node->getIdentity().getIp(), node->getIdentity().getUdpPort(),
node->getUser()->getCID(), node->getUdpKey());
}
开发者ID:eiskaltdcpp,项目名称:eiskaltdcpp,代码行数:28,代码来源:ConnectionManager.cpp
示例10: assert
bool SequenceType::ItemType::matchesSchemaElement(const Node::Ptr &toBeTested, const DynamicContext* context) const
{
// retrieve the type of the element name
assert(m_pName!=NULL);
const XMLCh* elementNS=m_NameURI;
const XMLCh* elementName=m_pName->getName();
SchemaElementDecl *elemDecl=context->getDocumentCache()->getElementDecl(elementNS, elementName);
assert(elemDecl != NULL);
// 1. The name of the candidate node matches the specified ElementName or matches the name of an element in a
// substitution group headed by an element named ElementName.
ATQNameOrDerived::Ptr name = toBeTested->dmNodeName(context);
if(name.isNull()) return false;
const XMLCh *node_uri = ((const ATQNameOrDerived*)name.get())->getURI();
const XMLCh *node_name = ((const ATQNameOrDerived*)name.get())->getName();
if(!(XPath2Utils::equals(elementName, node_name)) ||
!(XPath2Utils::equals(elementNS, node_uri)))
{
// the node doesn't match the ElementName; check if it is in its substitution group
SchemaElementDecl* thisElemDecl=context->getDocumentCache()->getElementDecl(node_uri, node_name);
if(thisElemDecl==NULL) // the node to be tested has no type info
return false;
SchemaElementDecl* rootElemDecl=thisElemDecl->getSubstitutionGroupElem();
bool foundIt=false;
while (rootElemDecl)
{
if (XPath2Utils::equals(rootElemDecl->getBaseName(), elementName) &&
XPath2Utils::equals(context->getDocumentCache()->getSchemaUri(rootElemDecl->getURI()), elementNS))
{
foundIt = true;
break;
}
rootElemDecl = rootElemDecl->getSubstitutionGroupElem();
}
if(!foundIt)
return false;
}
// 2. derives-from(AT, ET) is true, where AT is the type of the candidate node and ET is the type declared for
// element ElementName in the in-scope element declarations.
ComplexTypeInfo* pTypeInfo=elemDecl->getComplexTypeInfo();
if(pTypeInfo && !toBeTested->hasInstanceOfType(pTypeInfo->getTypeUri(), pTypeInfo->getTypeLocalName(), context))
return false;
// 3. Either the nilled property of the candidate node is false, or the element declaration for ElementName in
// the in-scope element declarations is nillable.
if(toBeTested->dmNilled(context).get()->isTrue() &&
!(elemDecl->getMiscFlags() & SchemaSymbols::XSD_NILLABLE))
return false;
return true;
}
开发者ID:kanbang,项目名称:Colt,代码行数:55,代码来源:SequenceType.cpp
示例11: HasIncomingEdgesFromLowerLevel
bool BoundFactsCalculator::HasIncomingEdgesFromLowerLevel(int curOrder, vector<Node::Ptr>& curNodes) {
for (auto nit = curNodes.begin(); nit != curNodes.end(); ++nit) {
Node::Ptr cur = *nit;
NodeIterator nbegin, nend;
cur->ins(nbegin, nend);
for (; nbegin != nend; ++nbegin)
if (analysisOrder[*nbegin] < curOrder) return true;
}
return false;
}
开发者ID:hira-a,项目名称:dyninst,代码行数:11,代码来源:BoundFactCalculator.C
示例12: resolveDocument
bool XercesURIResolver::resolveDocument(Sequence &result, const XMLCh* uri, DynamicContext* context, const QueryPathNode *projection)
{
Node::Ptr doc;
// Resolve the uri against the base uri
const XMLCh *systemId = uri;
XMLURL urlTmp(context->getMemoryManager());
if(urlTmp.setURL(context->getBaseURI(), uri, urlTmp)) {
systemId = context->getMemoryManager()->getPooledString(urlTmp.getURLText());
} else {
systemId = context->getMemoryManager()->getPooledString(uri);
}
// Check in the cache
DOMDocument *found = _documentMap.get((void*)systemId);
// Check to see if we can locate and parse the document
if(found == 0) {
try {
doc = const_cast<DocumentCache*>(context->getDocumentCache())->loadDocument(uri, context, projection);
found = (DOMDocument*)((DOMNode*)doc->getInterface(XercesConfiguration::gXerces));
_documentMap.put((void*)systemId, found);
_uriMap.put((void*)found, const_cast<XMLCh*>(systemId));
}
catch(const XMLParseException& e) {
XMLBuffer errMsg;
errMsg.set(X("Error parsing resource: "));
errMsg.append(uri);
errMsg.append(X(". Error message: "));
errMsg.append(e.getError());
errMsg.append(X(" [err:FODC0002]"));
XQThrow2(XMLParseException,X("XercesContextImpl::resolveDocument"), errMsg.getRawBuffer());
}
}
else {
doc = new XercesNodeImpl(found, (XercesURIResolver*)context->getDefaultURIResolver());
}
if(doc.notNull()) {
result.addItem(doc);
return true;
}
XMLBuffer errMsg;
errMsg.set(X("Error retrieving resource: "));
errMsg.append(uri);
errMsg.append(X(" [err:FODC0002]"));
XQThrow2(XMLParseException,X("XercesContextImpl::resolveDocument"), errMsg.getRawBuffer());
return false;
}
开发者ID:kanbang,项目名称:Colt,代码行数:53,代码来源:XercesURIResolver.cpp
示例13: applyInsertBefore
void DbXmlUpdateFactory::applyInsertBefore(const PendingUpdate &update, DynamicContext *context)
{
const DbXmlNodeImpl *next = (const DbXmlNodeImpl*)update.getTarget().get();
if (!next->isUpdateAble())
return;
Node::Ptr parent = next->dmParent(context);
NsDomNodeRef nextRef = next->getNsDomNode();
applyInserts(update,
(const DbXmlNodeImpl *)parent->getInterface(DbXmlNodeImpl::gDbXml),
nextRef.get(),
context,
false);
}
开发者ID:cajus,项目名称:dbxml-debian,代码行数:13,代码来源:DbXmlUpdateFactory.cpp
示例14:
static
std::string
getDotLabel(Node::Ptr node)
{
if (node)
{
return node->name() == "unnamed" || node->name().find("AutoName$") != std::string::npos
? "\"\""
: "\"" + node->name() + "\"";
}
else
return "\"\"";
}
开发者ID:382309009,项目名称:minko,代码行数:13,代码来源:ASSIMPParserDebug.hpp
示例15: applyReplaceNode
void DbXmlUpdateFactory::applyReplaceNode(const PendingUpdate &update, DynamicContext *context)
{
const DbXmlNodeImpl *target = (const DbXmlNodeImpl*)update.getTarget().get();
if (!target->isUpdateAble())
return;
Node::Ptr parent = target->dmParent(context);
// insert all new nodes *before* the target, then
// mark target for deletion
NsDomNodeRef targetRef = target->getNsDomNode();
applyInserts(update,
(const DbXmlNodeImpl *)parent->getInterface(DbXmlNodeImpl::gDbXml),
targetRef.get(),
context, false);
forDeletion_.insert(target);
}
开发者ID:cajus,项目名称:dbxml-debian,代码行数:15,代码来源:DbXmlUpdateFactory.cpp
示例16: createUpdateList
PendingUpdateList URename::createUpdateList(DynamicContext *context) const
{
Node::Ptr node = (Node*)target_->createResult(context)->next(context).get();
if(node->dmNodeKind() != Node::element_string &&
node->dmNodeKind() != Node::attribute_string &&
node->dmNodeKind() != Node::processing_instruction_string)
XQThrow(XPath2TypeMatchException,X("URename::createUpdateList"),
X("It is a type error for the target expression of a rename expression not to be a single element, "
"attribute or processing instruction [err:XUTY0012]"));
ATQNameOrDerived::Ptr qname = (ATQNameOrDerived*)name_->createResult(context)->next(context).get();
// 3. The following checks are performed for error conditions:
// a. If $target is an element node, the "namespaces" property of $target must not include any namespace binding that conflicts
// with the implied namespace binding of $QName [err:XUDY0023].
if(node->dmNodeKind() == Node::element_string) {
ATAnyURIOrDerived::Ptr uri = FunctionNamespaceURIForPrefix::uriForPrefix(qname->getPrefix(), node, context, this);
if(uri.notNull() && !XPath2Utils::equals(uri->asString(context), qname->getURI())) {
XMLBuffer buf;
buf.append(X("Implied namespace binding for the rename expression (\""));
buf.append(qname->getPrefix());
buf.append(X("\" -> \""));
buf.append(qname->getURI());
buf.append(X("\") conflicts with those already existing on the target element [err:XUDY0023]"));
XQThrow3(DynamicErrorException, X("URename::createUpdateList"), buf.getRawBuffer(), this);
}
}
// b. If $target is an attribute node that has a parent, the "namespaces" property of parent($target) must not include any
// namespace binding that conflicts with the implied namespace binding of $QName [err:XUDY0023].
else if(node->dmNodeKind() == Node::attribute_string) {
Node::Ptr parentNode = node->dmParent(context);
if(parentNode.notNull() && qname->getURI() != 0 && *(qname->getURI()) != 0) {
ATAnyURIOrDerived::Ptr uri = FunctionNamespaceURIForPrefix::uriForPrefix(qname->getPrefix(), parentNode, context, this);
if(uri.notNull() && !XPath2Utils::equals(uri->asString(context), qname->getURI())) {
XMLBuffer buf;
buf.append(X("Implied namespace binding for the rename expression (\""));
buf.append(qname->getPrefix());
buf.append(X("\" -> \""));
buf.append(qname->getURI());
buf.append(X("\") conflicts with those already existing on the parent element of the target attribute [err:XUDY0023]"));
XQThrow3(DynamicErrorException, X("URename::createUpdateList"), buf.getRawBuffer(), this);
}
}
}
// c. If $target is processing instruction node, $QName must not include a non-empty namespace prefix. [err:XUDY0025].
else if(node->dmNodeKind() == Node::processing_instruction_string && !XPath2Utils::equals(qname->getPrefix(), XMLUni::fgZeroLenString))
XQThrow(XPath2TypeMatchException,X("URename::createUpdateList"),
X("The target of a rename expression is a processing instruction node, and the new name "
"expression returned a QName with a non-empty namespace prefix [err:XUDY0025]"));
return PendingUpdate(PendingUpdate::RENAME, node, qname, this);
}
开发者ID:kanbang,项目名称:Colt,代码行数:53,代码来源:URename.cpp
示例17: rand
void
addStar(Node::Ptr root, file::AssetLibrary::Ptr assets, std::vector<Star>& stars)
{
const unsigned int MAX_NUM_STARS = 20;
if (stars.size() == MAX_NUM_STARS)
{
std::cerr << "cannot add more stars." << std::endl;
return;
}
unsigned int numBranches = 4 + rand() % 4;
float outRadius = 0.9f + 0.2f * (rand() / float(RAND_MAX) - 0.5f);
float inRadius = outRadius * (0.5f + 0.1f * (rand() / float(RAND_MAX) - 0.5f));
auto starNode = Node::create("star_" + std::to_string(stars.size()))
->addComponent(Surface::create(
createStarLineGeometry(numBranches, inRadius, outRadius, assets->context()),
material::Material::create("material")
->set("diffuseColor", Color::hslaToRgba(rand() / float(RAND_MAX), 0.75f, 0.6f, 1.0f))
->set("lineThickness", 1.0f + 3.0f * (rand() / float(RAND_MAX))),
assets->effect("line")
))
->addComponent(Transform::create(Matrix4x4::create()->appendRotationZ(2.0f * float(M_PI) * rand() / (float) RAND_MAX)));
stars.push_back(Star());
stars.back().node = starNode;
stars.back().angRate = 0.01f + 0.05f * (rand() / float(RAND_MAX));
root->addChild(stars.back().node);
}
开发者ID:382309009,项目名称:minko,代码行数:32,代码来源:main.cpp
示例18: assert
void
explodeModel(float magnitude,
float previousMagnitude,
Node::Ptr node)
{
assert(fabsf(magnitude) > 1e-6f);
assert(fabsf(previousMagnitude) > 1e-6f);
for (auto& child : node->children())
{
if (child->component<Transform>())
{
auto transform = child->component<Transform>()->matrix();
auto direction = transform->translation();
transform->appendTranslation(direction * (magnitude - previousMagnitude));
explodeModel(magnitude * 0.8f, previousMagnitude * 0.8f, child);
}
else
{
explodeModel(magnitude, previousMagnitude, child);
}
}
}
开发者ID:382309009,项目名称:minko,代码行数:25,代码来源:main.cpp
示例19:
boost::optional<EntityCollection<Cell>>
NodeConnectivity::getCellsAttachedToNode(Node::Ptr const & vertex) const {
NodeCell_t::const_iterator it = node_cells_.find(vertex->id());
if (it == node_cells_.end())
return boost::optional<EntityCollection<Cell>>();
return boost::optional<EntityCollection<Cell>>(it->second);
}
开发者ID:svenschmidt75,项目名称:FiniteVolume2D,代码行数:8,代码来源:NodeConnectivity.cpp
示例20: applyReplaceAttribute
void XercesUpdateFactory::applyReplaceAttribute(const PendingUpdate &update, DynamicContext *context)
{
const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
DOMAttr *domnode = (DOMAttr*)nodeImpl->getDOMNode();
Node::Ptr parentNode = nodeImpl->dmParent(context);
DOMElement *element = domnode->getOwnerElement();
DOMDocument *doc = element->getOwnerDocument();
bool untyped = parentNode->dmNodeKind() == Node::element_string &&
XPath2Utils::equals(parentNode->getTypeName(), DocumentCache::g_szUntyped) &&
XPath2Utils::equals(parentNode->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
Result children = update.getValue();
Item::Ptr item;
while((item = children->next(context)).notNull()) {
const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla);
DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true);
// 1. Error checks:
// a. If the QNames of any two attribute nodes in $replacement have implied namespace bindings that conflict with
// each other, a dynamic error is raised [err:XUDY0024].
// b. If the QName of any attribute node in $replacement has an implied namespace binding that conflicts with a
// namespace binding in the "namespaces" property of parent($target), a dynamic error is raised [err:XUDY0024].
// Checks performed by UpdateFactory
// 2b. If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked
// on each element node in $replacement.
if(!untyped) setTypes(newChild, childImpl->getDOMNode());
// 2a. For each node in $replacement, the parent property is set to parent($target).
// 4a. If $target is an attribute node, the attributes property of parent($target) is modified by removing $target
// and adding the nodes in $replacement (if any).
// 4b. If $target is an attribute node, the namespaces property of parent($target) is modified to include namespace
// bindings for any attribute namespace prefixes in $replacement that did not already have bindings.
element->setAttributeNode((DOMAttr*)newChild);
}
// 3a. $target is marked for deletion.
forDeletion_.insert(domnode);
// 4d. upd:removeType(parent($target)) is invoked.
removeType(element);
// Use parentNode, since the attr replace could have removed the original attr
addToPutSet(parentNode, &update, context);
}
开发者ID:xubingyue,项目名称:xqilla,代码行数:46,代码来源:XercesUpdateFactory.cpp
注:本文中的node::Ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论