コード例 #1
0
ファイル: internal.cpp プロジェクト: Brainiarc7/arrayfire
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));
}
コード例 #2
0
ファイル: rs_dimlinear.cpp プロジェクト: Azen2011/LibreCAD
RS_Entity* RS_DimLinear::clone() const {
	RS_DimLinear* d = new RS_DimLinear(*this);
	d->setOwner(isOwner());
	d->initId();
	d->detach();
	return d;
}
コード例 #3
0
ファイル: Array.cpp プロジェクト: umar456/arrayfire
T *Array<T>::device() {
    getQueue().sync();
    if (!isOwner() || getOffset() || data.use_count() > 1) {
        *this = copyArray<T>(*this);
    }
    return this->get();
}
コード例 #4
0
ファイル: Array.hpp プロジェクト: DeepCV/arrayfire
 T* device()
 {
     if (!isOwner() || getOffset() || data.use_count() > 1) {
         *this = Array<T>(dims(), get(), true, true);
     }
     return this->get();
 }
コード例 #5
0
ファイル: channelnick.cpp プロジェクト: KDE/konversation
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;
}
コード例 #6
0
/**
 * 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);
    }
}
コード例 #7
0
RS_Entity* RS_DimAligned::clone() const{
	RS_DimAligned* d = new RS_DimAligned(*this);
	d->setOwner(isOwner());
	d->initId();
	d->detach();
	return d;
}
コード例 #8
0
RS_Entity* RS_Spline::clone() const{
    RS_Spline* l = new RS_Spline(*this);
    l->setOwner(isOwner());
    l->initId();
    l->detach();
    return l;
}
コード例 #9
0
ファイル: rs_dimradial.cpp プロジェクト: Ngassa/LibreCAD
RS_Entity* RS_DimRadial::clone() const {
	RS_DimRadial* d = new RS_DimRadial(*this);
	d->setOwner(isOwner());
	d->initId();
	d->detach();
	return d;
}
コード例 #10
0
ファイル: rs_text.cpp プロジェクト: PlastecProfiles/LibreCAD
RS_Entity* RS_Text::clone() const{
	RS_Text* t = new RS_Text(*this);
	t->setOwner(isOwner());
	t->initId();
	t->detach();
	return t;
}
コード例 #11
0
ファイル: rs_block.cpp プロジェクト: Ngassa/LibreCAD
RS_Entity* RS_Block::clone() const {
    RS_Block* blk = new RS_Block(*this);
    blk->setOwner(isOwner());
    blk->detach();
    blk->initId();
    return blk;
}
コード例 #12
0
ファイル: rs_leader.cpp プロジェクト: Azen2011/LibreCAD
RS_Entity* RS_Leader::clone() const{
	RS_Leader* p = new RS_Leader(*this);
	p->setOwner(isOwner());
	p->initId();
	p->detach();
	return p;
}
コード例 #13
0
ファイル: rs_insert.cpp プロジェクト: CERobertson/LibreCAD
RS_Entity* RS_Insert::clone() const{
	RS_Insert* i = new RS_Insert(*this);
	i->setOwner(isOwner());
	i->initId();
	i->detach();
	return i;
}
コード例 #14
0
ファイル: rs_polyline.cpp プロジェクト: chenchizhao/LibreCAD
RS_Entity* RS_Polyline::clone() const {
	RS_Polyline* p = new RS_Polyline(*this);
	p->setOwner(isOwner());
	p->initId();
	p->detach();
	return p;
}
コード例 #15
0
ファイル: rs_dimdiametric.cpp プロジェクト: Aly1029/LibreCAD
RS_Entity* RS_DimDiametric::clone() const {
	RS_DimDiametric* d = new RS_DimDiametric(*this);
	d->setOwner(isOwner());
	d->initId();
	d->detach();
	return d;
}
コード例 #16
0
ファイル: rs_hatch.cpp プロジェクト: rmamba/LibreCAD
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;
}
コード例 #17
0
ファイル: rs_hatch.cpp プロジェクト: dvstrom/LibreCAD
RS_Entity* RS_Hatch::clone() {
    RS_Hatch* t = new RS_Hatch(*this);
    t->setOwner(isOwner());
    t->initId();
    t->detach();
        t->hatch = NULL;
    return t;
}
コード例 #18
0
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;
}
コード例 #19
0
ファイル: rs_hatch.cpp プロジェクト: Aly1029/LibreCAD
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;
}
コード例 #20
0
ファイル: Deleting.cpp プロジェクト: utkillr/VerController
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;
}
コード例 #21
0
ファイル: internal.cpp プロジェクト: Brainiarc7/arrayfire
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);
    }
}
コード例 #22
0
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();
}
コード例 #23
0
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();
}
コード例 #24
0
ファイル: waitinglist.cpp プロジェクト: angeldv95/pokerspot
//
// 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;
}
コード例 #25
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();
}
コード例 #26
0
//##############################################################################
//# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
//##############################################################################
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;
}
コード例 #27
0
//##############################################################################
//# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
//##############################################################################
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;
	}
}
コード例 #28
0
/**
 * 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);
    }
}
コード例 #29
0
//##############################################################################
//# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
//##############################################################################
xLogHandler::~xLogHandler()
{
	if(isOwner())
		delete m_formatter;
}
コード例 #30
0
ファイル: zValidator.cpp プロジェクト: KnIfER/armagetron
bool
zValidatorAllButOwner::isValid(gVectorExtra< nNetObjectID > &owners, gVectorExtra< nNetObjectID > &teamOwners, gCycle* possibleUser)
{
    return !isOwner(possibleUser->Player(), owners);
}