void DeleteSlotTest()
        {
            /////
            {
                ConstraintModel model {id_type<ConstraintModel>{0}, id_type<AbstractConstraintViewModel>{0}, this};
                auto content_id = getStrongId(model.rackes());
                model.createRack(content_id);
                auto rack = model.rack(content_id);

                auto slot_id = getStrongId(rack->getSlots());
                rack->addSlot(new SlotModel
                {
                    slot_id,
                    rack
                });
                rack->removeSlot(slot_id);
                model.removeRack(content_id);
            }

            //////
            {
                ConstraintModel model {id_type<ConstraintModel>{0},
                                       id_type<AbstractConstraintViewModel>{0}, this
                                      };
                auto content_id = getStrongId(model.rackes());
                model.createRack(content_id);
                auto rack = model.rack(content_id);

                rack->addSlot(new SlotModel
                {
                    getStrongId(rack->getSlots()),
                    rack
                });

                rack->addSlot(new SlotModel
                {
                    getStrongId(rack->getSlots()),
                    rack
                });

                rack->addSlot(new SlotModel
                {
                    getStrongId(rack->getSlots()),
                    rack
                });

                model.removeRack(content_id);
            }
        }
StateChunk *ChunkMaterial::find(const FieldContainerType &type, 
                                      Int32               slot) const
{
    UInt32 index = 0;

    for(UInt32 i = 0; i < _mfChunks.size(); ++i)
    {
        StateChunk *p = _mfChunks[i];

        Int32 s = State::AutoSlotReplace;

        if(i < getMFSlots()->size())
            s = getSlots(i);

        if(s == State::AutoSlotReplace)
            s = index;

        if(p->getType() == type)
        {           
            if(slot == State::AutoSlotReplace || slot == s)
                return (p);

            ++index;
        }
    }

    return NULL;
}
block_id StorageManager::createBlock(const CatalogRelation &relation,
                                     const StorageBlockLayout *layout) {
  if (layout == NULL) {
    layout = &(relation.getDefaultStorageBlockLayout());
  }

  size_t num_slots = layout->getDescription().num_slots();
  DEBUG_ASSERT(num_slots > 0);
  size_t slot_index = getSlots(num_slots);
  void *new_block_mem = getSlotAddress(slot_index);
  ++block_index_;

  BlockHandle new_block_handle;
  new_block_handle.slot_index_low = slot_index;
  new_block_handle.slot_index_high = slot_index + num_slots;
  new_block_handle.block = new StorageBlock(relation,
                                            block_index_,
                                            *layout,
                                            true,
                                            new_block_mem,
                                            kSlotSizeBytes * num_slots);

  blocks_[block_index_] = new_block_handle;
  return block_index_;
}
示例#4
0
int Inventory::getFreeSlot()
{
	for (int i = 0; i < getSlots(); i++)
	{
		if(storedItems[i] == nullptr)
			return i;
	}
	return -1;
}
示例#5
0
void QSAEditor::completeQMetaObject( const QMetaObject *meta,
					 const QString &,
					 QVector<CompletionEntry> &res,
					 int flags,
					 QSObject &obj )
{
    QMap<QString, bool> propMap;
    bool includeSuperClass = (flags & IncludeSuperClass) == IncludeSuperClass;

    // properties
    const QMetaObject *m = meta;
    int num = m->propertyCount();

    for ( int j = 0; j < num; ++j ) {
        const QMetaProperty mp = m->property( j );
        if ( propMap.find( QString::fromLatin1(mp.name()) ) != propMap.end() )
            continue;
        CompletionEntry c;
        propMap[QLatin1String(mp.name())] = false;
        c.type = QLatin1String("property");
        c.text = mp.name();
        c.prefix = QString();
        c.postfix2 = mp.typeName();
        QuickInterpreter::cleanType( c.postfix2 );
        if ( !c.postfix2.isEmpty() )
            c.postfix2.prepend( QLatin1String(" : ") );
        res.append( c );
    }

    if ( includeSuperClass && obj.isValid() && !obj.isUndefined() ) {
        QStringList vars = interpreter()->variablesOf( obj, true );
        QStringList::iterator it;
        for ( it = vars.begin(); it != vars.end(); ++it ) {
            CompletionEntry c;
            c.type = QLatin1String("variable");
            c.text = *it;
            c.prefix = QString();
            c.postfix2 = QString();
            res << c;
        }
    }

    // functions
    QList<Property> lst;
    QList<Property>::Iterator pit;
    getSlots( meta, lst, includeSuperClass, false, false );
    for ( pit  = lst.begin(); pit != lst.end(); ++pit ) {
        CompletionEntry c;
        c.type = QLatin1String("function");
        c.text = (*pit).name;
        c.postfix = QLatin1String("()");
        c.postfix2 = (*pit).type;
        if ( !c.postfix2.isEmpty() )
            c.postfix2.prepend( QString::fromLatin1(" : ") );
        res << c;
    }
    if ( includeSuperClass && obj.isValid() && !obj.isUndefined() ) {
        QStringList funcs = interpreter()->functionsOf( obj, true, true, true );
        QStringList::Iterator it;
        for ( it = funcs.begin(); it != funcs.end(); ++it ) {
            CompletionEntry c;
            c.type = QLatin1String("function");
            c.text = *it;
            c.prefix = QString();
            c.postfix2 = QString();
            res << c;
        }
    }

    // enum values

    m = meta;
    for (int k=0; k<m->enumeratorCount(); ++k) {
        QMetaEnum me = m->enumerator(k);
        for (int l=0; l<me.keyCount(); ++l) {
            CompletionEntry c;
            c.type = QLatin1String("enum");
            c.text = QLatin1String(me.key(l));
            c.prefix = QString();
            c.postfix2 = QLatin1String(me.name());

            if (!c.postfix2.isEmpty())
                c.postfix2.prepend( QString::fromLatin1(" : ") );
            res << c;
        }
    }

    if ( includeSuperClass && obj.isValid() && !obj.isUndefined() ) {
        QStringList classes = interpreter()->classesOf( obj );
        QStringList::Iterator it;
        for ( it = classes.begin(); it != classes.end(); ++it ) {
            CompletionEntry c;
            c.type = QLatin1String("class");
            c.text = *it;
            c.prefix = QString();
            c.postfix2 = QString();
            res << c;
        }
    }
}
示例#6
0
string SearchResult::getSlotString() const { 
	return Util::toString(getFreeSlots()) + '/' + Util::toString(getSlots()); 
}
示例#7
0
	string SearchResultInfo::getSlotStr() const noexcept {
		int free = 0, total = 0;
		getSlots(free, total);
		return Util::toString(free) + '/' + Util::toString(total);
	}