Ejemplo n.º 1
0
static ObjectPtr convertObject(ObjectPtr x) {
    switch (x->objKind) {
    case RECORD : {
        Record *y = (Record *)x.ptr();
        if (y->params.empty() && !y->varParam.ptr())
            return recordType(y, vector<ObjectPtr>()).ptr();
        return x;
    }
    case VARIANT : {
        Variant *y = (Variant *)x.ptr();
        if (y->params.empty() && !y->varParam.ptr())
            return variantType(y, vector<ObjectPtr>()).ptr();
        return x;
    }
    default :
        return x;
    }
}
Ejemplo n.º 2
0
 //-----------------------------------------------------------------------
 void Scene::addObject(const ObjectPtr& object)
 {
     if (!mObjects.get<by_identity>().insert(object).second)
     {
         OGRE_EXCEPT(Ogre::Exception::ERR_DUPLICATE_ITEM,
             "The given object with name '" + object->getName() + "' already contain by this scene",
             "Scene::addObject");
     }
 }
Ejemplo n.º 3
0
    void 
    AddLightObjectPlugin::onAddObject(const ObjectPtr& object)
    {
        Ogre::String type = object->getType();

        // 判断,如果是能处理的类型(LightObject),就处理
        if ( type == "Light" )
        {
            LightObject *lightObject = static_cast<LightObject *> (object.get());
            Indicator *indicator = new Indicator(object,mSceneManipulator->getSceneManager(),
                mSceneManipulator );

            std::pair<Indicators::iterator, bool> inserted =
                mIndicators.insert(Indicators::value_type(object, indicator));

            assert(inserted.second);
        }
    }
Ejemplo n.º 4
0
 //-----------------------------------------------------------------------
 void Scene::removeObject(const ObjectPtr& object)
 {
     if (mObjects.get<by_identity>().erase(object) <= 0)
     {
         OGRE_EXCEPT(Ogre::Exception::ERR_ITEM_NOT_FOUND,
             "The given object with name '" + object->getName() + "' doesn't contain by this scene",
             "Scene::removeObject");
     }
 }
Ejemplo n.º 5
0
		TEST(ObjectTests, NilObject)
		{
			ObjectPtr object = createObject();
			ASSERT_EQ(Object::NIL, object->getNativeType());
			ASSERT_TRUE(object->isNil());
			ASSERT_EQ(false, object->getBoolean());
			ASSERT_EQ(0.f, object->getNumber());
			ASSERT_TRUE(object->getString().empty());
			ASSERT_EQ(0, object->getUserdata());
			ASSERT_STREQ("nil", object->getReadableString().c_str());
		}
