Skip to content
Snippets Groups Projects
Commit c59ff9b0 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

clang-format

parent 4b578f2d
No related branches found
No related tags found
No related merge requests found
...@@ -89,7 +89,9 @@ class GmshSocket{ ...@@ -89,7 +89,9 @@ class GmshSocket{
GMSH_OPTION_2 = 101, GMSH_OPTION_2 = 101,
GMSH_OPTION_3 = 102, GMSH_OPTION_3 = 102,
GMSH_OPTION_4 = 103, GMSH_OPTION_4 = 103,
GMSH_OPTION_5 = 104}; GMSH_OPTION_5 = 104
};
protected: protected:
// the socket descriptor // the socket descriptor
int _sock; int _sock;
...@@ -135,8 +137,7 @@ class GmshSocket{ ...@@ -135,8 +137,7 @@ class GmshSocket{
for(int i = 0; i < n; i++) { for(int i = 0; i < n; i++) {
char *a = &array[i * size]; char *a = &array[i * size];
memcpy(x, a, size); memcpy(x, a, size);
for(int c = 0; c < size; c++) for(int c = 0; c < size; c++) a[size - 1 - c] = x[c];
a[size - 1 - c] = x[c];
} }
delete[] x; delete[] x;
} }
...@@ -149,6 +150,7 @@ class GmshSocket{ ...@@ -149,6 +150,7 @@ class GmshSocket{
Sleep(ms); Sleep(ms);
#endif #endif
} }
public: public:
GmshSocket() : _sock(0), _sent(0), _received(0) GmshSocket() : _sock(0), _sent(0), _received(0)
{ {
...@@ -261,7 +263,8 @@ class GmshClient : public GmshSocket { ...@@ -261,7 +263,8 @@ class GmshClient : public GmshSocket {
~GmshClient() {} ~GmshClient() {}
int Connect(const char *sockname) int Connect(const char *sockname)
{ {
if(strstr(sockname, "/") || strstr(sockname, "\\") || !strstr(sockname, ":")){ if(strstr(sockname, "/") || strstr(sockname, "\\") ||
!strstr(sockname, ":")) {
#if !defined(WIN32) || defined(__CYGWIN__) #if !defined(WIN32) || defined(__CYGWIN__)
// UNIX socket (testing ":" is not enough with Windows paths) // UNIX socket (testing ":" is not enough with Windows paths)
_sock = socket(PF_UNIX, SOCK_STREAM, 0); _sock = socket(PF_UNIX, SOCK_STREAM, 0);
...@@ -292,10 +295,8 @@ class GmshClient : public GmshSocket { ...@@ -292,10 +295,8 @@ class GmshClient : public GmshSocket {
int portno = atoi(port + 1); int portno = atoi(port + 1);
char *remote = strdup(sockname); char *remote = strdup(sockname);
int remotelen = (int)(strlen(remote) - strlen(port)); int remotelen = (int)(strlen(remote) - strlen(port));
if(remotelen > 0) if(remotelen > 0) strncpy(remote, sockname, remotelen);
strncpy(remote, sockname, remotelen); if(remotelen >= 0) remote[remotelen] = '\0';
if(remotelen >= 0)
remote[remotelen] = '\0';
struct hostent *server; struct hostent *server;
if(!(server = gethostbyname(remote))) { if(!(server = gethostbyname(remote))) {
CloseSocket(_sock); CloseSocket(_sock);
...@@ -306,7 +307,8 @@ class GmshClient : public GmshSocket { ...@@ -306,7 +307,8 @@ class GmshClient : public GmshSocket {
struct sockaddr_in addr_in; struct sockaddr_in addr_in;
memset((char *)&addr_in, 0, sizeof(addr_in)); memset((char *)&addr_in, 0, sizeof(addr_in));
addr_in.sin_family = AF_INET; addr_in.sin_family = AF_INET;
memcpy((char *)&addr_in.sin_addr.s_addr, (char *)server->h_addr, server->h_length); memcpy((char *)&addr_in.sin_addr.s_addr, (char *)server->h_addr,
server->h_length);
addr_in.sin_port = htons(portno); addr_in.sin_port = htons(portno);
for(int tries = 0; tries < 5; tries++) { for(int tries = 0; tries < 5; tries++) {
if(connect(_sock, (struct sockaddr *)&addr_in, sizeof(addr_in)) >= 0) { if(connect(_sock, (struct sockaddr *)&addr_in, sizeof(addr_in)) >= 0) {
...@@ -335,15 +337,18 @@ class GmshClient : public GmshSocket { ...@@ -335,15 +337,18 @@ class GmshClient : public GmshSocket {
class GmshServer : public GmshSocket { class GmshServer : public GmshSocket {
private: private:
int _portno; int _portno;
public: public:
GmshServer() : GmshSocket(), _portno(-1) {} GmshServer() : GmshSocket(), _portno(-1) {}
virtual ~GmshServer() {} virtual ~GmshServer() {}
virtual int NonBlockingSystemCall(const std::string &exe, const std::string &args) = 0; virtual int NonBlockingSystemCall(const std::string &exe,
virtual int NonBlockingWait(double waitint, double timeout, int socket=-1) = 0; const std::string &args) = 0;
virtual int NonBlockingWait(double waitint, double timeout,
int socket = -1) = 0;
// start the client by launching "exe args" (args is supposed to contain // start the client by launching "exe args" (args is supposed to contain
// '%s' where the socket name should appear) // '%s' where the socket name should appear)
int Start(const std::string &exe, const std::string &args, const std::string &sockname, int Start(const std::string &exe, const std::string &args,
double timeout) const std::string &sockname, double timeout)
{ {
_sockname = sockname; _sockname = sockname;
int tmpsock; int tmpsock;
...@@ -430,9 +435,7 @@ class GmshServer : public GmshSocket{ ...@@ -430,9 +435,7 @@ class GmshServer : public GmshSocket{
int ret = NonBlockingWait(0.001, timeout, tmpsock); int ret = NonBlockingWait(0.001, timeout, tmpsock);
if(ret) { if(ret) {
CloseSocket(tmpsock); CloseSocket(tmpsock);
if(ret == 2){ if(ret == 2) { throw "Socket listening timeout"; }
throw "Socket listening timeout";
}
else { else {
return -1; // stopped listening return -1; // stopped listening
} }
...@@ -454,15 +457,13 @@ class GmshServer : public GmshSocket{ ...@@ -454,15 +457,13 @@ class GmshServer : public GmshSocket{
setsockopt(_sock, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)); setsockopt(_sock, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
} }
CloseSocket(tmpsock); CloseSocket(tmpsock);
if(_sock < 0) if(_sock < 0) throw "Socket accept failed";
throw "Socket accept failed";
return _sock; return _sock;
} }
int Shutdown() int Shutdown()
{ {
#if !defined(WIN32) || defined(__CYGWIN__) #if !defined(WIN32) || defined(__CYGWIN__)
if(_portno < 0) if(_portno < 0) unlink(_sockname.c_str());
unlink(_sockname.c_str());
#endif #endif
ShutdownSocket(_sock); ShutdownSocket(_sock);
CloseSocket(_sock); CloseSocket(_sock);
......
...@@ -97,8 +97,7 @@ namespace onelab { ...@@ -97,8 +97,7 @@ namespace onelab {
if(it != _clients.end()) it->second = changed; if(it != _clients.end()) it->second = changed;
} }
else { else {
for(auto it = _clients.begin(); for(auto it = _clients.begin(); it != _clients.end(); it++)
it != _clients.end(); it++)
it->second = changed; it->second = changed;
} }
} }
...@@ -180,8 +179,7 @@ namespace onelab { ...@@ -180,8 +179,7 @@ namespace onelab {
} }
else { else {
int changed = 0; int changed = 0;
for(auto it = _clients.begin(); for(auto it = _clients.begin(); it != _clients.end(); it++) {
it != _clients.end(); it++) {
changed = std::max(changed, it->second); changed = std::max(changed, it->second);
} }
return changed; return changed;
...@@ -193,8 +191,7 @@ namespace onelab { ...@@ -193,8 +191,7 @@ namespace onelab {
bool getReadOnly() const { return _readOnly; } bool getReadOnly() const { return _readOnly; }
std::string getAttribute(const std::string &key) const std::string getAttribute(const std::string &key) const
{ {
auto it = auto it = _attributes.find(key);
_attributes.find(key);
if(it != _attributes.end()) return it->second; if(it != _attributes.end()) return it->second;
return ""; return "";
} }
...@@ -262,14 +259,11 @@ namespace onelab { ...@@ -262,14 +259,11 @@ namespace onelab {
<< getChangedValue() << charSep() << (getVisible() ? 1 : 0) << getChangedValue() << charSep() << (getVisible() ? 1 : 0)
<< charSep() << (getReadOnly() ? 1 : 0) << charSep() << charSep() << (getReadOnly() ? 1 : 0) << charSep()
<< _attributes.size() << charSep(); << _attributes.size() << charSep();
for(auto it = for(auto it = _attributes.begin(); it != _attributes.end(); it++)
_attributes.begin();
it != _attributes.end(); it++)
sstream << sanitize(it->first) << charSep() << sanitize(it->second) sstream << sanitize(it->first) << charSep() << sanitize(it->second)
<< charSep(); << charSep();
sstream << getClients().size() << charSep(); sstream << getClients().size() << charSep();
for(auto it = getClients().begin(); for(auto it = getClients().begin(); it != getClients().end(); it++)
it != getClients().end(); it++)
sstream << sanitize(it->first) << charSep() << (it->second ? 1 : 0) sstream << sanitize(it->first) << charSep() << (it->second ? 1 : 0)
<< charSep(); << charSep();
return sstream.str(); return sstream.str();
...@@ -354,9 +348,7 @@ namespace onelab { ...@@ -354,9 +348,7 @@ namespace onelab {
<< ", \"readOnly\":" << (getReadOnly() ? "true" : "false"); << ", \"readOnly\":" << (getReadOnly() ? "true" : "false");
if(_attributes.size()) { if(_attributes.size()) {
sstream << ", \"attributes\":{ "; sstream << ", \"attributes\":{ ";
for(auto it = for(auto it = _attributes.begin(); it != _attributes.end(); it++) {
_attributes.begin();
it != _attributes.end(); it++) {
if(it != _attributes.begin()) sstream << ", "; if(it != _attributes.begin()) sstream << ", ";
sstream << "\"" << sanitizeJSON(it->first) << "\":\"" sstream << "\"" << sanitizeJSON(it->first) << "\":\""
<< sanitizeJSON(it->second) << "\""; << sanitizeJSON(it->second) << "\"";
...@@ -365,9 +357,7 @@ namespace onelab { ...@@ -365,9 +357,7 @@ namespace onelab {
} }
if(getClients().size()) { if(getClients().size()) {
sstream << ", \"clients\":{ "; sstream << ", \"clients\":{ ";
for(auto it = for(auto it = getClients().begin(); it != getClients().end(); it++) {
getClients().begin();
it != getClients().end(); it++) {
if(it != getClients().begin()) sstream << ", "; if(it != getClients().begin()) sstream << ", ";
sstream << "\"" << sanitizeJSON(it->first) << "\":" << it->second; sstream << "\"" << sanitizeJSON(it->first) << "\":" << it->second;
} }
...@@ -378,8 +368,7 @@ namespace onelab { ...@@ -378,8 +368,7 @@ namespace onelab {
#if defined(HAVE_PICOJSON) #if defined(HAVE_PICOJSON)
virtual bool fromJSON(const picojson::value::object &par) virtual bool fromJSON(const picojson::value::object &par)
{ {
for(auto it = par.begin(); for(auto it = par.begin(); it != par.end(); ++it) {
it != par.end(); ++it) {
if(it->first == "name") { if(it->first == "name") {
if(!it->second.is<std::string>()) return false; if(!it->second.is<std::string>()) return false;
setName(it->second.get<std::string>()); setName(it->second.get<std::string>());
...@@ -408,8 +397,7 @@ namespace onelab { ...@@ -408,8 +397,7 @@ namespace onelab {
if(!it->second.is<picojson::object>()) return false; if(!it->second.is<picojson::object>()) return false;
const picojson::value::object &obj = const picojson::value::object &obj =
it->second.get<picojson::object>(); it->second.get<picojson::object>();
for(auto i = obj.begin(); for(auto i = obj.begin(); i != obj.end(); ++i) {
i != obj.end(); ++i) {
std::string key(i->first); std::string key(i->first);
if(!i->second.is<std::string>()) return false; if(!i->second.is<std::string>()) return false;
setAttribute(key, i->second.get<std::string>()); setAttribute(key, i->second.get<std::string>());
...@@ -419,8 +407,7 @@ namespace onelab { ...@@ -419,8 +407,7 @@ namespace onelab {
if(!it->second.is<picojson::object>()) return false; if(!it->second.is<picojson::object>()) return false;
const picojson::value::object &obj = const picojson::value::object &obj =
it->second.get<picojson::object>(); it->second.get<picojson::object>();
for(auto i = obj.begin(); for(auto i = obj.begin(); i != obj.end(); ++i) {
i != obj.end(); ++i) {
std::string client(i->first); std::string client(i->first);
if(!i->second.is<double>()) return false; if(!i->second.is<double>()) return false;
addClient(client, (int)i->second.get<double>()); addClient(client, (int)i->second.get<double>());
...@@ -515,8 +502,7 @@ namespace onelab { ...@@ -515,8 +502,7 @@ namespace onelab {
} }
std::string getValueLabel(double value) const std::string getValueLabel(double value) const
{ {
auto it = auto it = _valueLabels.find(value);
_valueLabels.find(value);
if(it != _valueLabels.end()) return it->second; if(it != _valueLabels.end()) return it->second;
return ""; return "";
} }
...@@ -559,9 +545,7 @@ namespace onelab { ...@@ -559,9 +545,7 @@ namespace onelab {
for(std::size_t i = 0; i < _choices.size(); i++) for(std::size_t i = 0; i < _choices.size(); i++)
sstream << _choices[i] << charSep(); sstream << _choices[i] << charSep();
sstream << _valueLabels.size() << charSep(); sstream << _valueLabels.size() << charSep();
for(auto it = for(auto it = _valueLabels.begin(); it != _valueLabels.end(); it++) {
_valueLabels.begin();
it != _valueLabels.end(); it++) {
sstream << it->first << charSep() << sanitize(it->second) << charSep(); sstream << it->first << charSep() << sanitize(it->second) << charSep();
} }
return sstream.str(); return sstream.str();
...@@ -609,9 +593,7 @@ namespace onelab { ...@@ -609,9 +593,7 @@ namespace onelab {
} }
if(_valueLabels.size()) { if(_valueLabels.size()) {
sstream << ", \"valueLabels\":{ "; sstream << ", \"valueLabels\":{ ";
for(auto it = for(auto it = _valueLabels.begin(); it != _valueLabels.end(); it++) {
_valueLabels.begin();
it != _valueLabels.end(); it++) {
if(it != _valueLabels.begin()) sstream << ", "; if(it != _valueLabels.begin()) sstream << ", ";
sstream << "\"" << sanitizeJSON(it->second) << "\":" << it->first; sstream << "\"" << sanitizeJSON(it->second) << "\":" << it->first;
} }
...@@ -641,8 +623,7 @@ namespace onelab { ...@@ -641,8 +623,7 @@ namespace onelab {
bool fromJSON(const picojson::value::object &par) bool fromJSON(const picojson::value::object &par)
{ {
if(!parameter::fromJSON(par)) return false; if(!parameter::fromJSON(par)) return false;
for(auto it = par.begin(); for(auto it = par.begin(); it != par.end(); ++it) {
it != par.end(); ++it) {
if(it->first == "values") { if(it->first == "values") {
if(!it->second.is<picojson::array>()) return false; if(!it->second.is<picojson::array>()) return false;
const picojson::value::array &arr = it->second.get<picojson::array>(); const picojson::value::array &arr = it->second.get<picojson::array>();
...@@ -681,8 +662,7 @@ namespace onelab { ...@@ -681,8 +662,7 @@ namespace onelab {
if(!it->second.is<picojson::object>()) return false; if(!it->second.is<picojson::object>()) return false;
const picojson::value::object &obj = const picojson::value::object &obj =
it->second.get<picojson::object>(); it->second.get<picojson::object>();
for(auto i = obj.begin(); for(auto i = obj.begin(); i != obj.end(); ++i) {
i != obj.end(); ++i) {
if(!i->second.is<double>()) return false; if(!i->second.is<double>()) return false;
_valueLabels[i->second.get<double>()] = i->first; _valueLabels[i->second.get<double>()] = i->first;
} }
...@@ -730,10 +710,7 @@ namespace onelab { ...@@ -730,10 +710,7 @@ namespace onelab {
if(_values.empty()) return n; if(_values.empty()) return n;
return _values[0]; return _values[0];
} }
std::string getValueAsString() const std::string getValueAsString() const { return getValue(); }
{
return getValue();
}
const std::vector<std::string> &getValues() const { return _values; } const std::vector<std::string> &getValues() const { return _values; }
int getNumValues() const { return (int)_values.size(); } int getNumValues() const { return (int)_values.size(); }
const std::string &getKind() const { return _kind; } const std::string &getKind() const { return _kind; }
...@@ -831,8 +808,7 @@ namespace onelab { ...@@ -831,8 +808,7 @@ namespace onelab {
bool fromJSON(const picojson::value::object &par) bool fromJSON(const picojson::value::object &par)
{ {
if(!parameter::fromJSON(par)) return false; if(!parameter::fromJSON(par)) return false;
for(auto it = par.begin(); for(auto it = par.begin(); it != par.end(); ++it) {
it != par.end(); ++it) {
if(it->first == "values") { if(it->first == "values") {
if(!it->second.is<picojson::array>()) return false; if(!it->second.is<picojson::array>()) return false;
const picojson::value::array &arr = it->second.get<picojson::array>(); const picojson::value::array &arr = it->second.get<picojson::array>();
...@@ -876,8 +852,7 @@ namespace onelab { ...@@ -876,8 +852,7 @@ namespace onelab {
{ {
if(name.empty() && client.size()) { if(name.empty() && client.size()) {
std::vector<T *> toDelete; std::vector<T *> toDelete;
for(auto it = ps.begin(); for(auto it = ps.begin(); it != ps.end();) {
it != ps.end();) {
T *p = *it; T *p = *it;
if(p->hasClient(client)) { if(p->hasClient(client)) {
ps.erase(it++); // to avoid invalid iterator ps.erase(it++); // to avoid invalid iterator
...@@ -936,9 +911,7 @@ namespace onelab { ...@@ -936,9 +911,7 @@ namespace onelab {
{ {
p.clear(); p.clear();
if(name.empty()) { if(name.empty()) {
for(auto it = ps.begin(); for(auto it = ps.begin(); it != ps.end(); it++) p.push_back(**it);
it != ps.end(); it++)
p.push_back(**it);
} }
else { else {
T tmp(name); T tmp(name);
...@@ -979,9 +952,7 @@ namespace onelab { ...@@ -979,9 +952,7 @@ namespace onelab {
if(name.empty() && client.empty()) { if(name.empty() && client.empty()) {
std::set<parameter *, parameterLessThan> ps; std::set<parameter *, parameterLessThan> ps;
getAllParameters(ps); getAllParameters(ps);
for(auto it = ps.begin(); for(auto it = ps.begin(); it != ps.end(); it++) delete *it;
it != ps.end(); it++)
delete *it;
_numbers.clear(); _numbers.clear();
_strings.clear(); _strings.clear();
} }
...@@ -1023,10 +994,7 @@ namespace onelab { ...@@ -1023,10 +994,7 @@ namespace onelab {
ps.insert(_numbers.begin(), _numbers.end()); ps.insert(_numbers.begin(), _numbers.end());
ps.insert(_strings.begin(), _strings.end()); ps.insert(_strings.begin(), _strings.end());
} }
int getNumParameters() int getNumParameters() { return (int)(_numbers.size() + _strings.size()); }
{
return (int)(_numbers.size() + _strings.size());
}
void getParameterNames(std::vector<std::string> &names, void getParameterNames(std::vector<std::string> &names,
const std::string &search = "") const const std::string &search = "") const
{ {
...@@ -1045,8 +1013,7 @@ namespace onelab { ...@@ -1045,8 +1013,7 @@ namespace onelab {
if(std::regex_search(p->getName(), std::regex(search))) if(std::regex_search(p->getName(), std::regex(search)))
names.push_back(p->getName()); names.push_back(p->getName());
} }
} } catch(...) {
catch(...) {
} }
} }
} }
...@@ -1055,8 +1022,7 @@ namespace onelab { ...@@ -1055,8 +1022,7 @@ namespace onelab {
{ {
std::set<parameter *, parameterLessThan> ps; std::set<parameter *, parameterLessThan> ps;
getAllParameters(ps); getAllParameters(ps);
for(auto it = ps.begin(); for(auto it = ps.begin(); it != ps.end(); it++)
it != ps.end(); it++)
if((*it)->hasClient(client)) return true; if((*it)->hasClient(client)) return true;
return false; return false;
} }
...@@ -1067,8 +1033,7 @@ namespace onelab { ...@@ -1067,8 +1033,7 @@ namespace onelab {
std::set<parameter *, parameterLessThan> ps; std::set<parameter *, parameterLessThan> ps;
getAllParameters(ps); getAllParameters(ps);
int changed = 0; int changed = 0;
for(auto it = ps.begin(); for(auto it = ps.begin(); it != ps.end(); it++) {
it != ps.end(); it++) {
changed = std::max(changed, (*it)->getChanged(client)); changed = std::max(changed, (*it)->getChanged(client));
} }
return changed; return changed;
...@@ -1079,16 +1044,14 @@ namespace onelab { ...@@ -1079,16 +1044,14 @@ namespace onelab {
{ {
std::set<parameter *, parameterLessThan> ps; std::set<parameter *, parameterLessThan> ps;
getAllParameters(ps); getAllParameters(ps);
for(auto it = ps.begin(); for(auto it = ps.begin(); it != ps.end(); it++)
it != ps.end(); it++)
(*it)->setChanged(changed, client); (*it)->setChanged(changed, client);
} }
void thresholdChanged(int threshold, const std::string &client = "") void thresholdChanged(int threshold, const std::string &client = "")
{ {
std::set<parameter *, parameterLessThan> ps; std::set<parameter *, parameterLessThan> ps;
getAllParameters(ps); getAllParameters(ps);
for(auto it = ps.begin(); for(auto it = ps.begin(); it != ps.end(); it++) {
it != ps.end(); it++) {
int changed = (*it)->getChanged(client); int changed = (*it)->getChanged(client);
if(changed > threshold) (*it)->setChanged(threshold, client); if(changed > threshold) (*it)->setChanged(threshold, client);
} }
...@@ -1100,9 +1063,7 @@ namespace onelab { ...@@ -1100,9 +1063,7 @@ namespace onelab {
std::vector<std::string> s; std::vector<std::string> s;
std::set<parameter *, parameterLessThan> ps; std::set<parameter *, parameterLessThan> ps;
getAllParameters(ps); getAllParameters(ps);
for(auto it = for(auto it = ps.begin(); it != ps.end(); it++)
ps.begin();
it != ps.end(); it++)
if(client.empty() || (*it)->hasClient(client)) { if(client.empty() || (*it)->hasClient(client)) {
if((*it)->getAttribute("NotInDb") != "True") if((*it)->getAttribute("NotInDb") != "True")
s.push_back((*it)->toChar()); s.push_back((*it)->toChar());
...@@ -1147,9 +1108,7 @@ namespace onelab { ...@@ -1147,9 +1108,7 @@ namespace onelab {
json += " \"parameters\":[\n"; json += " \"parameters\":[\n";
std::set<parameter *, parameterLessThan> ps; std::set<parameter *, parameterLessThan> ps;
getAllParameters(ps); getAllParameters(ps);
for(auto it = for(auto it = ps.begin(); it != ps.end(); it++) {
ps.begin();
it != ps.end(); it++) {
if(it != ps.begin()) json += ",\n"; if(it != ps.begin()) json += ",\n";
if(client.empty() || (*it)->hasClient(client)) { if(client.empty() || (*it)->hasClient(client)) {
if((*it)->getAttribute("NotInDb") != "True") { if((*it)->getAttribute("NotInDb") != "True") {
...@@ -1171,7 +1130,8 @@ namespace onelab { ...@@ -1171,7 +1130,8 @@ namespace onelab {
auto it = obj.find("onelab"); auto it = obj.find("onelab");
if(it != obj.end()) { // full database if(it != obj.end()) { // full database
if(!it->second.is<picojson::object>()) return false; if(!it->second.is<picojson::object>()) return false;
const picojson::value::object &db = it->second.get<picojson::object>(); const picojson::value::object &db =
it->second.get<picojson::object>();
for(auto j = db.begin(); j != db.end(); ++j) { for(auto j = db.begin(); j != db.end(); ++j) {
if(j->first == "version") { if(j->first == "version") {
if(!j->second.is<std::string>()) return false; if(!j->second.is<std::string>()) return false;
...@@ -1180,10 +1140,12 @@ namespace onelab { ...@@ -1180,10 +1140,12 @@ namespace onelab {
} }
else if(j->first == "parameters") { else if(j->first == "parameters") {
if(!j->second.is<picojson::array>()) return false; if(!j->second.is<picojson::array>()) return false;
const picojson::value::array &arr = j->second.get<picojson::array>(); const picojson::value::array &arr =
j->second.get<picojson::array>();
for(std::size_t k = 0; k < arr.size(); k++) { for(std::size_t k = 0; k < arr.size(); k++) {
if(!arr[k].is<picojson::object>()) return false; if(!arr[k].is<picojson::object>()) return false;
const picojson::value::object &par = arr[k].get<picojson::object>(); const picojson::value::object &par =
arr[k].get<picojson::object>();
if(!fromJSON(par, client)) return false; if(!fromJSON(par, client)) return false;
} }
} }
...@@ -1211,7 +1173,8 @@ namespace onelab { ...@@ -1211,7 +1173,8 @@ namespace onelab {
#endif #endif
} }
#if defined(HAVE_PICOJSON) #if defined(HAVE_PICOJSON)
bool fromJSON(const picojson::value::object &par, const std::string &client = "") bool fromJSON(const picojson::value::object &par,
const std::string &client = "")
{ {
auto it = par.find("type"); auto it = par.find("type");
if(it == par.end()) return false; if(it == par.end()) return false;
...@@ -1391,10 +1354,7 @@ namespace onelab { ...@@ -1391,10 +1354,7 @@ namespace onelab {
{ {
_parameterSpace.thresholdChanged(value, client); _parameterSpace.thresholdChanged(value, client);
} }
int getNumParameters() int getNumParameters() { return _parameterSpace.getNumParameters(); }
{
return _parameterSpace.getNumParameters();
}
void getParameterNames(std::vector<std::string> &names, void getParameterNames(std::vector<std::string> &names,
const std::string &search = "") const const std::string &search = "") const
{ {
...@@ -1706,8 +1666,8 @@ namespace onelab { ...@@ -1706,8 +1666,8 @@ namespace onelab {
if(!_gmshClient) return false; if(!_gmshClient) return false;
std::string msg = name; std::string msg = name;
if(msg.empty()) msg = "*"; if(msg.empty()) msg = "*";
_gmshClient->SendMessage(GmshSocket::GMSH_PARAMETER_CLEAR, (int)msg.size(), _gmshClient->SendMessage(GmshSocket::GMSH_PARAMETER_CLEAR,
&msg[0]); (int)msg.size(), &msg[0]);
return true; return true;
} }
virtual bool set(const number &p) { return _set(p); } virtual bool set(const number &p) { return _set(p); }
...@@ -1783,7 +1743,8 @@ namespace onelab { ...@@ -1783,7 +1743,8 @@ namespace onelab {
} }
#endif #endif
std::string msg = name + parameter::charSep() + command; std::string msg = name + parameter::charSep() + command;
_gmshClient->SendMessage(GmshSocket::GMSH_CONNECT, (int)msg.size(), &msg[0]); _gmshClient->SendMessage(GmshSocket::GMSH_CONNECT, (int)msg.size(),
&msg[0]);
_numSubClients += 1; _numSubClients += 1;
} }
void runSubClient(const std::string &name, const std::string &command) void runSubClient(const std::string &name, const std::string &command)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment