/*private*/ void Root::insertContained(Node *tree, const Envelope *itemEnv, void *item) { assert(tree->getEnvelope()->contains(itemEnv)); /** * Do NOT create a new quad for zero-area envelopes - this would lead * to infinite recursion. Instead, use a heuristic of simply returning * the smallest existing quad containing the query */ bool isZeroX = IntervalSize::isZeroWidth(itemEnv->getMinX(), itemEnv->getMaxX()); bool isZeroY = IntervalSize::isZeroWidth(itemEnv->getMinY(), itemEnv->getMaxY()); NodeBase *node; if (isZeroX || isZeroY) { node = tree->find(itemEnv); } else { node = tree->getNode(itemEnv); } node->add(item); }
void LinkListBase::destroyAll() { NodeBase* n; // Excluding the dummy node mHead and mTail while(mTail != (n = mHead->mNext)) { n->destroyThis(); } }
void LinkListBase::removeAll() { NodeBase* n; // Excluding the dummy node mHead and mTail while(mTail != (n = mHead->mNext)) { n->removeThis(); } }
void Control_::destroy() { object_ = 0; manage_ = 0; NodeBase* n = dep_; while (n) { NodeBase* next = n->link()->next_; n->notify(false); n = next; } dep_ = 0; cunref(); }
// _____________________________________________________________________ // Méthode appelée à chaque fois qu'un noeud change de status de communication // (passe de OK à KO ou l'inverse) void CXbeeNetworkMessenger::on_node_com_status_changed() { NodeBase **node_list = m_xbee_messenger.m_database.getNodesList(); for (int i=0; i<m_xbee_messenger.m_database.getNodeCount(); i++) { NodeBase *node = node_list[i]; if (node) { QString led_name= "led_XbeeMsngNodePresent." + QString(node->getName()); QLed *led = m_ihm.findChild<QLed *>(led_name); // recherche l'objet LED par son nom if (led) { led->setValue(node->isPresent()); } } } }
WriteBufferOperation *OutputSocket::findAttachedWriteBufferOperation() const { unsigned int index; for (index = 0; index < this->m_connections.size(); index++) { SocketConnection *connection = this->m_connections[index]; NodeBase *node = connection->getToNode(); if (node->isOperation()) { NodeOperation *operation = (NodeOperation *)node; if (operation->isWriteBufferOperation()) { return (WriteBufferOperation *)operation; } } } return NULL; }
void OutputSocket::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { NodeBase *node = this->getNode(); if (node->isOperation()) { NodeOperation *operation = (NodeOperation *)node; if (operation->isResolutionSet()) { resolution[0] = operation->getWidth(); resolution[1] = operation->getHeight(); } else { operation->determineResolution(resolution, preferredResolution); operation->setResolution(resolution); } } }
void LinkListBase::insertBefore(NodeBase& newNode, const NodeBase& beforeThis) { MCD_ASSERT(!newNode.isInList()); MCD_ASSERT("Parameter 'beforeThis' should be in this list" && beforeThis.mNext == nullptr || beforeThis.getList() == this ); beforeThis.mPrev->mNext = &newNode; newNode.mPrev = beforeThis.mPrev; const_cast<NodeBase&>(beforeThis).mPrev = &newNode; newNode.mNext = const_cast<NodeBase*>(&beforeThis); newNode.mList = this; ++mCount; }
NodeIterator::NodeIterator(NodeBase &start, const char *name) { _stack.push_back(start.getNode()); _type = OSG::FieldContainerFactory::the()->findType(name); }
void Root::insertContained(Node *tree, Interval *itemInterval, void* item) { using geos::index::quadtree::IntervalSize; assert(tree->getInterval()->contains(itemInterval)); /** * Do NOT create a new node for zero-area intervals - this would lead * to infinite recursion. Instead, use a heuristic of simply returning * the smallest existing node containing the query */ bool isZeroArea=IntervalSize::isZeroWidth(itemInterval->getMin(), itemInterval->getMax()); NodeBase *node; if (isZeroArea) node=tree->find(itemInterval); else node=tree->getNode(itemInterval); node->add(item); }
// _____________________________________________________________________ // Construit automatiquement la page de diagnostique de présenc // en fonction des informations renseignées sur les nodes dans la database void CXbeeNetworkMessenger::initDiagPresencePage() { int ligne=0; NodeBase **node_list = m_xbee_messenger.m_database.getNodesList(); for (int i=0; i<m_xbee_messenger.m_database.getNodeCount(); i++) { NodeBase *node = node_list[i]; if (node) { QString data_name= "XbeeMsngNodePresent." + QString(node->getName()); m_application->m_data_center->write(data_name, QVariant(node->isPresent())); CData *data = m_application->m_data_center->getData(data_name); if (data) { connect(data, SIGNAL(valueChanged(QVariant)), this, SLOT(on_node_com_status_changed())); } QLed *led; led = new QLed(m_ihm.ui.tab_diag); led->setObjectName("led_" + data_name); led->setMaximumSize(QSize(30, 30)); led->setMinimumSize(QSize(20, 20)); led->setValue(node->isPresent()); led->setOnColor(QLed::Green); led->setOffColor(QLed::Grey); led->setShape(QLed::Circle); led->setToolTip(data_name); m_ihm.ui.layout_led_presence->addWidget(led, ligne, 0, 1, 1); QLabel *label = new QLabel(m_ihm.ui.tab_diag); label->setObjectName("lbl_" + data_name); label->setText(node->getName()); label->setToolTip("Node ID=" + QString::number(node->getID())); m_ihm.ui.layout_led_presence->addWidget(label, ligne, 1, 1, 1); ligne++; } } }
void Runtime::Evaluate(NodeBase* node,WQState* state) { if (node->GetType() == NT_EXPRESSION) { ExpressionNode* expnode = (ExpressionNode*)node; Evaluate(expnode->Expression, state); } else if (node->GetType() == NT_ASSIGNMENT) { AssignmentNode* assignment = (AssignmentNode*)node; //Evaluate the right side Evaluate((NodeBase*)assignment->RightSide, state); CurrentLineNumber = assignment->GetLineNumber(); if (assignment->TargetType == AT_VARIABLE) { VariableNode* var = assignment->LeftSideVariable; Evaluate(var, state); WQObject* left =state->GetReturnObject(); Evaluate(assignment->RightSide, state); PerformAssignment(left, assignment->AssignmentOperator, state->GetReturnObject()); environment->SetVariable(*var->Value,left ); } else if (assignment->TargetType == AT_ELEMENT) { ElementNode* ele = assignment->LeftSideElement; Evaluate(ele->Variable, state); WQObject* lsobj = state->GetReturnObject(); if (lsobj->Type == DT_LIST) { Evaluate(ele->key, state); //get the index long index = state->GetReturnObject()->GetIntValue(); WQObject *left = lsobj->GetListElement(index); Evaluate(assignment->RightSide, state); PerformAssignment(left, assignment->AssignmentOperator, state->GetReturnObject()); lsobj->SetListElement(index,*left); } else if (lsobj->Type == DT_DICTIONARY) { Evaluate(ele->key, state); //get the index string key = state->GetReturnObject()->ToString(); WQObject *left = lsobj->GetDictionaryElement(key); Evaluate(assignment->RightSide, state); PerformAssignment(left, assignment->AssignmentOperator, state->GetReturnObject()); } //environment->GetVariable() } } else if (node->GetType() == NT_VARIABLE) { VariableNode* varnode = (VariableNode*)node; // //printf(varnode->Value->c_str()); WQObject* obj=environment->GetVariable(*varnode->Value); if (obj == NULL) { state->ReturnReference(environment->CreateVariable(*(varnode->Value))); } else { state->ReturnReference(obj); } } //else if (node->GetType() == NT_ELEMENT) //{ // ElementNode* elenode = (ElementNode*)node; // Evaluate(elenode->key, state); // int index = state->GetReturnObject()->GetIntValue(); // WQObject* obj = environment->GetVariable(*elenode->Variable->Value)->GetListElement(index); // state->ReturnReference(obj); //} else if (node->GetType() == NT_STRING) { StringNode* strnode = (StringNode*)node; state->GetReturnObject()->SetStringValue( *strnode->Value); } else if (node->GetType() == NT_BOOLEAN) { BooleanNode * boolnode = (BooleanNode*)node; state->GetReturnObject()->SetBoolValue(boolnode->Value); } else if (node->GetType() == NT_OPERATION) { OperationNode* opnode = (OperationNode*)node; // list<ExpressionNode*>::iterator expit = opnode->Terms->begin(); list<string*>::iterator opit = opnode->Operators->begin(); stack<string*> lowops; stack<WQObject*> lowexps; WQObject left, right; if (opnode->Terms->size() - opnode->Operators->size() != 1) { throw SYNTAX_INVALID_EXPRESSION; } Evaluate(*expit, state); left.GetAssigned(state->GetReturnObject()); expit++; WQObject* term; string* op; while (expit!=opnode->Terms->end()) { op = *opit; Evaluate( *expit,state); //notice I new an object, needs to be delete later term = new WQObject; term->GetAssigned(state->GetReturnObject()); //if sees - or +, always push , means save it for later if (*op == "-" || *op == "+" ) { lowops.push(op); lowexps.push(term); } else { //if it's a * / %, pop the one element from the stack and evaluate, then push it back if (lowexps.size() > 0) { // WQObject* exp= lowexps.top(); Calculate(*exp, op,*term); } else { //the most left one, which is not in the stack Calculate(left, op, *term); } } //Evaluate(term, state); //Calculate(left, op, *state->GetReturnObject()); ++expit; ++opit; } while (lowops.size() != 0) { WQObject* term= lowexps.top(); string* op = lowops.top(); Calculate(left, op, *term); delete term; lowexps.pop(); lowops.pop(); } state->GetReturnObject()->GetAssigned(&left); } else if (node->GetType() == NT_IF) { IfNode* ifnode = (IfNode*)node; map<ExpressionNode*, CodeBlockNode*>::iterator it = ifnode->IfBlock->begin(); bool anyifexecuted = false; if (it != ifnode->IfBlock->end()) { Evaluate(it->first,state); if (state->GetReturnObject()->Type != DT_BOOLEAN) { throw RUNTIME_EXPECTING_BOOLEAN; } if (state->GetReturnObject()->GetBoolValue()) { EnterNewEnvironment(); Evaluate(it->second, state); BackToParentEnvironment(); } anyifexecuted = true; } it++; if (anyifexecuted == false) { while (it != ifnode->IfBlock->end()) { Evaluate(it->first, state); if (state->GetReturnObject()->Type != DT_BOOLEAN) { throw RUNTIME_EXPECTING_BOOLEAN; } if (state->GetReturnObject()->GetBoolValue()) { EnterNewEnvironment(); Evaluate(it->second, state); BackToParentEnvironment(); break; } it++; } } if (anyifexecuted==false) Evaluate(ifnode->ElseBlock, state); } else if (node->GetType() == NT_WHILE) { WhileNode* whilenode = (WhileNode*)node; while (true) { Evaluate(whilenode->Condition, state); if (state->GetReturnObject()->Type != DT_BOOLEAN) { throw RUNTIME_EXPECTING_BOOLEAN; } if (state->GetReturnObject()->GetBoolValue() == false) { break; } state->BreakOccurred = false; EnterNewEnvironment(); Evaluate(whilenode->CodeBlock, state); BackToParentEnvironment(); if (state->BreakOccurred) break; } } else if (node->GetType() == NT_COMPARISON) { ComparisonNode* comnode = (ComparisonNode*)node; Evaluate(comnode->LeftSide, state); WQObject lhs; lhs.GetAssigned(state->GetReturnObject()); Evaluate(comnode->RightSide, state); bool result=false; if (*comnode->Operator == OP_EQUAL) { result = lhs == *state->GetReturnObject(); } else if (*comnode->Operator == OP_GREATER) { result = lhs > *state->GetReturnObject(); } else if (*comnode->Operator ==OP_LESS) { result = lhs < *state->GetReturnObject(); } else if (*comnode->Operator ==OP_GREATEQUAL) { result = lhs >= *state->GetReturnObject(); } else if (*comnode->Operator == OP_LESSEQUAL) { result = lhs <= *state->GetReturnObject(); } state->GetReturnObject()->SetBoolValue(result); } else if (node->GetType() == NT_LOGIC) { LogicNode* lgnode = (LogicNode*)node; stack<string> lowops; stack<bool> lowexps; bool left; list<string*>::iterator opit = lgnode->Operators->begin(); list<ExpressionNode*>::iterator expit = lgnode->Expressions->begin(); string* op; ExpressionNode* exp; exp = *expit; expit++; Evaluate(exp, state); left=(state->GetReturnObject()->GetBoolValue()); while (expit != lgnode->Expressions->end()) { op = *opit; exp = *expit; if (opit==lgnode->Operators->end()) { throw SYNTAX_INVALID_EXPRESSION; } Evaluate(exp, state); if (*op == OP_NOT) { lowexps.push(!state->GetReturnObject()->GetBoolValue()); } else if (*op == OP_AND) { //if there is something in the stack, deal with the stack first if (lowexps.size() > 0) { lowexps.top() = lowexps.top()&&state->GetReturnObject()->GetBoolValue(); } else left = left&&state->GetReturnObject()->GetBoolValue(); } //if it's ||, it has lower priority than &&, so push it to the stack for later else if (*op == OP_OR) { lowexps.push(state->GetReturnObject()->GetBoolValue()); lowops.push(*op); } opit++; expit++; } while (lowexps.size() > 0) { string op = lowops.top(); bool val = lowexps.top(); //it must be OR operation!! //if (op == OP_OR) //{ left = left || val; //} lowops.pop(); lowexps.pop(); } state->GetReturnObject()->SetBoolValue(left); /* printf("Logic Node(Expressions:"); for (list<ExpressionNode*>::iterator expit = lgnode->Expressions->begin(); expit != lgnode->Expressions->end(); expit++) { Evaluate(*expit, state); } printf(", Logic Operators:"); for (list<string*>::iterator lgit = lgnode->Operators->begin(); lgit != lgnode->Operators->end(); lgit++) { printf((*lgit)->c_str()); } printf(")"); */ } else if (node->GetType() == NT_FLOAT) { FloatNode* fltnode = (FloatNode*)node; state->GetReturnObject()->SetFloatValue(fltnode->Value); } else if (node->GetType() == NT_INTEGER) { IntegerNode* intnode = (IntegerNode*)node; state->GetReturnObject()->SetIntValue(intnode->Value); } else if (node->GetType() == NT_FUNCTIONCALL) { FunctionCallNode* funcnode = (FunctionCallNode*)node; CurrentLineNumber = funcnode->GetLineNumber(); //retrive the target function from the function library WQFunction func = environment->Functions->Get(funcnode->FunctionName); if (func == NULL) { throw string(RUNTIME_FUNCTION_NOT_DEFINED) + ": "+*funcnode->FunctionName; } //check the parameter size of the function call state->ParamSize = funcnode->Parameters->size(); //evaluate each of them and send them to the current state for (list<ExpressionNode*>::iterator it = funcnode->Parameters->begin(); it != funcnode->Parameters->end(); it++) { Evaluate(*it, state); //string str = state->GetReturnObject()->ToString(); //if returning a reference, so don't copy it if (state->ReferencedObject!=NULL) state->AddParam(state->GetReturnObject()); //it's returning a copy, so I can copy it it else { WQObject* param = new WQObject; param->GetAssigned(state->GetReturnObject()); state->AddParam(param); } } state->ReturnNull(); //call the function func(state); //clear the parameters in the list state->ClearParams(); } else if (node->GetType() == NT_CREATELIST) { CreateListNode* lsnode = (CreateListNode*)node; WQObject result; result.InitList(); for (list<ExpressionNode*>::iterator it = lsnode->Parameters->begin(); it != lsnode->Parameters->end(); it++) { Evaluate(*it, state); result.AppendListValue(*state->GetReturnObject()); } state->GetReturnObject()->GetAssigned(&result); } else if (node->GetType() == NT_CREATEDICT) { CreateDictionaryNode* dictnode = (CreateDictionaryNode*)node; WQObject result; result.InitDictionary(); state->GetReturnObject()->GetAssigned(&result); } else if (node->GetType() == NT_FOR) { ForNode* fornode = (ForNode*)node; Evaluate(fornode->IterableVariable, state); WQObject iterable; iterable.GetAssigned(state->GetReturnObject()); if (iterable.Type != DT_LIST) throw RUNTIME_ITERATE_NON_LIST_VARIABLE; vector<WQObject*>* iterablelist = iterable.GetListValue(); for (int i = 0; i < iterablelist->size(); i++) { EnterNewEnvironment(); WQObject tempvar; tempvar.GetAssigned(iterablelist->at(i)); environment->CreateVariable(*fornode->TempVariable->Value)->GetAssigned( &tempvar); Evaluate(fornode->CodeBlock, state); BackToParentEnvironment(); if (state->BreakOccurred) { break; } } } else if (node->GetType() == NT_SLICING) { SlicingNode* slicenode = (SlicingNode*)node; //has start index if (slicenode->HasStartIndex) { Evaluate(slicenode->StartIndex, state); if (state->GetReturnObject()->Type != DT_INTEGER) { throw RUNTIME_NON_INTERGER_INDEX; } long startIndex = (long)state->GetReturnObject()->GetIntValue(); if (slicenode->HasEndIndex) { Evaluate(slicenode->EndIndex, state); if (state->GetReturnObject()->Type != DT_INTEGER) { throw RUNTIME_NON_INTERGER_INDEX; } long endIndex = (long)state->GetReturnObject()->GetIntValue(); //<variable>[<exp>:<exp>] Evaluate(slicenode->Variable, state); WQObject *lsvar = state->GetReturnObject(); lsvar->GetSlicing(startIndex,endIndex,state->GetReturnObject()); } else { //<variable>[<exp>:] Evaluate(slicenode->Variable, state); WQObject *lsvar = state->GetReturnObject(); lsvar->GetSlicingWithLeftIndexValue(startIndex,state->GetReturnObject()); } } //no start index else { if (slicenode->HasEndIndex) { Evaluate(slicenode->EndIndex, state); if (state->GetReturnObject()->Type != DT_INTEGER) { throw RUNTIME_NON_INTERGER_INDEX; } long endIndex = (long)state->GetReturnObject()->GetIntValue(); //<variable>[:<exp>] Evaluate(slicenode->Variable, state); WQObject *lsvar = state->GetReturnObject(); lsvar->GetSlicingWithRightIndexValue(endIndex,state->GetReturnObject()); } else { //<variable>[:] //just copy the list Evaluate(slicenode->Variable, state); WQObject cpyobj; cpyobj.GetAssigned(state->GetReturnObject()); state->GetReturnObject()->GetAssigned(&cpyobj); } } } else if (node->GetType() == NT_CODEBLOCK) { CodeBlockNode* program = (CodeBlockNode*)node; for (list<NodeBase*>::iterator it = program->Statements->begin(); it != program->Statements->end(); it++) { NodeBase* nxt = *it; if (nxt->GetType() == NT_BREAK) { state->BreakOccurred = true; break; } Evaluate(*it, state); } } }
NodeBase* node_factory::create_node(const uint32_t id, const string& name, const string& type, const string& desc, const key_map_t& keymap) { NodeBase* node = NULL; if (strcasecmp(type.c_str(), NODE_ANSWER) == 0) { node = new(std::nothrow) NodeAnswer(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_HANGUP) == 0) { node = new(std::nothrow) NodeHangup(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_PLAY) == 0) { node = new(std::nothrow) NodePlay(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_RECORD) == 0) { node = new(std::nothrow) NodeRecord(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_DIGIT) == 0) { node = new(std::nothrow) NodeGetDigits(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_DIAL) == 0) { node = new(std::nothrow) NodeDial(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_BRIDGE) == 0) { node = new(std::nothrow) NodeBridge(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_ASSIGN) == 0) { node = new(std::nothrow) NodeAssign(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_COMP) == 0) { node = new(std::nothrow) NodeCompare(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_DB) == 0) { node = new(std::nothrow) NodeDB(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_HTTP) == 0) { node = new(std::nothrow) NodeHttp(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_INI) == 0) { node = new(std::nothrow) NodeReadIni(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_BRIDGEEX) == 0) { node = new(std::nothrow) node_bridgeex_t(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_JSONGET) == 0) { node = new(std::nothrow) NodeJsonGet(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_PLAYNUM) == 0) { node = new(std::nothrow) NodePlayNum(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_WAITEVENT) == 0) { node = new(std::nothrow) NodeWaitEvent(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_REGTIMER) == 0) { node = new(std::nothrow) NodeRegTimer(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_STOPTIMER) == 0) { node = new(std::nothrow) NodeStopTimer(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_WRITELOG) == 0) { node = new(std::nothrow) NodeWriteLog(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_STOPMEDIA) == 0) { node = new(std::nothrow) NodeStopMedia(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_STOPRECORD) == 0) { node = new(std::nothrow) NodeStopRecord(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_JSONGET_ARRAY) == 0) { node = new(std::nothrow) NodeJsonGetArray(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_JSONGET_ARRAYLEN) == 0) { node = new(std::nothrow) NodeJsonGetArrayLen(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_REQUEST_AGENT) == 0) { node = new(std::nothrow) NodeRequestAgent(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_TRANS_AGENT) == 0) { node = new(std::nothrow) NodeTransAgent(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_CANCEL_AGENT) == 0) { node = new(std::nothrow) NodeCancelAgent(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_SET_ASSOCIATEDATA) == 0) { node = new(std::nothrow) NodeSetAssociateData(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_GET_ASSOCIATEDATA) == 0) { node = new(std::nothrow) NodeGetAssociateData(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_REQUEST_RESULT) == 0) { node = new(std::nothrow) NodeRequestResponseCompare(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_WHATWEEKDAY) == 0) { node = new(std::nothrow) NodeWhatWeekday(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), NODE_MAKECALL) == 0) { node = new(std::nothrow) NodeMakeCall(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), _s_node_broadcast) == 0) { node = new(std::nothrow) ivr::NodeBroadcast(id, name, type, desc, keymap); } else if (strcasecmp(type.c_str(), _s_node_broadcast_num) == 0) { node = new(std::nothrow) ivr::NodeBroadcastNum(id, name, type, desc, keymap); }else if (strcasecmp(type.c_str(), _s_node_base64_encode) == 0) { node = new(std::nothrow) NodeBase64Encode(id, name, type, desc, keymap); }else if (strcasecmp(type.c_str(), _s_node_base64_decode) == 0) { node = new(std::nothrow) NodeBase64Decode(id, name, type, desc, keymap); }else if (strcasecmp(type.c_str(), _s_node_set_appdata) == 0) { node = new(std::nothrow) NodeSetAppData(id, name, type, desc, keymap); } if (node && (!node->load_other())) { delete node; node = NULL; } return node; }
void traverseSeq(OSG::GraphOpSeq& g, NodeBase& b) { OSG::NodePtr p = b.getNode(); g.run(p); }
void traverse(OSG::GraphOp& g, NodeBase& b) { OSG::NodePtr p = b.getNode(); g.traverse(p); }
uint32_t InboundChanThread::execute(void* taskparam) { string callid, ani, dnis; NodeBase* node = NULL; inbound_script_t script; std::string err; channel_info_t cinfo; // clear flow ptr script.flow = NULL; uint32_t ret = 0; std::string curr; dnis = ((inbound_script_t*)_param)->dnis; ostringstream ost; fs_opr_t* opr = NULL; IVR_DEBUG("inbound_execute event queue pointer %lu, queue size: %lu", (uint64_t)(((session_dynamic_resource_t*)taskparam)->event_queue), ((session_dynamic_resource_t*)taskparam)->event_queue->size()); ivr_session_id_t ivr_s_id; session_dynamic_resource_t* resource = NULL; IvrInstanceManager* mgr = NULL; if (!check_capability()) { ret = 1; // add to data collection IvrCallDataCollection::instance().new_inbound_call(((inbound_script_t*)_param)->ani , ((inbound_script_t*)_param)->dnis, ((inbound_script_t*)_param)->callid); goto END; } //inbound_script 对象 作为流程执行run函数的参数param { rw_lock_t lock(g_inbound_conf_rwlock, false); if (!lock.locked()) { IVR_WARN("failed lock!"); IvrCallDataCollection::instance().new_inbound_call(((inbound_script_t*)_param)->ani , ((inbound_script_t*)_param)->dnis, ((inbound_script_t*)_param)->callid); goto CHAN_END; } if (g_inbound_conf.dnis_script_map.find(dnis) == g_inbound_conf.dnis_script_map.end()) { if (!g_inbound_conf.has_default) { IVR_WARN("没有找到可以匹配的流程(dnis=%s),且默认流程未配置或未正确加载", dnis.c_str()); ret = 1; IvrCallDataCollection::instance().new_inbound_call(((inbound_script_t*)_param)->ani , ((inbound_script_t*)_param)->dnis, ((inbound_script_t*)_param)->callid); goto CHAN_END; } else { IVR_TRACE("没有找到可以匹配的流程(dnis=%s),启动默认流程", dnis.c_str()); script = g_inbound_conf.default_script; if (SUCCESS != FlowManager::attach_flow(g_inbound_conf.default_script.flow, &script.flow)) { ret = 1; IvrCallDataCollection::instance().new_inbound_call(((inbound_script_t*)_param)->ani , ((inbound_script_t*)_param)->dnis, ((inbound_script_t*)_param)->callid); goto CHAN_END; } } } else { IVR_TRACE("找到匹配的流程(dnis=%s)", dnis.c_str()); script = g_inbound_conf.dnis_script_map[dnis]; if (SUCCESS != FlowManager::attach_flow(g_inbound_conf.dnis_script_map[dnis].flow, &script.flow)) { ret = 1; IvrCallDataCollection::instance().new_inbound_call(((inbound_script_t*)_param)->ani , ((inbound_script_t*)_param)->dnis, ((inbound_script_t*)_param)->callid); goto CHAN_END; } } } // init ims information script.imsno = (uint32_t) - 1; script.imssid = 0; script.requestId = 0; script.type = ((inbound_script_t*)_param)->type; script.fid = ((inbound_script_t*)_param)->fid; script.ani = ((inbound_script_t*)_param)->ani; script.dnis = ((inbound_script_t*)_param)->dnis; script.callid = ((inbound_script_t*)_param)->callid; script.callsource = ((inbound_script_t*)_param)->callsource; script.channel_name = ((inbound_script_t*)_param)->channel_name; script.channel_id = ((inbound_script_t*)_param)->channel_id; script.trunck = ((inbound_script_t*)_param)->trunck; ivr_tools_t::build_vars(script.flow->name_var_map, script.name_var_map); // don't add channel information here // if answer the call, will add information //创建实例 resource = (session_dynamic_resource_t*)taskparam; mgr = IvrInstanceManager::get_instance(); if (IVR_SUCCESS != mgr->create_ivr_instance(script.type, script.fid, &ivr_s_id, *resource, script.callid.c_str())) { IVR_WARN("创建实例失败(dnis=%s)", script.dnis.c_str()); IvrCallDataCollection::instance().new_inbound_call(((inbound_script_t*)_param)->ani , ((inbound_script_t*)_param)->dnis, ((inbound_script_t*)_param)->callid); goto CHAN_END; } //添加uuid if (IVR_SUCCESS != mgr->add_uuid(ivr_s_id, script.callid)) { IVR_WARN("创建实例失败(dnis=%s)", script.dnis.c_str()); mgr->destroy_ivr_instance(ivr_s_id); IvrCallDataCollection::instance().new_inbound_call(((inbound_script_t*)_param)->ani , ((inbound_script_t*)_param)->dnis, ((inbound_script_t*)_param)->callid); goto CHAN_END; } //注册uuid if (fs_mgr_t::instance()->fetch_opr(script.fid, &opr) == IVR_SUCCESS) { if (NULL == opr || IVR_SUCCESS != opr->register_session(script.callid.c_str(), ivr_s_id)) { IVR_WARN("添加uuid失败(dnis=%s)", script.dnis.c_str()); mgr->destroy_ivr_instance(ivr_s_id); fs_mgr_t::instance()->free_opr(&opr); IvrCallDataCollection::instance().new_inbound_call(((inbound_script_t*)_param)->ani , ((inbound_script_t*)_param)->dnis, ((inbound_script_t*)_param)->callid); goto CHAN_END; } fs_mgr_t::instance()->free_opr(&opr); } else { IVR_WARN("注册实例失败(dnis=%s)", script.dnis.c_str()); mgr->destroy_ivr_instance(ivr_s_id); IvrCallDataCollection::instance().new_inbound_call(((inbound_script_t*)_param)->ani , ((inbound_script_t*)_param)->dnis, ((inbound_script_t*)_param)->callid); goto CHAN_END; } // update channel info cinfo.callsource = _param->callsource; cinfo.channel_id = _param->channel_id; cinfo.channel_name = _param->channel_name; IvrInstanceManager::get_instance()->add_channel_info(script.callid, cinfo); //设置script内容 script.session_id = ivr_s_id; script.timer = resource->timer; curr = ivr_tools_t::get_current_second(); *(string*)script.name_var_map[SYS_VAR[sys_var_t::ANI]].pvalue = script.ani; *(string*)script.name_var_map[SYS_VAR[sys_var_t::DNIS]].pvalue = script.dnis; *(string*)script.name_var_map[SYS_VAR[sys_var_t::CALLID]].pvalue = script.callid; *(string*)script.name_var_map[SYS_VAR[sys_var_t::TRUNCK]].pvalue = script.trunck; *(string*)script.name_var_map[SYS_VAR[sys_var_t::RECORD_FILE]].pvalue = ""; *(string*)script.name_var_map[SYS_VAR[sys_var_t::HANGUP_CAUSE]].pvalue = "user_hangup"; *(string*)script.name_var_map[SYS_VAR[sys_var_t::CALL_BEGIN_TIME]].pvalue = curr; *(string*)script.name_var_map[SYS_VAR[sys_var_t::CALL_ANSWER_TIME]].pvalue = curr; //运行流程 node = script.flow->id_node_map[script.flow->begin_id]; ost << "\n================"; ost << "ANI:\t" << script.ani << endl; ost << "DNIS:\t" << script.dnis << endl; ost << "CALLID:\t" << script.callid << endl; ost << "TRUNCK:\t" << script.trunck << endl; ost << "FID:\t" << script.fid << endl; ost << "SESSIONID:\t" << script.session_id << endl; ost << "================"; IVR_DEBUG("%s", ost.str().c_str()); // add to data collection IvrCallDataCollection::instance().new_inbound_call(script.ani, script.dnis, script.session_id, script.callid); #if IVR_ENABLE_DEBUGER IvrDebuger::get_instance()->report(this, "startup", script, node); #endif do { #if IVR_ENABLE_DEBUGER if (IvrDebuger::get_instance()->wait(this) == 1) { break; } #endif node = node->run(&script); #if IVR_ENABLE_DEBUGER IvrDebuger::get_instance()->report(this, "runnode", script, node); #endif } while (node && !g_stopped); if (!node) { CallDataManager* calldata_manager = CallDataManager::get_instance(); calldata_manager->push_calldata(script.bill_info().c_str()); } //set state IvrCallDataCollection::instance().set_state(script.session_id, IvrInboundCall::EXITFLOW, ""); ivr_tools_t::destroy_vars(script.name_var_map); mgr->destroy_ivr_instance(ivr_s_id); ims_mgr_t::get_instance()->unbind_session_id(ivr_s_id); if (resource->timer != NULL) { // clear all timer resource->timer->clear_all_timer(); } CHAN_END: FlowManager::detach_flow(&script.flow); { rw_lock_t lock(g_inbound_chan_rwlock, true); if (lock.locked()) { --g_inbound_chan_num; } else { err = "lock inbound rwlock failed"; } } if (err.length()) { IVR_WARN("%s", err.c_str()); } END: return ret; }
void subRef(NodeBase &node) { OSG::subRef(node.getNode()); }
void addRef(NodeBase &node) { OSG::addRef(node.getNode()); }
void Group::subChild(NodeBase &child) { // OSG::beginEditCP(_node); _node->subChild(child.getNode()); // OSG::endEditCP(_node); }
NodeBase makeShared(NodeBase &node) { return NodeBase(node.getNode()->getCore()); }
QSGNode* NodeConnectionLines::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) { if (!m_nodeObject) return nullptr; const QVector<QPointer<NodeBase>>& connectedNodes = m_nodeObject->getConnectedNodes(); int connectionCount = connectedNodes.size(); // -------------------- Prepare QSG Nodes: QSGNode* parentNode = oldNode; if (!oldNode) { parentNode = new QSGNode(); } else { // update color in case it changed: // FIXME: is there a more efficient way to do this? for (int i=0; i<parentNode->childCount(); ++i) { QSGGeometryNode* childNode = static_cast<QSGGeometryNode*>(parentNode->childAtIndex(i)); if (!childNode) continue; QSGFlatColorMaterial* material = static_cast<QSGFlatColorMaterial*>(childNode->material()); if (!material) continue; material->setColor(m_color); } } // adapt child count: int childCount = parentNode->childCount(); if (childCount < connectionCount) { for (int i=0; i<(connectionCount - childCount); ++i) { QSGGeometryNode* node = new QSGGeometryNode; QSGGeometry* geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 3); geometry->setDrawingMode(GL_TRIANGLE_STRIP); node->setGeometry(geometry); node->setFlag(QSGNode::OwnsGeometry); QSGFlatColorMaterial* material = new QSGFlatColorMaterial; material->setColor(m_color); node->setMaterial(material); node->setFlag(QSGNode::OwnsMaterial); parentNode->appendChildNode(node); } } else if (childCount > connectionCount) { for (int i=0; i<(childCount - connectionCount); ++i) { parentNode->removeChildNode(parentNode->childAtIndex(0)); } } Q_ASSERT(parentNode->childCount() == connectionCount); // calculate common start point: const QPointF p0(width(), height() / 2); double widthOffset = m_lineWidth / 2; //const QPointF posInScene = mapToScene(QPointF(0, 0)); for (int i=0; i<connectionCount; ++i) { NodeBase* otherNode = connectedNodes[i]; if (!otherNode) continue; QQuickItem* otherGuiItem = otherNode->getGuiItem(); if (!otherGuiItem) continue; const QPointF p3 = mapFromItem(otherGuiItem, QPointF(-otherGuiItem->width() / 2, otherGuiItem->height() / 2)); int handleLength = std::max(50, std::min(int(p3.x() - p0.x()), 80)); const QPointF p1(p0.x() + handleLength, p0.y()); const QPointF p2(p3.x() - handleLength, p3.y()); // calculate reasonable segment count: int segmentCount = qMax(16.0, qMin(qAbs(p3.y() - p0.y()) / 25, 50.0)); int verticesCount = segmentCount * 2; QSGGeometryNode* qsgNode = static_cast<QSGGeometryNode*>(parentNode->childAtIndex(i)); if (!qsgNode) continue; QSGGeometry* geometry = qsgNode->geometry(); if (!geometry) continue; geometry->allocate(verticesCount); QSGGeometry::Point2D* vertices = geometry->vertexDataAsPoint2D(); // triangulate cubic bezier curve: for (int i = 0; i < segmentCount; ++i) { // t is the position on the line: const qreal t = i / qreal(segmentCount - 1); // pos is the point on the curve at "t": const QPointF pos = calculateBezierPoint(t, p0, p1, p2, p3); // normal is the normal vector at that point const QPointF normal = normalFromTangent(calculateBezierTangent(t, p0, p1, p2, p3)); // first is a point offsetted in the normal direction by lineWidth / 2 from pos const QPointF first = pos - normal * widthOffset; // ssecond is a point offsetted in the negative normal direction by lineWidth / 2 from pos const QPointF second = pos + normal * widthOffset; // add first and second as vertices to this geometry: vertices[i*2].set(first.x(), first.y()); vertices[i*2+1].set(second.x(), second.y()); } // tell Scene Graph that this items needs to be drawn: qsgNode->markDirty(QSGNode::DirtyGeometry); } return parentNode; }