Ejemplo n.º 6
0
void SceneBrowser::OnContextMenu( ObjectPtr &object, wxTreeEvent& event )
{
	const Ogre::String &type = object->getType();

	if ( type == "Actor" )
	{
		ActorAnimationSettingDialog *dlg = new ActorAnimationSettingDialog(this, wxID_ANY,
			_("ActorAnimationSetting Dialog"), object, mSceneManipulator, event.GetPoint());

		int result = dlg->Show(true);
		//if (result == wxID_CANCEL)
		//{
		//	// 如果异常列表中仍有内容,就给出提示
		//	if (dlg->mListBox->GetCount() > 0)
		//	{
		//		wxMessageBox(_("Thera are still some wrongs in scene,remember to fix them!"));
		//	}
		//	else
		//	{
		//		wxMessageBox(_("All wrongs in scene have been fixed,remember to save the scene!"));
		//	}
		//}

	}
	else if ( type == "Effect" )
	{
		
		Fairy::Effect *effect = static_cast<Fairy::EffectObject *>(object.get())->getEffect();

		if ( effect )
		{
			if ( NULL == mEffectDialog )
			{
				mEffectDialog = new WXEffectEditDialog(this, wxID_ANY, _("Effect Setting"));
			}
			if ( false == mEffectDialog->IsShown() )
				mEffectDialog->Show();			
			mEffectDialog->InitEffectDialog(effect, mSceneManipulator);
		}			
	}

	mSceneManipulator->setActiveAction(NULL);
}
Ejemplo n.º 7
0
DX11DeferredRendererMaterial::DX11DeferredRendererMaterial(const ObjectPtr<DX11Material>& base_material) :
material_(base_material->Instantiate()){

	auto& resources = DX11Graphics::GetInstance().GetResources();

	shader_parameters_ = resources.Load<IStructuredBuffer, IStructuredBuffer::FromSize>({ sizeof(ShaderParameters) });

	material_->SetInput(kShaderParameters, ObjectPtr<IStructuredBuffer>(shader_parameters_));

}
Ejemplo n.º 8
0
void ObjectSet::insert(ObjectPtr object)
{
    std::pair<ObjectSet::SetType::iterator, bool> result =
        objects.insert(object);

    if (result.second)
    {
        objectMap[object->getId()] = result.first;
    }
}
Ejemplo n.º 9
0
IException* User::Channel::SendAndReceive(TypeInfo::MethodAttributes_t attribs, Remoting::IMessage* pSend, Remoting::IMessage*& pRecv)
{
	// Get the object manager
	OOBase::Guard<OOBase::SpinLock> guard(m_lock);

	ObjectPtr<Remoting::IMarshaller> ptrMarshaller = m_ptrMarshaller;
	if (!ptrMarshaller)
		throw Remoting::IChannelClosedException::Create(OMEGA_CREATE_INTERNAL("SendAndReceive() called on disconnected channel"));

	guard.release();

	// We need to wrap the message
	ObjectPtr<ObjectImpl<OOCore::CDRMessage> > ptrEnvelope = ObjectImpl<OOCore::CDRMessage>::CreateObject();
	ptrMarshaller->MarshalInterface(string_t::constant("payload"),ptrEnvelope,OMEGA_GUIDOF(Remoting::IMessage),pSend);

	OOBase::CDRStream response;
	try
	{
		OOServer::MessageHandler::io_result::type res = Manager::instance()->send_request(m_channel_id,ptrEnvelope->GetCDRStream(),&response,attribs);
		if (res != OOServer::MessageHandler::io_result::success)
		{
			if (res == OOServer::MessageHandler::io_result::channel_closed)
			{
				disconnect();
				throw Omega::Remoting::IChannelClosedException::Create(OMEGA_CREATE_INTERNAL("Failed to send request"));
			}
			
			disconnect();
			OMEGA_THROW("Internal server exception");
		}
	}
	catch (...)
	{
		ptrMarshaller->ReleaseMarshalData(string_t::constant("payload"),ptrEnvelope,OMEGA_GUIDOF(Remoting::IMessage),pSend);
		throw;
	}

	if (!(attribs & TypeInfo::Asynchronous))
	{
		try
		{
			// Wrap the response
			ObjectPtr<ObjectImpl<OOCore::CDRMessage> > ptrRecv = ObjectImpl<OOCore::CDRMessage>::CreateObject();
			ptrRecv->init(response);

			// Unwrap the payload...
			IObject* pObj = NULL;
			ptrMarshaller->UnmarshalInterface(string_t::constant("payload"),ptrRecv,OMEGA_GUIDOF(Remoting::IMessage),pObj);
			pRecv = static_cast<Remoting::IMessage*>(pObj);
		}
		catch (IException* pE)
		{
			return pE;
		}
	}

	return NULL;
}
Ejemplo n.º 10
0
void printStaticName(llvm::raw_ostream &out, ObjectPtr x)
{
    if (x->objKind == IDENTIFIER) {
        Identifier *y = (Identifier *)x.ptr();
        out << y->str;
    }
    else {
        printName(out, x);
    }
}
Ejemplo n.º 11
0
bool Inside_Object (const Vector3d& IPoint, ObjectPtr Object, TraceThreadData *Thread)
{
    for (vector<ObjectPtr>::iterator Sib = Object->Clip.begin(); Sib != Object->Clip.end(); Sib++)
    {
        if(!Inside_Object(IPoint, *Sib, Thread))
            return false;
    }

    return (Object->Inside(IPoint, Thread));
}
Ejemplo n.º 12
0
void HistogramDialog::configureTab(ObjectPtr object) {
  if (!object) {
    _histogramTab->setRealTimeAutoBin(dialogDefaults().value("histogram/realTimeAutoBin", false).toBool());
    _histogramTab->setNormalizationType(Histogram::NormalizationType(dialogDefaults().value("histogram/normalizationType",Histogram::Number).toInt()));
  } else if (HistogramPtr histogram = kst_cast<Histogram>(object)) {
    _histogramTab->setVector(histogram->vector());
    _histogramTab->setMin(histogram->xMin());
    _histogramTab->setMax(histogram->xMax());
    _histogramTab->setBins(histogram->numberOfBins());
    _histogramTab->setRealTimeAutoBin(histogram->realTimeAutoBin());
    _histogramTab->setNormalizationType(histogram->normalizationType());
    _histogramTab->hideCurveOptions();
    if (_editMultipleWidget) {
      HistogramList objects = _document->objectStore()->getObjects<Histogram>();
      _editMultipleWidget->clearObjects();
      foreach(HistogramPtr object, objects) {
        _editMultipleWidget->addObject(object->Name(), object->descriptionTip());
      }
    }
Ejemplo n.º 13
0
void Player::SetAgent( sf::Uint16 id ) {
	m_tentative_agent_id = id;
	ObjectPtr object = Game::GetGame()->GetObjectManager()->GetObjectById( id );

	if( !object ) {
		return;
	}

	if( object->GetType() != ObjectType::SHIP ) {
		return;
	}

	ShipPtr agent = std::static_pointer_cast<Ship>( Game::GetGame()->GetObjectManager()->GetObjectById( id ) );
	agent->SetPlayer( true );
	LogConsole( "Set player ship to object: " + string_cast( id ) );
	m_tentative_agent_id = 0xffff;

	m_agent = agent;
}
Ejemplo n.º 14
0
void ArchiveBinary::DeserializeInstance(ObjectPtr& object)
{
    //
    // If we don't have an object allocated for deserialization, pull one from the stream
    //

    if (!object.ReferencesObject())
    {
        object = Allocate();
    }

    //
    // We should now have an instance (unless data was skipped)
    //

    if (object.ReferencesObject())
    {
#ifdef REFLECT_ARCHIVE_VERBOSE
        m_Indent.Get(stdout);
        Log::Print(TXT("Deserializing %s\n"), object->GetClass()->m_Name);
        m_Indent.Push();
#endif

        object->PreDeserialize( NULL );

        Data* data = SafeCast<Data>(object);

        if ( data )
        {
            data->Deserialize(*this);
        }
        else
        {
            DeserializeFields(object);
        }

        object->PostDeserialize( NULL );

#ifdef REFLECT_ARCHIVE_VERBOSE
        m_Indent.Pop();
#endif
    }
}
Ejemplo n.º 15
0
void
throwUOE(const string& expectedType, const ObjectPtr& v)
{
    //
    // If the object is an unknown sliced object, we didn't find an
    // object factory, in this case raise a NoObjectFactoryException
    // instead.
    //
    UnknownSlicedObject* uso = dynamic_cast<UnknownSlicedObject*>(v.get());
    if(uso)
    {
        throw NoObjectFactoryException(__FILE__, __LINE__, "", uso->getUnknownTypeId());
    }

    string type = v->ice_id();
    throw Ice::UnexpectedObjectException(__FILE__, __LINE__,
                                         "expected element of type `" + expectedType + "' but received '" +
                                         type, type, expectedType);
}
Ejemplo n.º 16
0
void CurveDialog::configureTab(ObjectPtr object) {
  if (!object) {
    _curveTab->curveAppearance()->loadWidgetDefaults();
    _curveTab->setToLastX();
  } else if (CurvePtr curve = kst_cast<Curve>(object)) {
    _curveTab->curveAppearance()->loadWidgetDefaults();
    _curveTab->setXVector(curve->xVector());
    _curveTab->setYVector(curve->yVector());
    if (curve->hasXError()) {
      _curveTab->setXError(curve->xErrorVector());
    }
    if (curve->hasYError()) {
    _curveTab->setYError(curve->yErrorVector());
    }
    if (curve->hasXMinusError()) {
    _curveTab->setXMinusError(curve->xMinusErrorVector());
    }
    if (curve->hasYMinusError()) {
      _curveTab->setYMinusError(curve->yMinusErrorVector());
    }
    _curveTab->setIgnoreAutoScale(curve->ignoreAutoScale());
    _curveTab->curveAppearance()->setColor(curve->color());
    _curveTab->curveAppearance()->setHeadColor(curve->headColor());
    _curveTab->curveAppearance()->setShowPoints(curve->hasPoints());
    _curveTab->curveAppearance()->setShowLines(curve->hasLines());
    _curveTab->curveAppearance()->setShowBars(curve->hasBars());
    _curveTab->curveAppearance()->setShowHead(curve->hasHead());
    _curveTab->curveAppearance()->setLineWidth(curve->lineWidth());
    _curveTab->curveAppearance()->setPointSize(curve->pointSize());
    _curveTab->curveAppearance()->setLineStyle(curve->lineStyle());
    _curveTab->curveAppearance()->setPointType(curve->pointType());
    _curveTab->curveAppearance()->setPointDensity(curve->pointDensity());
    _curveTab->curveAppearance()->setBarFillColor(curve->barFillColor());
    _curveTab->curveAppearance()->setHeadType(curve->headType());
    _curveTab->hidePlacementOptions();
    if (_editMultipleWidget) {
      CurveList objects = _document->objectStore()->getObjects<Curve>();
      _editMultipleWidget->clearObjects();
      foreach(CurvePtr object, objects) {
        _editMultipleWidget->addObject(object->Name(), object->descriptionTip());
      }
    }
Ejemplo n.º 17
0
void Scene::eraseObject(ObjectPtr pObject) {
  SIACheckRet(!pObject);
  SIAAssert(m_pGameLayer);

  auto pEntity = pObject->entity();
  SIAAssert(pEntity);

  m_modelController.addCommand(std::make_shared<Commands::EraseEntity>(pEntity),
    [pObject, this] () {
    auto pView = pObject->view();
    SIAAssert(pView);
    m_pGameLayer->eraseGameView(pView);

    m_pObjects.erase(std::remove_if(m_pObjects.begin(), m_pObjects.end(), [&pObject] (ObjectPtr& pObj) {
      return pObject.get() == pObj.get();
    }), m_pObjects.end());

    SIADebug("Removed object from scene.");
  }, nullptr);
}
Ejemplo n.º 18
0
ObjectPtr Copy_Object (ObjectPtr Old)
{
    ObjectPtr New;

    if(Old == NULL)
        return NULL;

    New = Old->Copy();

    /*
     * The following copying of OBJECT_FIELDS is redundant if Copy
     * did *New = *Old but we cannot assume it did. It is safe for
     * Copy to do *New = *Old but it should not otherwise
     * touch OBJECT_FIELDS.
     */

    New->Type    = Old->Type;
    New->Bound   = Old->Bound;
    New->Clip    = Old->Clip;
    New->BBox    = Old->BBox;
    New->Flags   = Old->Flags;

    New->Ph_Density             = Old->Ph_Density;
    New->RadiosityImportance    = Old->RadiosityImportance;

    // TODO FIXME - An explanation WHY this is important would be nice [CLi]
    New->LLights.clear(); // important

    New->Texture = Copy_Textures (Old->Texture);
    New->Interior_Texture = Copy_Textures (Old->Interior_Texture);
    if(Old->interior != NULL)
        New->interior = InteriorPtr(new Interior(*(Old->interior)));
    else
        New->interior.reset();

    // TODO: we really ought to decide whether or not it's useful to maintain
    //       the overhead of having multiple clip and bound objects ... it is
    //       after all possible for the user to use CSG and give us one object
    //       meaning we could use a plain pointer here.
    if (Old->Bound.empty() == false)
        New->Bound = Copy_Objects(Old->Bound);
    if (Old->Clip.empty() == false)
    {
        // note that in this case the objects are shared and should only be
        // destroyed the once !!! ... to be frank POV really needs a reference-
        // counted system for sharing objects with copy-on-write semantics.
        if(Old->Bound != Old->Clip)
            New->Clip = Copy_Objects(Old->Clip);
        else
            New->Clip = New->Bound;
    }

    return New;
}
void
Freeze::BackgroundSaveEvictorI::finished(const Current& current, const ObjectPtr& servant, const LocalObjectPtr& cookie)
{
    assert(servant != 0);
    DeactivateController::Guard deactivateGuard(_deactivateController);

    if(cookie != 0)
    {
        BackgroundSaveEvictorElementPtr element = BackgroundSaveEvictorElementPtr::dynamicCast(cookie);
        assert(element);
    
        bool enqueue = false;
        
        if((servant->ice_operationAttributes(current.operation) & 0x1) != 0)
        {
            IceUtil::Mutex::Lock lock(element->mutex);
            
            if(element->status == clean)
            {
                //
                // Assume this operation updated the object
                // 
                element->status = modified;
                enqueue = true;
            }
        }
        
        Lock sync(*this);

        //
        // Only elements with a usageCount == 0 can become stale and we own 
        // one count!
        // 
        assert(!element->stale);
        assert(element->usageCount >= 1);
        
        //
        // Decrease the usage count of the evictor queue element.
        //
        element->usageCount--;
        
        if(enqueue)
        {
            addToModifiedQueue(element);
        }
        else if(element->usageCount == 0 && element->keepCount == 0)
        {
            //
            // Evict as many elements as necessary.
            //
            evict();
        }
    }
}
Ejemplo n.º 20
0
		VALUE array_inspect(const CallFrame* here, VALUE self, VALUE it) {
			ObjectPtr<Array> array = self;
			if (array == NULL) {
				throw_exception_with_description("Array#inspect called for object that doesn't derive from Array.");
			}

			ObjectPtr<String> result = create_string_constant("@(");

			for (size_t i = 0; i < array->size(); ++i) {
				Value val = (*array)[i];
				string_append(result, value_inspect(val));
				if (i != array->size() - 1) {
					string_append_cstr(result, ", ");
				}
			}

			string_append_cstr(result, ")");

			return result;
		}
Ejemplo n.º 21
0
static vector<TypePtr> typesOfValues(ObjectPtr obj) {
    vector<TypePtr> types;
    switch (obj->objKind) {
    case MULTI_PVALUE : {
        MultiPValue *mpv = (MultiPValue *)obj.ptr();
        for (unsigned i = 0; i < mpv->size(); ++i)
            types.push_back(mpv->values[i]->type);
        break;
    }
    case MULTI_CVALUE : {
        MultiCValue *mcv = (MultiCValue *)obj.ptr();
        for (unsigned i = 0; i < mcv->size(); ++i)
            types.push_back(mcv->values[i]->type);
        break;
    }
    default :
        assert(false);
    }
    return types;
}
Ejemplo n.º 22
0
			inline void onEvent(Event& event) {
				if(object_) {
					object_->onEvent(*this, event);
				}
				
				typedef std::map<std::string, NodePtr>::iterator ItType;
				
				for(ItType it = children_.begin(); it != children_.end(); ++it) {
					it->second->onEvent(event);
				}
			}
Ejemplo n.º 23
0
    //-----------------------------------------------------------------------
    void CreateObjectOperator::add(const ObjectPtr& object, bool create)
    {
        assert(object);

        mObjectInfos.push_back(ObjectInfo());
        ObjectInfo& info = mObjectInfos.back();

        info.create = create;
        info.type = object->getType();
        info.name = object->getName();
        const PropertyList& properties = object->getProperties();
        for (PropertyList::const_iterator it = properties.begin(); it != properties.end(); ++it)
        {
            const PropertyDef& propertyDef = *it;
            if (object->getPropertyAsString(propertyDef.name) != propertyDef.defaultValue)
            {
                info.properties.insert(
                    PropertyNameVariantPairList::value_type(propertyDef.name, object->getProperty(propertyDef.name)));
            }
        }
    }
Ejemplo n.º 24
0
 //-----------------------------------------------------------------------
 void CreateObjectOperator::apply(bool reserve)
 {
     for (ObjectInfoList::const_iterator i = mObjectInfos.begin(); i != mObjectInfos.end(); ++i)
     {
         const ObjectInfo& info = *i;
         if (reserve == info.create)
         {
             const ObjectPtr& object = mSceneManipulator->getSceneInfo()->findObjectByName(i->name);
             assert(object);
             mSceneManipulator->removeObject(object, NULL, true);
         }
         else
         {
             ObjectPtr object = ObjectFactoryManager::getSingleton().createInstance(info.type);
             object->setName(info.name);
             object->setPropertyList(info.properties);
             object->createRenderInstance(mSceneManipulator);
             mSceneManipulator->addObject(object, NULL, true);
         }
     }
 }
Ejemplo n.º 25
0
/*
   void GameMan::Unselect(List* objectList)
   {

   }
   */
void GameMan::Update(float dt)
{
    for(ObjectTypeMap::const_iterator objTypeMap = m_objects.begin(); objTypeMap != m_objects.end(); objTypeMap++)
    {
	ObjectMap ObjMap = (*objTypeMap).second;
	std::stack<uint32_t> eraseStack;
	for(ObjectMap::const_iterator objMap = ObjMap.begin(); objMap != ObjMap.end(); objMap++)
	{
	    ObjectPtr object = objMap->second;
	    if (object->clearObject())
		eraseStack.push(objMap->first);
	    else
		object->update(dt);
	}
	while(!eraseStack.empty())
	{
	    ObjMap.erase(eraseStack.top());
	    eraseStack.pop();
	}
    }
}
Ejemplo n.º 26
0
const OverloadPtr callableInterface(ObjectPtr x)
{
    switch (x->objKind) {
    case PROCEDURE : {
        Procedure *y = (Procedure *)x.ptr();
        return y->interface;
    }
    default : {
        return NULL;
    }
    }
}
Ejemplo n.º 27
0
// Run one item, return true if there are more items.
bool active::scheduler::locked_run_one()
{
#ifdef ACTIVE_USE_CXX11
	if(atomic_node * n = m_activated_objects.pop())
	{
		static_cast<ObjectPtr>(n)->run_some();
		return true;
	}
#else
	if( m_head )
	{
		ObjectPtr p = m_head;
        m_head=static_cast<ObjectPtr>(m_head->next);
		m_mutex.unlock();
		p->run_some();
		m_mutex.lock();
		return true;
	}
#endif	
	return false;
}
Ejemplo n.º 28
0
    static void cmdOverloads(const vector<Token>& tokens) {
        for (size_t i = 1; i < tokens.size(); ++i) {
            if (tokens[i].tokenKind == T_IDENTIFIER) {
                Str identStr = tokens[i].str;

                ObjectPtr obj = lookupPrivate(module, Identifier::get(identStr));
                if (obj == NULL || obj->objKind != PROCEDURE) {
                    llvm::errs() << identStr << " is not a procedure name\n";
                    continue;
                }

                vector<InvokeSet*> sets = lookupInvokeSets(obj.ptr());
                for (size_t k = 0; k < sets.size(); ++k) {
                    llvm::errs() << "        ";
                    for (size_t l = 0; l < sets[k]->argsKey.size(); ++l) {
                        llvm::errs() << sets[k]->argsKey[l] << " : ";
                    }
                    llvm::errs() << "\n";
                }
            }
        }
    }
Ejemplo n.º 29
0
qlib::Vector4D RendGroup::getCenter() const
{
  // Calc COM of renderers in this group
  Vector4D resvec;
  int nsum = 0;
  ObjectPtr pObj = getClientObj();
  Object::RendIter iter = pObj->beginRend();
  Object::RendIter eiter = pObj->endRend();
  for (;iter!=eiter;++iter) {
    RendererPtr pRend = iter->second;
    if (!pRend->getGroupName().equals(getName()))
      continue;
    if (pRend->hasCenter()) {
      resvec += pRend->getCenter();
      ++nsum;
    }
  }
  if (nsum>0)
    return resvec.divide(nsum);
  else
    return qlib::Vector4D();
}
Ejemplo n.º 30
0
  QString ScriptInterface::doObjectCommand(QString command, ObjectPtr ob) {

    QString v=doNamedObjectCommand(command, ob);
    if (!v.isEmpty()) {
      return v;
    }

    if (command.startsWith("type(")) {
      return ob->typeString();
    }

    return QString();
  }