TEST(Internal, CheckInfo) { int xdim = 10; int ydim = 8; int xoff = 1; int yoff = 2; int xnum = 5; int ynum = 3; af::array a = af::randu(10, 8); af::array b = a(af::seq(xoff, xoff + xnum - 1), af::seq(yoff, yoff + ynum - 1)); af::dim4 strides = getStrides(b); af::dim4 dims = b.dims(); dim_t offset = xoff + yoff * xdim; ASSERT_EQ(dims[0], xnum); ASSERT_EQ(dims[1], ynum); ASSERT_EQ(isOwner(a), true); ASSERT_EQ(isOwner(b), false); ASSERT_EQ(getOffset(b), offset); ASSERT_EQ(strides[0], 1); ASSERT_EQ(strides[1], xdim); ASSERT_EQ(strides[2], xdim * ydim); ASSERT_EQ(getRawPtr(a), getRawPtr(b)); }
RS_Entity* RS_DimLinear::clone() const { RS_DimLinear* d = new RS_DimLinear(*this); d->setOwner(isOwner()); d->initId(); d->detach(); return d; }
T *Array<T>::device() { getQueue().sync(); if (!isOwner() || getOffset() || data.use_count() > 1) { *this = copyArray<T>(*this); } return this->get(); }
T* device() { if (!isOwner() || getOffset() || data.use_count() > 1) { *this = Array<T>(dims(), get(), true, true); } return this->get(); }
QString ChannelNick::tooltip() const { QString strTooltip; QTextStream tooltip( &strTooltip, QIODevice::WriteOnly ); tooltip << "<qt>"; tooltip << "<table cellspacing=\"5\" cellpadding=\"0\">"; m_nickInfo->tooltipTableData(tooltip); QStringList modes; if(isOp()) modes << i18n("Operator"); if(isAdmin()) modes << i18n("Admin"); if(isOwner()) modes << i18n("Owner"); if(isHalfOp()) modes << i18n("Half-operator"); if(hasVoice()) modes << i18n("Has voice"); //Don't show anything if the user is just a normal user //if(modes.empty()) modes << i18n("A normal user"); if(!modes.empty()) { tooltip << "<tr><td><b>" << i18n("Mode") << ":</b></td><td>" << modes.join(QStringLiteral(", ")) << "</td></tr>"; } tooltip << "</table></qt>"; //qDebug() << strTooltip ; //if(!dirty) return QString(); return strTooltip; }
/** * Detaches shallow copies and creates deep copies of all subentities. * This is called after cloning entity containers. */ void RS_EntityContainer::detach() { QList<RS_Entity*> tmp; bool autoDel = isOwner(); RS_DEBUG->print("RS_EntityContainer::detach: autoDel: %d", (int)autoDel); setOwner(false); // make deep copies of all entities: for (RS_Entity* e=firstEntity(); e!=NULL; e=nextEntity()) { if (!e->getFlag(RS2::FlagTemp)) { tmp.append(e->clone()); } } // clear shared pointers: entities.clear(); setOwner(autoDel); // point to new deep copies: for (int i = 0; i < tmp.size(); ++i) { RS_Entity* e = tmp.at(i); entities.append(e); e->reparent(this); } }
RS_Entity* RS_DimAligned::clone() const{ RS_DimAligned* d = new RS_DimAligned(*this); d->setOwner(isOwner()); d->initId(); d->detach(); return d; }
RS_Entity* RS_Spline::clone() const{ RS_Spline* l = new RS_Spline(*this); l->setOwner(isOwner()); l->initId(); l->detach(); return l; }
RS_Entity* RS_DimRadial::clone() const { RS_DimRadial* d = new RS_DimRadial(*this); d->setOwner(isOwner()); d->initId(); d->detach(); return d; }
RS_Entity* RS_Text::clone() const{ RS_Text* t = new RS_Text(*this); t->setOwner(isOwner()); t->initId(); t->detach(); return t; }
RS_Entity* RS_Block::clone() const { RS_Block* blk = new RS_Block(*this); blk->setOwner(isOwner()); blk->detach(); blk->initId(); return blk; }
RS_Entity* RS_Leader::clone() const{ RS_Leader* p = new RS_Leader(*this); p->setOwner(isOwner()); p->initId(); p->detach(); return p; }
RS_Entity* RS_Insert::clone() const{ RS_Insert* i = new RS_Insert(*this); i->setOwner(isOwner()); i->initId(); i->detach(); return i; }
RS_Entity* RS_Polyline::clone() const { RS_Polyline* p = new RS_Polyline(*this); p->setOwner(isOwner()); p->initId(); p->detach(); return p; }
RS_Entity* RS_DimDiametric::clone() const { RS_DimDiametric* d = new RS_DimDiametric(*this); d->setOwner(isOwner()); d->initId(); d->detach(); return d; }
RS_Entity* RS_Hatch::clone() const{ RS_Hatch* t = new RS_Hatch(*this); t->setOwner(isOwner()); t->initId(); t->detach(); t->hatch = nullptr; return t; }
RS_Entity* RS_Hatch::clone() { RS_Hatch* t = new RS_Hatch(*this); t->setOwner(isOwner()); t->initId(); t->detach(); t->hatch = NULL; return t; }
VOID CLinkedQueue::purge() { if (isOwner ()){ CLinkedList<CObjectEx*>::CListElement const* ptr; for (ptr = list.head(); ptr != 0; ptr = ptr->next) delete ptr->datum; } list.purge (); m_uCount = 0; }
RS_Entity* RS_Hatch::clone() const{ RS_DEBUG->print(RS_Debug::D_DEBUGGING, "RS_Hatch::clone()"); RS_Hatch* t = new RS_Hatch(*this); t->setOwner(isOwner()); t->initId(); t->detach(); t->update(); // t->hatch = nullptr; RS_DEBUG->print(RS_Debug::D_DEBUGGING, "RS_Hatch::clone(): OK"); return t; }
bool deleteFileWithPermissions(string fileName, string nickname) { if (!isSaved(fileName)) throw accessError(NOT_SAVED); if (!isOwner(fileName, nickname)) throw accessError(NOT_OWNER); string fileDirectory = getFilePath(fileName); remove((fileDirectory + '\\' + fileName).c_str()); string permFileName = fileDirectory + '\\' + fileName + "-perm.dat"; remove(permFileName.c_str()); string diffFileName = fileDirectory + '\\' + fileName + "-diff.dat"; remove(diffFileName.c_str()); _rmdir(fileDirectory.c_str()); return true; }
TEST(Internal, Linear) { af::array c; { af::array a = af::randu(10, 8); // b is just pointing to same underlying data // b is an owner; af::array b = a; ASSERT_EQ(isOwner(b), true); // C is considered sub array // C will not be an owner c = a(af::span); ASSERT_EQ(isOwner(c), false); } // Even though a and b are out of scope, c is still not an owner { ASSERT_EQ(isOwner(c), false); } }
void VolumeURLListProperty::loadVolume(const std::string& url, bool invalidateUI /*=true*/) throw (tgt::FileException, std::bad_alloc) { if (!containsURL(url)) { LWARNING("loadVolume(): passed URL not contained by this property: " << url); return; } // delete volume, if already loaded and owned by the property if (getVolume(url) && isOwner(url)) delete getVolume(url); handleMap_.erase(url); ownerMap_.erase(url); ProgressBar* progressBar = getProgressBar(); if (progressBar) { progressBar->setTitle("Loading volume"); progressBar->setProgressMessage("Loading volume ..."); } VolumeSerializerPopulator serializerPopulator(progressBar); VolumeBase* handle = serializerPopulator.getVolumeSerializer()->read(VolumeURL(url)); if (progressBar) progressBar->hide(); if (handle) { // url may have been altered by loading routine if (url != handle->getOrigin().getURL()) { bool selected = isSelected(url); selectionMap_.erase(url); selectionMap_[handle->getOrigin().getURL()] = selected; for (size_t i=0; i<value_.size(); i++) { if (value_[i] == url) { value_[i] = handle->getOrigin().getURL(); break; } } } handleMap_[handle->getOrigin().getURL()] = handle; ownerMap_[handle->getOrigin().getURL()] = true; } if(invalidateUI) invalidate(); }
void TransFuncListProperty::removeVolume(VolumeBase* handle) { tgtAssert(handle, "null pointer passed"); std::string url = handle->getOrigin().getURL(); if (!containsURL(url)) { LWARNING("removeVolume(): passed handle's URL not contained by this property: " << url); return; } if ((getVolume(url) == handle) && isOwner(url)) { delete handle; } handleMap_.erase(url); ownerMap_[url] = false; invalidate(); }
// // If players are to be serviced, then // - if there is room in tables, send player there // - if no room, decide if we should spawn table // int CWaitingList::tick(long now) { if (!isOwner()) { // This waiting list is owned by another Lounge // Server instance return 0; } if (CLounge::Inst()->getShutdown()) { printf("Server is shutting down, waiting list not serviced.\n"); return 0; } printf(" Waiting list %d has %d players waiting.\n", queueNumber_, players_.size()); const int TimeBetweenSpawns = 60; if (state_ == WS_Spawning && (now - spawnTime_ > TimeBetweenSpawns)) { // more than N seconds has passed since // last spawn state_ = WS_Servicing; } if (state_ == WS_Servicing) { // If we have more players in queue than the // spawn threshold, spawn new table if (players_.size() >= GetTableSpawnThreshold(tables_.size()) ) { state_ = WS_Spawning; CLounge::Inst()->spawnTable(pGame_->getGameType(), getGameType(), // queueIndex! getTableMax(), getLo(), getHi(), pGame_->isHiLoSplit()); spawnTime_ = now; } } return 0; }
void MoleculeURLListProperty::loadMolecule(const std::string& url) throw (tgt::FileException, std::bad_alloc) { if (!containsURL(url)) { LWARNING("loadMolecule(): passed URL not contained by this property: " << url); return; } // delete molecule, if already loaded and owned by the property if (getMolecule(url) && isOwner(url)) delete getMolecule(url); handleMap_.erase(url); ownerMap_.erase(url); ProgressBar* progressBar = getProgressBar(); if (progressBar) { progressBar->setTitle("Loading molecule"); progressBar->setMessage("Loading molecule ..."); } Molecule* handle = MoleculeIO::read(MoleculeURL(url)); if (handle) { // url may have been altered by loading routine if (url != handle->getOrigin().getURL()) { bool selected = isSelected(url); selectionMap_.erase(url); selectionMap_[handle->getOrigin().getURL()] = selected; for (size_t i=0; i<value_.size(); i++) { if (value_[i] == url) { value_[i] = handle->getOrigin().getURL(); break; } } } handleMap_[handle->getOrigin().getURL()] = handle; ownerMap_[handle->getOrigin().getURL()] = true; } invalidate(); }
//############################################################################## //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # //############################################################################## xHashMap::Node* xHashMap::delFromList(xObject* key,Node* root) { Node* tmp = root; Node* prev = NULL; while(tmp != NULL) { if(tmp->key->equals(*key)) { Node* tmpNext = tmp->next; if(isOwner()) { if(tmp->data != tmp->key) delete tmp->key; delete tmp->data; } else { if(tmp->data != tmp->key) delete tmp->key; } delete tmp; m_count--; if(prev != NULL) { prev->next = tmp->next; return root; } else return tmpNext; } prev = tmp; tmp = tmp->next; } return root; }
//############################################################################## //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # //############################################################################## xHashMap::Node* xHashMap::addInList(xObject* data,xObject* key,Node* root) { Node* tmp = root; for(;;) { if(tmp == NULL) { m_count++; return new Node(data,key); } else if(tmp->next == NULL) { tmp->next = new Node(data,key); m_count++; return root; } //if duplicate, substitute else if(tmp->key->equals(*key)) { if(isOwner()) { if(tmp->data != tmp->key) delete tmp->key; delete tmp->data; } else { if(tmp->data != tmp->key) delete tmp->key; } tmp->data = data; return root; } tmp = tmp->next; } }
/** * Detaches shallow copies and creates deep copies of all subentities. * This is called after cloning entity containers. */ void RS_EntityContainer::detach() { QList<RS_Entity*> tmp; bool autoDel = isOwner(); RS_DEBUG->print("RS_EntityContainer::detach: autoDel: %d", (int)autoDel); setOwner(false); // make deep copies of all entities: for(auto e: entities){ if (!e->getFlag(RS2::FlagTemp)) { tmp.append(e->clone()); } } // clear shared pointers: entities.clear(); setOwner(autoDel); // point to new deep copies: for(auto e: tmp){ entities.append(e); e->reparent(this); } }
//############################################################################## //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # //############################################################################## xLogHandler::~xLogHandler() { if(isOwner()) delete m_formatter; }
bool zValidatorAllButOwner::isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser) { return !isOwner(possibleUser->Player(), owners); }