void AggregationVisualizerNode::expand(VariableNode* a_pVariableNode, const vector<reflection::Expression*>& a_LeftExpressions) const { a_pVariableNode->setDelegate(o_new(AggregationVariableNodeDelegate)); vector<vector<reflection::Expression*>> groupedVariables; for(size_t i = 0; i<a_LeftExpressions.size(); ++i) { reflection::Expression* pLeftExpression = a_LeftExpressions[i]; reflection::AggregationClass* pAggregationClass = as<reflection::AggregationClass*>(pLeftExpression->getValueType()->removeReference()); o_assert(pAggregationClass); vector<reflection::Expression*> signature; reflection::Expression* pSizeExpression = cplusplus()->qualifiedLookup(pLeftExpression->clone(), "count", nullptr, &signature)->asExpression(); bool ok; size_t count = pSizeExpression->get().as<size_t>(&ok); o_assert(ok); groupedVariables.resize(std::max(groupedVariables.size(), count)); for(size_t i = 0; i<count; ++i) { reflection::Expression* pIndexExpression = o_new(reflection::ConstantExpression)(constant<size_t>(i)); reflection::Expression* pExpression = cplusplus()->solveBinaryOperator("[]", pLeftExpression->clone(), pIndexExpression); o_assert(pExpression); groupedVariables[i].push_back(pExpression); } o_dynamic_delete pSizeExpression; } size_t i = 0; for(;i<groupedVariables.size(); ++i) { VariableNode* pChild = o_new(VariableNode)(lexical_cast<string>(i), groupedVariables[i]); pChild->setDelegate(o_new(AggregationAggregateVariableNodeDelegate)(i, groupedVariables.size())); a_pVariableNode->addChildNode(pChild); } }
Expression* Expression::dereference() const { DataPointerType* pPointerType = m_pValueType->asDataPointerType(); Expression* args[2] = { (Expression*)this, 0 }; if(pPointerType == nullptr) return o_new(BuiltInOperatorExpression)( application()->getBuiltInOperator(e_Operator_Dereference), Type::Invalid(), args, operation_delegate_t()); return o_new(BuiltInOperatorExpression)(application()->getBuiltInOperator(e_Operator_Dereference), pPointerType->removePointer()->addLValueReference(), args, operation_delegate_t(pPointerType, &DataPointerType::dereference)); }
Expression* Expression::address() const { ReferenceType* pReferenceType = m_pValueType->asReferenceType(); Expression* args[2] = { (Expression*)this, 0 }; if(pReferenceType == nullptr) return o_new(BuiltInOperatorExpression)(application()->getBuiltInOperator(e_Operator_Address), Type::Invalid(), args, operation_delegate_t()); return o_new(BuiltInOperatorExpression)(application()->getBuiltInOperator(e_Operator_Address), pReferenceType->removeReference()->addPointer(), args, operation_delegate_t(pReferenceType, &ReferenceType::address)); }
VirtualMemberFunctionTable* VirtualMemberFunctionTable::derive(size_t a_uiSize /*= 0*/) const { if(a_uiSize == 0 OR a_uiSize == m_pMemberFunctions->size()) { return o_new(VirtualMemberFunctionTable)(const_cast<VirtualMemberFunctionTable*>(this)); } o_assert(a_uiSize > m_pMemberFunctions->size()); return o_new(VirtualMemberFunctionTable)(const_cast<VirtualMemberFunctionTable*>(this), a_uiSize); }
Expression* Expression::arrayAccess( Expression* a_pIndexExpression ) { ReferenceType* pReferenceType = m_pValueType->asReferenceType(); Expression* args[2] = { (Expression*)this, a_pIndexExpression }; if(pReferenceType == nullptr OR pReferenceType->getReferencedType()->asArrayType() == nullptr OR pReferenceType->getReferencedType()->asDataPointerType() == nullptr) return o_new(BuiltInOperatorExpression)(application()->getBuiltInOperator(e_Operator_Bracket), Type::Invalid(), args, operation_delegate_t()); Type* pElementType = pReferenceType->getReferencedType()->getUnderlyingType(); Type* pResultType = pReferenceType->asRValueReferenceType() ? (Type*)pElementType->rvalueReferenceType() : pElementType->lvalueReferenceType(); return o_new(BuiltInOperatorExpression)(application()->getBuiltInOperator(e_Operator_Bracket), pResultType, args, operation_delegate_t(pElementType->pointerType(), &DataPointerType::bracket)); }
Expression* Expression::store( Expression* a_pRightExpression ) { ReferenceType* pReferenceType = m_pValueType->asReferenceType(); Expression* args[2] = { (Expression*)this, a_pRightExpression }; if(pReferenceType == nullptr OR pReferenceType->getReferencedType()->asClassType() OR pReferenceType->getReferencedType()->isConst() OR NOT(a_pRightExpression->getValueType()->equals(pReferenceType->getReferencedType()))) return o_new(BuiltInOperatorExpression)(application()->getBuiltInOperator(e_Operator_Assignment), Type::Invalid(), args, operation_delegate_t()); Type* pElementType = pReferenceType->getReferencedType()->getUnderlyingType(); Type* pResultType = pReferenceType->asRValueReferenceType() ? (Type*)pElementType->rvalueReferenceType() : pElementType->lvalueReferenceType(); return o_new(BuiltInOperatorExpression)(application()->getBuiltInOperator(e_Operator_Assignment), pResultType, args, operation_delegate_t(pReferenceType, &ReferenceType::memcpyStoreDelegate)); }
void ClassTypeVisualizerNode::expand( VariableNode* a_pParentNode, const vector<reflection::Expression*>& a_LeftExpressions, reflection::ClassType* a_pClassType) const { // Public Value Members (Properties and InstanceAttributes { auto it = a_pClassType->beginValueMembers(); auto end = a_pClassType->endValueMembers(); for(;it != end;++it) { reflection::ValueMember* pValueMember = *it; if(!m_Filter(a_pParentNode, pValueMember)) continue; vector<reflection::Expression*> expressions; for(auto it = a_LeftExpressions.begin(); it != a_LeftExpressions.end(); ++it) { reflection::Expression* pLeftExpression = *it; expressions.push_back(cplusplus()->qualifiedLookup(pLeftExpression->clone(), pValueMember->getName(), nullptr, nullptr, 0)->asExpression()); } VariableNode* pVariableNode = o_new(VariableNode)(nameOf(pValueMember), expressions); pVariableNode->setIcon(QIcon(iconOf(pValueMember).c_str())); pVariableNode->setRange(pValueMember->getRange()); pVariableNode->setModifiers(pValueMember->getModifiers()); a_pParentNode->addChildNode(pVariableNode); } } }
void Expression::ancestorChanged( LanguageElement* a_pLanguageElement ) { if(getEnclosingBlock()) { Class* pClass = getValueType()->removeRValueReference()->asClass(); if(pClass) { void* pStorageAddress = evalStorage(); o_assert(pStorageAddress); Expression* pThis = (o_new(ConstantExpression)(phantom::constant<void*>(pStorageAddress)))->convert(getValueType()->pointerType())->dereference(); Statement* pLifeTimeStatement = evaluateLifeTime(); o_assert(pLifeTimeStatement); CallExpression* pDestructionExpression = o_new(CallExpression)(getValueType()->asClass()->getDestructor(), pThis); pLifeTimeStatement->addTemporaryObjectDestruction(pDestructionExpression); } } }
void CullSystem::BuildOctTree( TreeNode<VisCell>& node ) { if (node.GetDepth() == m_Depth ) { return; } node.GetChildren().resize(8); for( int i = 0 ;i<8; i++ ) { node.GetChildren()[i] = o_new( TreeNode<VisCell> ); node.GetChildren()[i]->SetParent( &node ); node.GetChildren()[i]->SetDepth( node.GetDepth()+1 ); node.GetChildren()[i]->SetIndex(i); VisCell& parentCell = node.GetContent(); aabbox& box = parentCell.GetAABB(); aabbox baseBox; point middle = (box.GetMax()+box.GetMin())*0.5f; float xHalf = box.GetMax().X() - middle.X(); float yHalf = box.GetMax().Y() - middle.Y(); float zHalf = box.GetMax().Z() - middle.Z(); baseBox.SetMax( box.GetMax() ); baseBox.SetMin( middle ); point& pMax = baseBox.GetMax(); point& pMin = baseBox.GetMin(); if ( i%2==1 ) { pMax.X()-=xHalf; pMin.X()-=xHalf; } if ( i>=4 ) { pMax.Y()-=yHalf; pMin.Y()-=yHalf; if (i>=6) { pMax.Z()-=zHalf; pMin.Z()-=zHalf; } } else if( i>=2 ) { pMax.Z()-=zHalf; pMin.Z()-=zHalf; } VisCell& childCell = node.GetChildren()[i]->GetContent(); childCell.SetAABB(baseBox); BuildOctTree( *node.GetChildren()[i]); } }
int main() { orientdb *oh; orientdb_con *oc; struct timeval tv; int rc; char str[O_ERR_MAXLEN]; long x; oh = o_new(); o_debug_setlevel(oh, ORIENT_DEBUG); o_debug_sethook(oh, &my_debug); //rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "192.168.1.100", "2424"); rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "127.0.0.1", "2424"); if (rc != O_OK) { o_strerr(rc, str, O_ERR_MAXLEN); fprintf(stderr, "Error preparing connections (%i): %s\n", rc, str); o_free(oh); return rc; } // this user will be used to execute administrative commands to orientdb rc = o_prepare_user(oh, ORIENT_ADMIN, "root", "test"); // this user will be used on database open to execute commands to the db rc = o_prepare_user(oh, ORIENT_USER, "admin", "admin"); // set a connection timeout of 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // try to create the connection with orientdb. NULL if a problem is encountered oc = o_connect(oh, &tv, 0); if (!oc) { o_free(oh); return 1; } // set a connection timeout of 5 seconds tv.tv_sec = 15; tv.tv_usec = 0; //rc = bin_dbopen(oh, oc, &tv, 0, "demo"); rc = o_bin_dbopen(oh, oc, &tv, 0, "test"); tv.tv_sec = 15; tv.tv_usec = 0; x = o_bin_dataclustercount(oh, oc, &tv, 0, 6); fprintf(stderr, "Cluster count: %ld\n", x); tv.tv_sec = 15; tv.tv_usec = 0; rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh); return 0; }
Expression* Expression::convert( Type* a_pOutputType, int conversionType /*= e_implicit_conversion*/, LanguageElement* a_pContextScope ) const { if(a_pOutputType->removeQualifiers()->equals(m_pValueType->removeQualifiers()) && conversionType == e_implicit_conversion) return const_cast<Expression*>(this); conversion* conv = getValueType()->conversionTo(a_pOutputType, conversionType, a_pContextScope); if(conv == nullptr) return o_new(BuiltInConversionExpression)(const_cast<Expression*>(this), nullptr, conversionType); Expression* pConversion = conv->convert(const_cast<Expression*>(this)); o_assert(pConversion); delete conv; return pConversion; }
void AggregationClass::fetchExpressions( Expression* a_pInstanceExpression, vector<Expression*>& out, filter a_Filter, uint a_uiSerializationMask ) const { if(a_Filter(getAggregateClass()->pointerType())) { void* pInstance = a_pInstanceExpression->loadEffectiveAddress(); size_t count = this->count(pInstance); for(size_t i = 0; i<count; ++i) { out.push_back(o_new(AggregationInsertRemoveExpression)(a_pInstanceExpression, o_new(ConstantExpression)(phantom::constant<size_t>(i)), const_cast<AggregationClass*>(this))); } } }
void GraphicMgr::Init() { // here we will init the current pipeline and cull sys; m_pPipeline = o_new(FixedRenderPipeline); m_pPipeline->Init(); m_pRenderer = o_new(FixedRenderer);//hack for (int i = 0;i<RENDERTYPECOUNT;i++) { m_RenderableArries.push_back(std::list<Ptr<Renderable>>()); } // here we will setup the culling system m_pCullSystem = o_new(CullSystem); m_pCullSystem->SetDepth(3); aabbox cullArea; cullArea.SetMax(point( 500.f, 500.f, 500.f,1.f)); cullArea.SetMin(point(-500.f,-500.f,-500.f,1.f)); m_pCullSystem->SetCullArea(cullArea); m_pCullSystem->Init(); }
VariableWidgetEditor* ComponentVariableNodeDelegate::createEditor() const { reflection::ComponentClass* pComponentClass = m_pVariableNode->getValueType()->removeConstReference()->asComponentClass(); vector<reflection::Class*> currentClasses; size_t count = m_pVariableNode->getExpressionCount(); reflection::Class* pCurrentClass = nullptr; for(size_t i = 0; i<count; ++i) { void* pOldValue = nullptr; pComponentClass->get(m_pVariableNode->getExpression(i)->loadEffectiveAddress(), &pOldValue); if(pOldValue) { reflection::Class* pClass = classOf(pOldValue); if(pCurrentClass != nullptr AND pClass != pCurrentClass) { pCurrentClass = nullptr; break; } pCurrentClass = pClass; } } return o_new(ClassComboBoxEditor)(pComponentClass->getPointedClass(), pCurrentClass, NOT(m_pVariableNode->hasModifier(o_mandatory))); }
void Vision::feel_vision_update (CObject* parent, Fvector& P, float dt, float vis_threshold) { // B-A = objects, that become visible if (!seen.empty()) { xr_vector<CObject*>::iterator E = std::remove(seen.begin(),seen.end(),parent); seen.resize (E-seen.begin()); { diff.resize (_max(seen.size(),query.size())); xr_vector<CObject*>::iterator E = std::set_difference( seen.begin(), seen.end(), query.begin(),query.end(), diff.begin() ); diff.resize(E-diff.begin()); for (u32 i=0; i<diff.size(); i++) o_new(diff[i]); } } // A-B = objects, that are invisible if (!query.empty()) { diff.resize (_max(seen.size(),query.size())); xr_vector<CObject*>::iterator E = std::set_difference( query.begin(),query.end(), seen.begin(), seen.end(), diff.begin() ); diff.resize(E-diff.begin()); for (u32 i=0; i<diff.size(); i++) o_delete(diff[i]); } // Copy results and perform traces query = seen; o_trace (P,dt,vis_threshold); }
RemoveDataCommand::RemoveDataCommand(serialization::DataBase* a_pDataBase, const vector<uint>& a_Guids) : DataBaseCommand(a_pDataBase) { m_Guids = a_Guids; setName("Remove"); vector<phantom::data> allData; m_pDataBase->rootNode()->fetchDataCascade(allData); for(size_t i = 0; i<m_Guids.size(); ++i) { phantom::data d = m_pDataBase->getData(m_Guids[i]); o_assert(!d.isNull()); for(auto it = allData.begin(); it != allData.end(); ++it) { if(m_pDataBase->getComponentDataOwner(*it) == d) m_Guids.push_back(m_pDataBase->getGuid(*it)); } } std::sort(m_Guids.begin(), m_Guids.end()); m_Guids.resize(std::unique(m_Guids.begin(), m_Guids.end())-m_Guids.begin()); for(auto it = m_Guids.begin(); it != m_Guids.end(); ++it) { pushCommand(o_new(UndoCommand)((m_pDataBase->getNode(*it) ? "Node '" : "Data '") + m_pDataBase->getAttributeValues(m_pDataBase->getData(*it).address())[0] + "' ("+lexical_cast<string>((void*)(*it))+")" )); } }
void FlagsVisualizerNode::expand( VariableNode* a_pParent, const vector<reflection::Expression*>& a_LeftExpressions ) const { map<reflection::Constant*, vector<reflection::Expression*>> flagsExpressions; for(auto it = a_LeftExpressions.begin(); it != a_LeftExpressions.end(); ++it) { reflection::Expression* pLeftExpression = *it; if(NOT(pLeftExpression->hasEffectiveAddress())) continue; reflection::Enum* pEnum = pLeftExpression->getValueType()->removeReference()->removeConst()->getOwner()->asTemplateSpecialization()->getArgument("Enum")->asEnum(); for(size_t i = 0; i<pEnum->getConstantCount(); ++i) { flagsExpressions[pEnum->getConstant(i)].push_back( cplusplus()->qualifiedLookup( cplusplus()->solveBinaryOperator("[]", pLeftExpression->clone(), o_new(reflection::ConstantExpression)(pEnum->getConstant(i))) , "value", nullptr, nullptr, 0)->asExpression() ); } } for(auto it = flagsExpressions.begin(); it != flagsExpressions.end(); ++it) { VariableNode* pNode = o_new(VariableNode)(nameOf(it->first), it->second); pNode->setIcon(QIcon(iconOf(it->first).c_str())); a_pParent->addChildNode(pNode); } }
int main() { orientdb *oh; orientdb_con *oc; struct timeval tv; ODOC_OBJECT *odoc; int rc; char str[O_ERR_MAXLEN]; long position; int i; oh = o_new(); o_debug_setlevel(oh, ORIENT_DEBUG); //o_debug_setlevel(oh, ORIENT_CRITICAL); o_debug_sethook(oh, &my_debug); //rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "192.168.1.100", "2424"); rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "127.0.0.1", "2424"); if (rc != O_OK) { o_strerr(rc, str, O_ERR_MAXLEN); fprintf(stderr, "Error preparing connections (%i): %s\n", rc, str); o_free(oh); return rc; } // this user will be used to execute administrative commands to orientdb rc = o_prepare_user(oh, ORIENT_ADMIN, "root", "test"); // this user will be used on database open to execute commands to the db rc = o_prepare_user(oh, ORIENT_USER, "admin", "admin"); // set a connection timeout of 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // try to create the connection with orientdb. NULL if a problem is encountered oc = o_connect(oh, &tv, 0); if (!oc) { o_free(oh); return 1; } // set a connection timeout of 5 seconds tv.tv_sec = 15; tv.tv_usec = 0; rc = o_bin_dbopen(oh, oc, &tv, 0, "test"); tv.tv_sec = 15; tv.tv_usec = 0; // initialize a new document with the classname called "Class" ODOC_INITIALIZE_DOCUMENT(odoc, NULL); if (!odoc) { fprintf(stderr, "RECORD_CREATE: problem initializating document\n"); tv.tv_sec = 5; tv.tv_usec = 0; rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh); return 0; } odoc_setraw(odoc, "nully:,shorty:10s,inty:20,embeddeddocy:(stringyembeddy:\"Hello world!! This is a string\",intyembeddy:12345),binny:_SGVsbG8gd29ybGQhISBUaGlzIGlzIGEgc3RyaW5n_,collecty:[]", strlen("nully:,shorty:10s,inty:20,embeddeddocy:(stringyembeddy:\"Hello world!! This is a string\",intyembeddy:12345),binny:_SGVsbG8gd29ybGQhISBUaGlzIGlzIGEgc3RyaW5n_,collecty:[]")); tv.tv_sec = 3; tv.tv_usec = 0; position = o_bin_recordcreate(oh, oc, &tv, 0, 6, odoc, O_RECORD_DOC, O_RECSYNC); fprintf(stderr, "RECORD_CREATE: %ld\n", position); i = ODOC_FREE_DOCUMENT(odoc); tv.tv_sec = 10; tv.tv_usec = 0; rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh); return 0; }
void ComponentVisualizerNode::expand(VariableNode* a_pVariableNode, const vector<reflection::Expression*>& a_LeftExpressions) const { a_pVariableNode->setDelegate(o_new(ComponentVariableNodeDelegate)); }
InvalidExpression* InvalidExpression::clone() const { return o_new(InvalidExpression)(m_pValueType); }
UpdateComponentDataCommand* UpdateComponentDataCommand::clone() const { return o_new(UpdateComponentDataCommand)(m_pDataBase, m_Guids); }
serialization::Bundle* PolymorphicArrayClass::createBundle( serialization::BundleNode* a_pOwnerNode ) const { return o_new(serialization::native::TBundle<util::PolymorphicArray>)(a_pOwnerNode); }
Type* PolymorphicArrayClass::createConstType() const { return o_new(native::TConstType<PolymorphicArrayClass>)(const_cast<PolymorphicArrayClass*>(this)); }
PropertyExpression* PropertyExpression::clone() const { return o_new(PropertyExpression)(m_pLeftExpression, m_pProperty); }
int main() { orientdb *oh; orientdb_con *oc; struct timeval tv; int rc; char str[O_ERR_MAXLEN]; ODOC_OBJECT *odoc; short cluster_id; long cluster_position; // create the orientdb object oh = o_new(); // setup debug hook, so that my_debug() finction will be invoked each time the library has to say something useful o_debug_setlevel(oh, ORIENT_DEBUG); o_debug_sethook(oh, &my_debug); // prepare the connection to the database (no real connection will be made) rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "127.0.0.1", "2424"); if (rc != O_OK) { o_strerr(rc, str, O_ERR_MAXLEN); fprintf(stderr, "Error preparing connections (%i): %s\n", rc, str); o_free(oh); return rc; } // this user will be used to execute administrative commands to orientdb rc = o_prepare_user(oh, ORIENT_ADMIN, "root", "test"); // this user will be used on database open to execute commands to the db rc = o_prepare_user(oh, ORIENT_USER, "admin", "admin"); // set a connection timeout of 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // try to create the connection with orientdb. NULL if a problem is encountered oc = o_connect(oh, &tv, 0); if (!oc) { o_free(oh); return 1; } // set a timeout of 10 seconds tv.tv_sec = 10; tv.tv_usec = 0; // Open a database named "test" rc = o_bin_dbopen(oh, oc, &tv, 0, "test"); // set a timeout of 15 seconds tv.tv_sec = 15; tv.tv_usec = 0; // simulating a record id like #6:0 cluster_id = 6; cluster_position = 0; // get the document from the database odoc = o_bin_recordload(oh, oc, &tv, 0, cluster_id, cluster_position, "*:-1"); if (!odoc) { fprintf(stderr, "RECORD_LOAD: problem getting record\n"); tv.tv_sec = 5; tv.tv_usec = 0; rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh); return 0; } fprintf(stderr, "RECORD_LOAD: got a document: %s\n", odoc_getraw(odoc, NULL)); // free the returned document when you no longer need it ODOC_FREE_DOCUMENT(odoc); tv.tv_sec = 5; tv.tv_usec = 0; rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh); return 0; }
UndoCommand* UndoCommand::clone() const { return o_new(UndoCommand)(m_strName); }
AggregationInsertRemoveExpression* AggregationInsertRemoveExpression::clone() const { return o_new(AggregationInsertRemoveExpression)(m_pLeftExpression, m_pIndexExpression, m_pAggregationClass); }
CompositionRemoveComponentDataCommand* CompositionRemoveComponentDataCommand::clone() const { return o_new(CompositionRemoveComponentDataCommand)(m_pDataBase, m_uiIndex, m_uiOwnerGuid, m_strCompositionExpression); }
AggregationGetSetExpression* AggregationGetSetExpression::clone() const { return o_new(AggregationGetSetExpression)(m_pLeftExpression, m_pIndexExpression, m_pAggregationClass); }
LocalVariableInitializationStatement* LocalVariableInitializationStatement::clone() const { return o_new(LocalVariableInitializationStatement)(m_pLocalVariable, m_pRightExpression); }