void UpdateReferenceDialog::setObjref(Objref_ptr objref) { if (m_objref) { disconnect(this, SIGNAL(updateReference(const CORBA::Object_var&)), m_objref.get(), SLOT(setReference(const CORBA::Object_var&))); disconnect(m_objref.get(), SIGNAL(updatedReference(const CORBA::Object_var&)), m_status, SLOT(setReference(const CORBA::Object_var&))); } m_objref = objref; if (m_objref) { m_status->setInterface(objref->interface()); m_reference->setInterface(objref->interface()); m_status->setReference(objref->reference()); connect(this, SIGNAL(updateReference(const CORBA::Object_var&)), m_objref.get(), SLOT(setReference(const CORBA::Object_var&))); connect(m_objref.get(), SIGNAL(updatedReference(const CORBA::Object_var&)), m_status, SLOT(setReference(const CORBA::Object_var&))); } }
InterfaceDescriptor_ptr ParametersModel::getReflective(const QString& id) const { Objref_ptr obj = getInstance(id); if (obj) return obj->interface(); return NULL; }
CORBA::Object_var ServerApp::setServant( const char * fqn, const char * servantName, PortableServer::ServantBase * servant, const char * nsEntry) { // We activate the real servant PortableServer::ObjectId_var myObjID = m_impl->rootPOA->activate_object(servant); CORBA::Object_var realRef = m_impl->rootPOA->servant_to_reference(servant); // We use a fake servant ServantConfig scfg; scfg.fqn = fqn; scfg.name = servantName; if (nsEntry) scfg.entry = nsEntry; Objref_ptr oServant = m_impl->application.createServant(scfg); if (!oServant) throw std::runtime_error("Can not create servant"); Servant * sServant = static_cast< Servant * >(oServant.get()); CORBA::Object_var result = sServant->reference(); sServant->setReference(result); // create an objref with the real reference ObjrefConfig ocfg; ocfg.fqn = fqn; ocfg.name = std::string("corbasim hide client ") + servantName; ocfg.reference = realRef; ocfg.hide = true; Objref_ptr realObjref = m_impl->application.createObjref(ocfg); if (!realObjref) throw std::runtime_error("Can not create servant"); sServant->setProxy(realObjref); // end create an objref with the real reference return result; }
void FilterModel::load(const QVariant& settings) { const QVariantList list = settings.toList(); for (QVariantList::const_iterator it = list.begin(); it != list.end(); ++it) { const QVariantMap map = it->toMap(); if (!map.contains("instance") || !map.contains("operations")) continue; // Name to ID conversion const QString instance = map["instance"].toString(); if (instance.isEmpty()) continue; Objref_ptr objref = m_instances.find(instance); if (!objref) continue; FirstLevelItems_t::iterator fit = m_items.find(objref->id()); if (fit == m_items.end()) continue; // End Name to ID conversion const QVariantMap operations = map["operations"].toMap(); for (unsigned int j = 0; j < objref->interface()->operation_count(); j++) { OperationDescriptor_ptr op = objref->interface()->get_reflective_by_index(j); tag_t tag = op->get_tag(); OperationsMap_t::iterator opit = fit.value().operations.find(tag); if(operations.contains(op->get_name()) && opit != fit.value().operations.end()) { bool state = operations[op->get_name()].toBool(); opit.value()->setCheckState((state)? Qt::Checked: Qt::Unchecked); } } } }
void AbstractInputTool::unregisterInstance(ObjectId id) { Objref_ptr objref = m_instances.find(id); if (!objref) return; // Maps map_t::iterator it = m_map.begin(); for(; it != m_map.end(); it++) { if (objref->name() == it->first.first) { for (int i = 0; i < it->second.size(); i++) { AbstractInputItem * item = it->second[i]; m_inverse_map.erase(item); // FIXME we need to block signals because uncheck // method is connected to deleteAbstractItem // Must be changed for a better implementation m_model->blockSignals(true); m_model->uncheck(objref->name(), item->getPath()); m_model->blockSignals(false); // Notify to the processor item->reset(); m_group->deleteItem( qobject_cast< qt::SortableGroupItem * > (item->parent())); delete item; } m_map.erase(it); } } m_model->unregisterInstance(id); m_instances.del(id); }
void OperationsView::clicked(const QModelIndex& index) { InstanceModel * src = dynamic_cast< InstanceModel * >(model()); if (src) { Objref_ptr instance = src->getInstance(index); if (src->isInstanceNode(index)) { emit selectedInstance(instance); } else if (src->isOperationNode(index)) { QList< int > list; list << index.row(); OperationDescriptor_ptr op = instance->interface()->get_reflective_by_index(index.row()); emit selectedItem(instance, op, list); emit selectedOperation(instance, op); } else { QList< int > list; QModelIndex current = index; while(current.parent().isValid()) { list.push_front(current.row()); current = current.parent(); } OperationDescriptor_ptr op = instance->interface()->get_reflective_by_index(list.front()); emit selectedItem(instance, op, list); } } }
void FilterModel::registerInstance(Objref_ptr objref) { m_instances.add(objref); FirstLevelItem item; item.objref = objref; FirstLevelItems_t::iterator it = m_items.insert(objref->id(), item); OperationsMap_t& operations = it.value().operations; QStandardItem * ifItem = new QStandardItem(objref->name()); ifItem->setEditable(false); ifItem->setCheckable(true); ifItem->setTristate(true); ifItem->setCheckState(Qt::Checked); item.item = ifItem; const unsigned int count = objref->interface()->operation_count(); for (unsigned int i = 0; i < count; i++) { OperationDescriptor_ptr op = objref->interface()->get_reflective_by_index(i); QStandardItem * opItem = new QStandardItem(op->get_name()); opItem->setEditable(false); opItem->setCheckable(true); opItem->setCheckState(Qt::Checked); ifItem->appendRow(opItem); operations.insert(op->get_tag(), opItem); } appendRow(ifItem); emit filterChanged(); }
void FilterModel::save(QVariant& settings) { QVariantList list; for (FirstLevelItems_t::iterator it = m_items.begin(); it != m_items.end(); ++it) { Objref_ptr objref = it.value().objref; QVariantMap map; map["instance"] = objref->name(); QVariantMap ops; for (unsigned int j = 0; j < objref->interface()->operation_count(); j++) { OperationDescriptor_ptr op = objref->interface()->get_reflective_by_index(j); tag_t tag = op->get_tag(); OperationsMap_t::const_iterator opit = it.value().operations.find(tag); if (opit != it.value().operations.end()) { ops[op->get_name()] = (opit.value()->checkState() == Qt::Checked); } } map["operations"] = ops; list << map; } settings = list; }
void ParametersFromFilesTool::initialize( Objref_ptr objref, OperationDescriptor_ptr reflective) { const InterfaceDescriptor_ptr iface = objref->interface(); int i = 0; while (i < iface->operation_count() && iface->get_reflective_by_index(i) != reflective) i++; m_model.initialize(i, reflective); m_objref = objref; m_operation = reflective; }
CORBA::Object_var ServerApp::setClient( const char * fqn, const char * clientName, const char * nsEntry) { const QString nameToFind = QString("corbasim hide servant %1").arg(clientName); Objref_ptr objref = m_impl->clients.find(nameToFind); CORBA::Object_var result; // Client exists if (objref) { // if the client exists we return its proxy servant // reference Servant * servant = static_cast< Servant * >(objref.get()); servant->proxy()->setNsEntry(nsEntry); result = servant->reference(); } else { // New client // We create a new hidden servant ServantConfig scfg; scfg.fqn = fqn; scfg.name = nameToFind.toStdString(); scfg.hide = true; Objref_ptr oServant = m_impl->application.createServant(scfg); if (!oServant) throw std::runtime_error("Can not create client"); Servant * servant = static_cast< Servant * >(oServant.get()); // user must use this reference // all its calls will be derived to a proxy reference result = servant->reference(); servant->setReference(result); // We create a visible client ObjrefConfig ccfg; ccfg.name = clientName; ccfg.fqn = fqn; ccfg.entry = nsEntry; Objref_ptr proxy = m_impl->application.createObjref(ccfg); if (!proxy) throw std::runtime_error("Can not create client"); servant->setProxy(proxy); m_impl->clients.add(oServant); } return result; }
Dumper::Dumper(Objref_ptr objref, OperationDescriptor_ptr reflective, const QList< int >& path, QWidget * parent) : AbstractInputItem(objref, reflective, path, parent) { const QString& id = objref->name(); QVBoxLayout * layout = new QVBoxLayout(); layout->setMargin(0); qt::FormWidget * form = new qt::FormWidget(); form->layout()->setMargin(0); layout->addWidget(form); m_filePrefix = new QLineEdit(); QHBoxLayout * prefixLayout = new QHBoxLayout(); m_browse = new QPushButton("&Browse"); prefixLayout->addWidget(m_filePrefix); prefixLayout->addWidget(m_browse); prefixLayout->setMargin(0); form->addMediumField("File prefix", prefixLayout); m_suffixLength = new QSpinBox(); m_suffixLength->setRange(1, 10); m_suffixLength->setValue(4); form->addField("Suffix length", m_suffixLength); m_format = new QComboBox(); m_format->addItem("Binary (*.bin)"); m_format->addItem("Text (*.txt)"); m_format->addItem("JSON (*.json)"); form->addField("Format", m_format); m_multipleFiles = new QCheckBox(); m_multipleFiles->setChecked(true); form->addField("Multiple files", m_multipleFiles); // start and stop button m_startStopButton = new qt::StartStopButton(); m_startStopButton->setObjectName("start-stop"); QHBoxLayout * startStopLayout = new QHBoxLayout(); QSpacerItem * spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); startStopLayout->addItem(spacer); startStopLayout->addWidget(m_startStopButton); layout->addLayout(startStopLayout); setLayout(layout); connect(m_startStopButton, SIGNAL(clicked(bool)), this, SLOT(doStart(bool))); connect(m_startStopButton, SIGNAL(toggled(bool)), this, SLOT(setEnabled(bool))); connect(m_browse, SIGNAL(clicked()), this, SLOT(browse())); QString defaultFile(id); defaultFile += "."; defaultFile += getFieldName(reflective, path); defaultFile += "-"; m_filePrefix->setText(defaultFile); }