module SALOME
{
+ typedef sequence<string> StringVec;
+
interface BasicDataServer
{
string getVarName();
interface DataScopeServer
{
string getScopeName();
+ StringVec listVars();
+ BasicDataServer retrieveVar(in string varName);
StringDataServer createGlobalStringVar(in string varName);
AnyDataServer createGlobalAnyVar(in string varName);
};
interface DataServerManager
{
+ StringVec listScopes();
DataScopeServer getDefaultScope();
DataScopeServer createDataScope(in string scopeName);
DataScopeServer retriveDataScope(in string scopeName);
#include "SALOMESDS_Exception.hxx"
#include <sstream>
+#include <iterator>
#include <algorithm>
using namespace SALOMESDS;
return CORBA::string_dup(_name.c_str());
}
+/*!
+ * Called remotely -> to protect against throw
+ */
+SALOME::StringVec *DataScopeServer::listVars()
+{
+ SALOME::StringVec *ret(new SALOME::StringVec);
+ std::size_t sz(_vars.size());
+ ret->length(sz);
+ std::list< std::pair< SALOME::BasicDataServer_var, AutoRefCountPtr<BasicDataServer> > >::iterator it(_vars.begin());
+ for(std::size_t i=0;i<sz;it++,i++)
+ {
+ BasicDataServer *obj((*it).second);
+ std::string name(obj->getVarNameCpp());
+ (*ret)[i]=CORBA::string_dup(name.c_str());
+ }
+ return ret;
+}
+
+/*!
+ * Called remotely -> to protect against throw
+ */
+SALOME::BasicDataServer_ptr DataScopeServer::retrieveVar(const char *varName)
+{
+ std::string varNameCpp(varName);
+ std::vector<std::string> allNames(getAllVarNames());
+ std::vector<std::string>::iterator it(std::find(allNames.begin(),allNames.end(),varNameCpp));
+ if(it==allNames.end())
+ {
+ std::ostringstream oss; oss << "DataScopeServer::retrieveVar : name \"" << varNameCpp << "\" does not exists ! Possibilities are :";
+ std::copy(allNames.begin(),allNames.end(),std::ostream_iterator<std::string>(oss,", "));
+ throw Exception(oss.str());
+ }
+ std::size_t pos(std::distance(allNames.begin(),it));
+ std::list< std::pair< SALOME::BasicDataServer_var, AutoRefCountPtr<BasicDataServer> > >::iterator it0(_vars.begin());
+ for(std::size_t i=0;i<pos;i++,it0++);
+ return SALOME::BasicDataServer::_duplicate((*it0).first);
+}
+
/*!
* Called remotely -> to protect against throw
*/
throw Exception(oss.str());
}
AutoRefCountPtr<StringDataServer> tmp(new StringDataServer(varNameCpp));
- _vars.push_back(DynamicCastSafe<StringDataServer,BasicDataServer>(tmp));
CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
+ std::pair< SALOME::BasicDataServer_var, AutoRefCountPtr<BasicDataServer> > p(SALOME::BasicDataServer::_narrow(ret),DynamicCastSafe<StringDataServer,BasicDataServer>(tmp));
+ _vars.push_back(p);
return SALOME::StringDataServer::_narrow(ret);
}
throw Exception(oss.str());
}
AutoRefCountPtr<AnyDataServer> tmp(new AnyDataServer(varNameCpp));
- _vars.push_back(DynamicCastSafe<AnyDataServer,BasicDataServer>(tmp));
CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
+ std::pair< SALOME::BasicDataServer_var, AutoRefCountPtr<BasicDataServer> > p(SALOME::BasicDataServer::_narrow(ret),DynamicCastSafe<AnyDataServer,BasicDataServer>(tmp));
+ _vars.push_back(p);
return SALOME::AnyDataServer::_narrow(ret);
}
{
std::size_t sz(_vars.size());
std::vector<std::string> ret(sz);
- std::list< AutoRefCountPtr<BasicDataServer> >::const_iterator it(_vars.begin());
+ std::list< std::pair< SALOME::BasicDataServer_var, AutoRefCountPtr<BasicDataServer> > >::const_iterator it(_vars.begin());
for(std::size_t i=0;i<sz;it++,i++)
- ret[i]=(*it)->getVarNameCpp();
+ ret[i]=(*it).second->getVarNameCpp();
return ret;
}
id=_poa->activate_object(_dft_scope);
obj=_poa->id_to_reference(id);
_ptr_dft_scope=SALOME::DataScopeServer::_narrow(obj);
- _scopes.push_back(_dft_scope);
+ _scopes.push_back(_ptr_dft_scope);
//
std::string fullNameInNS(CreateAbsNameInNSFromScopeName(DFT_SCOPE_NAME_IN_NS));
ns.Register(_ptr_dft_scope,fullNameInNS.c_str());
}
+SALOME::StringVec *DataServerManager::listScopes()
+{
+ SALOME::StringVec *ret(new SALOME::StringVec);
+ std::size_t sz(_scopes.size());
+ ret->length(sz);
+ std::list< SALOME::DataScopeServer_var >::iterator it(_scopes.begin());
+ for(std::size_t i=0;i<sz;it++,i++)
+ {
+ SALOME::DataScopeServer_var obj(*it);
+ char *name(obj->getScopeName());
+ (*ret)[i]=CORBA::string_dup(name);
+ CORBA::string_free(name);
+ }
+ return ret;
+}
+
SALOME::DataScopeServer_ptr DataServerManager::getDefaultScope()
{
return SALOME::DataScopeServer::_duplicate(_ptr_dft_scope);