diff options
Diffstat (limited to 'cpp/demo')
95 files changed, 4309 insertions, 4309 deletions
diff --git a/cpp/demo/Database/Oracle/occi/Client.cpp b/cpp/demo/Database/Oracle/occi/Client.cpp index 2260decdd0b..569fdf620fc 100644 --- a/cpp/demo/Database/Oracle/occi/Client.cpp +++ b/cpp/demo/Database/Oracle/occi/Client.cpp @@ -63,32 +63,32 @@ HRClient::HRClient() : _currentMenu(rootMenu) { _commonCommands = - "dept <number>: set department <number> as the current department\n" - "emp <number>: set employee <number> as the current employee\n" - "exit or quit: exit client\n" - "help: print this list of commands\n" - "root: go back to the root menu\n"; + "dept <number>: set department <number> as the current department\n" + "emp <number>: set employee <number> as the current employee\n" + "exit or quit: exit client\n" + "help: print this list of commands\n" + "root: go back to the root menu\n"; _rootCommands = - "create: create a new department\n" - "find <name>: find the department(s) with the given name\n" - "list: list all departments\n"; + "create: create a new department\n" + "find <name>: find the department(s) with the given name\n" + "list: list all departments\n"; - + _deptCommands = - "create: create a new employee in this department\n" - "find <name>: find employee(s) named <name> in this department\n" - "list: list all employees in this department\n" - "ping: ping this department\n" - "remove: remove this department\n" - "show: describe this department\n" - "update <dname|loc> <new value>: update this department\n"; + "create: create a new employee in this department\n" + "find <name>: find employee(s) named <name> in this department\n" + "list: list all employees in this department\n" + "ping: ping this department\n" + "remove: remove this department\n" + "show: describe this department\n" + "update <dname|loc> <new value>: update this department\n"; _empCommands = - "ping: ping this employee\n" - "remove: remove this employee\n" - "show: describe this employee\n" - "update <ename|job|mgr|hiredate|sal|comm|dept> <new-value>: update this employee\n"; + "ping: ping this employee\n" + "remove: remove this employee\n" + "show: describe this employee\n" + "update <ename|job|mgr|hiredate|sal|comm|dept> <new-value>: update this employee\n"; } void @@ -96,13 +96,13 @@ HRClient::checkEof(const string& command) const { if(!cin.eof()) { - string extra; - getline(cin, extra); - if(extra.size() > 0) - { - cout << "Warning: ignoring extra args '" << extra - << "' for '" << command << "'" << endl; - } + string extra; + getline(cin, extra); + if(extra.size() > 0) + { + cout << "Warning: ignoring extra args '" << extra + << "' for '" << command << "'" << endl; + } } } @@ -111,10 +111,10 @@ HRClient::checkCin(const string& command) const { if(!cin) { - cout << "Error: failed to read arguments for '" << command << "'" << endl; - cin.clear(); - cin.ignore(numeric_limits<streamsize>::max(), '\n'); - return false; + cout << "Error: failed to read arguments for '" << command << "'" << endl; + cin.clear(); + cin.ignore(numeric_limits<streamsize>::max(), '\n'); + return false; } checkEof(command); return true; @@ -124,7 +124,7 @@ void HRClient::invalidCommand(const string& command) const { cout << "Invalid command '" << command << "'. " - "Type 'help' for help." << endl; + "Type 'help' for help." << endl; cin.ignore(numeric_limits<streamsize>::max(), '\n'); } @@ -136,21 +136,21 @@ HRClient::help() const switch(_currentMenu) { - case rootMenu: - { - cout << _rootCommands; - break; - } - case deptMenu: - { - cout << _deptCommands; - break; - } - case empMenu: - { - cout << _empCommands; - break; - } + case rootMenu: + { + cout << _rootCommands; + break; + } + case deptMenu: + { + cout << _deptCommands; + break; + } + case empMenu: + { + cout << _empCommands; + break; + } } cout << "--- Common to all menus ---\n"; cout << _commonCommands << endl; @@ -163,8 +163,8 @@ HRClient::run(int argc, char* argv[]) _factory = DeptFactoryPrx::checkedCast(base); if(_factory == 0) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } Ice::EndpointSeq endpoints = _factory->ice_getEndpoints(); @@ -178,102 +178,102 @@ HRClient::run(int argc, char* argv[]) do { - cout << "==> "; - cin >> command; - - if(!cin) - { - break; - } - - try - { - - // - // Common commands - // - if(command == "dept") - { - int deptno; - cin >> deptno; - if(checkCin(command)) - { - _currentDept = DeptPrx::uncheckedCast(_factory->findDeptByNo(deptno)); - if(_currentDept != 0) - { - _currentMenu = deptMenu; - } - else - { - cout << "There is no department with deptno " << deptno << endl; - } - } - } - else if(command == "emp") - { - int empno; - cin >> empno; - if(checkCin(command)) - { - _currentEmp = EmpPrx::uncheckedCast(_factory->findEmpByNo(empno)); - if(_currentEmp != 0) - { - _currentMenu = empMenu; - } - else - { - cout << "There is no employee with empno " << empno << endl; - } - } - } - else if(command == "exit" || command == "quit") - { - checkEof(command); - break; - } - else if(command == "help") - { - checkEof(command); - help(); - } - else if(command == "root") - { - checkEof(command); - _currentMenu = rootMenu; - } - else if(_currentMenu == rootMenu) - { - doRootMenu(command); - } - else if(_currentMenu == deptMenu) - { - doDeptMenu(command); - } - else if(_currentMenu == empMenu) - { - doEmpMenu(command); - } - else - { - assert(0); - } - } - catch(const SqlException& e) - { - cout << "Caught a SqlException: " << e.reason << endl; - } - catch(const IceUtil::Exception& e) - { - cout << "Caught an Ice exception: " << e << endl; - } - catch(const std::exception& e) - { - cout << "Caught a std::exception: " << e.what() << endl; - } - catch(...) - { - cout << "Caught an unknown exception" << endl; - } + cout << "==> "; + cin >> command; + + if(!cin) + { + break; + } + + try + { + + // + // Common commands + // + if(command == "dept") + { + int deptno; + cin >> deptno; + if(checkCin(command)) + { + _currentDept = DeptPrx::uncheckedCast(_factory->findDeptByNo(deptno)); + if(_currentDept != 0) + { + _currentMenu = deptMenu; + } + else + { + cout << "There is no department with deptno " << deptno << endl; + } + } + } + else if(command == "emp") + { + int empno; + cin >> empno; + if(checkCin(command)) + { + _currentEmp = EmpPrx::uncheckedCast(_factory->findEmpByNo(empno)); + if(_currentEmp != 0) + { + _currentMenu = empMenu; + } + else + { + cout << "There is no employee with empno " << empno << endl; + } + } + } + else if(command == "exit" || command == "quit") + { + checkEof(command); + break; + } + else if(command == "help") + { + checkEof(command); + help(); + } + else if(command == "root") + { + checkEof(command); + _currentMenu = rootMenu; + } + else if(_currentMenu == rootMenu) + { + doRootMenu(command); + } + else if(_currentMenu == deptMenu) + { + doDeptMenu(command); + } + else if(_currentMenu == empMenu) + { + doEmpMenu(command); + } + else + { + assert(0); + } + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } } while(cin.good()); @@ -285,38 +285,38 @@ HRClient::doRootMenu(const string& command) const { if(command == "create") { - checkEof(command); - cout << "Please enter: deptno dname loc ==> "; - int deptno; - DeptDesc desc; - cin >> deptno >> desc.dname >> desc.loc; - - desc.dname = unquote(desc.dname); - desc.loc = unquote(desc.loc); - - if(checkCin("create parameters")) - { - _factory->createDept(deptno, desc); - cout << "Created new department number " << deptno << endl; - } + checkEof(command); + cout << "Please enter: deptno dname loc ==> "; + int deptno; + DeptDesc desc; + cin >> deptno >> desc.dname >> desc.loc; + + desc.dname = unquote(desc.dname); + desc.loc = unquote(desc.loc); + + if(checkCin("create parameters")) + { + _factory->createDept(deptno, desc); + cout << "Created new department number " << deptno << endl; + } } else if(command == "find") { - string name; - cin >> name; - if(checkCin(command)) - { - printDepts(_factory->findByName(name)); - } + string name; + cin >> name; + if(checkCin(command)) + { + printDepts(_factory->findByName(name)); + } } else if(command == "list") { - checkEof(command); - printDepts(_factory->findAll()); + checkEof(command); + printDepts(_factory->findAll()); } else { - invalidCommand(command); + invalidCommand(command); } } @@ -325,84 +325,84 @@ HRClient::doDeptMenu(const string& command) const { if(command == "create") { - checkEof(command); - cout << "Please enter: empno ename job mgr(empno) hiredate sal comm ==> "; - int empno; - int mgrEmpno; - EmpDesc desc; - cin >> empno >> desc.ename >> desc.job >> mgrEmpno >> desc.hiredate >> desc.sal >> desc.comm; - - desc.ename = unquote(desc.ename); - desc.job = unquote(desc.job); - - if(mgrEmpno != 0) - { - desc.mgr = _factory->findEmpByNo(mgrEmpno); - if(desc.mgr == 0) - { - cout << "Manager #" << mgrEmpno << " does not exist: clearing manager" << endl; - } - } - desc.hiredate = unquote(desc.hiredate); - desc.sal = unquote(desc.sal); - desc.comm = unquote(desc.comm); - - desc.edept = _currentDept; - - if(checkCin("create parameters")) - { - _currentDept->createEmp(empno, desc); - cout << "Created new employee number " << empno << endl; - } + checkEof(command); + cout << "Please enter: empno ename job mgr(empno) hiredate sal comm ==> "; + int empno; + int mgrEmpno; + EmpDesc desc; + cin >> empno >> desc.ename >> desc.job >> mgrEmpno >> desc.hiredate >> desc.sal >> desc.comm; + + desc.ename = unquote(desc.ename); + desc.job = unquote(desc.job); + + if(mgrEmpno != 0) + { + desc.mgr = _factory->findEmpByNo(mgrEmpno); + if(desc.mgr == 0) + { + cout << "Manager #" << mgrEmpno << " does not exist: clearing manager" << endl; + } + } + desc.hiredate = unquote(desc.hiredate); + desc.sal = unquote(desc.sal); + desc.comm = unquote(desc.comm); + + desc.edept = _currentDept; + + if(checkCin("create parameters")) + { + _currentDept->createEmp(empno, desc); + cout << "Created new employee number " << empno << endl; + } } else if(command == "find") { - string name; - cin >> name; - if(checkCin(command)) - { - printEmps(_currentDept->findByName(name)); - } + string name; + cin >> name; + if(checkCin(command)) + { + printEmps(_currentDept->findByName(name)); + } } else if(command == "list") { - checkEof(command); - printEmps(_currentDept->findAll()); + checkEof(command); + printEmps(_currentDept->findAll()); } else if(command == "ping") { - checkEof(command); - _currentDept->ice_ping(); - cout << "ice_ping: success!" << endl; + checkEof(command); + _currentDept->ice_ping(); + cout << "ice_ping: success!" << endl; } else if(command == "remove") { - checkEof(command); - _currentDept->remove(); + checkEof(command); + _currentDept->remove(); } else if(command == "show") { - checkEof(command); - DeptDesc desc = _currentDept->getDesc(); - cout << "deptno: " << desc.deptno << endl; - cout << "dname: " << quote(desc.dname) << endl; - cout << "loc: " << quote(desc.loc) << endl; + checkEof(command); + DeptDesc desc = _currentDept->getDesc(); + cout << "deptno: " << desc.deptno << endl; + cout << "dname: " << quote(desc.dname) << endl; + cout << "loc: " << quote(desc.loc) << endl; } else if(command == "update") { - string field; - string newValue; - cin >> field >> newValue; - newValue = unquote(newValue); - - if(checkCin("update " + field)) - { - _currentDept->updateField(field, newValue); - } + string field; + string newValue; + cin >> field >> newValue; + newValue = unquote(newValue); + + if(checkCin("update " + field)) + { + _currentDept->updateField(field, newValue); + } } else { - invalidCommand(command); + invalidCommand(command); } } @@ -411,80 +411,80 @@ HRClient::doEmpMenu(const string& command) const { if(command == "ping") { - checkEof(command); - _currentEmp->ice_ping(); - cout << "ice_ping: success!" << endl; + checkEof(command); + _currentEmp->ice_ping(); + cout << "ice_ping: success!" << endl; } else if(command == "remove") { - checkEof(command); - _currentEmp->remove(); + checkEof(command); + _currentEmp->remove(); } else if(command == "show") { - checkEof(command); - EmpDesc desc = _currentEmp->getDesc(); - cout << "empno: " << desc.empno << endl; - cout << "ename: " << quote(desc.ename) << endl; - cout << "job: " << quote(desc.job) << endl; - cout << "mgr: "; - if(desc.mgr == 0) - { - cout << "<null>" << endl; - } - else - { - cout << desc.mgr->getDesc().empno << endl; - } - cout << "hiredate: " << quote(desc.hiredate) << endl; - cout << "sal: " << quote(desc.sal) << endl; - cout << "comm: " << quote(desc.comm) << endl; - cout << "dept: "; - if(desc.edept == 0) - { - cout << "<null>" << endl; - } - else - { - cout << desc.edept->getDesc().deptno << endl; - } + checkEof(command); + EmpDesc desc = _currentEmp->getDesc(); + cout << "empno: " << desc.empno << endl; + cout << "ename: " << quote(desc.ename) << endl; + cout << "job: " << quote(desc.job) << endl; + cout << "mgr: "; + if(desc.mgr == 0) + { + cout << "<null>" << endl; + } + else + { + cout << desc.mgr->getDesc().empno << endl; + } + cout << "hiredate: " << quote(desc.hiredate) << endl; + cout << "sal: " << quote(desc.sal) << endl; + cout << "comm: " << quote(desc.comm) << endl; + cout << "dept: "; + if(desc.edept == 0) + { + cout << "<null>" << endl; + } + else + { + cout << desc.edept->getDesc().deptno << endl; + } } else if(command == "update") { - string field; - cin >> field; - if(field == "mgr") - { - int mgr; - cin >> mgr; - if(checkCin("update mgr")) - { - _currentEmp->updateMgr(mgr); - } - } - else if(field == "dept") - { - int deptno; - cin >> deptno; - if(checkCin("update dept")) - { - _currentEmp->updateDept(deptno); - } - } - else - { - string newValue; - cin >> newValue; - newValue = unquote(newValue); - if(checkCin("update " + field)) - { - _currentEmp->updateField(field, newValue); - } - } + string field; + cin >> field; + if(field == "mgr") + { + int mgr; + cin >> mgr; + if(checkCin("update mgr")) + { + _currentEmp->updateMgr(mgr); + } + } + else if(field == "dept") + { + int deptno; + cin >> deptno; + if(checkCin("update dept")) + { + _currentEmp->updateDept(deptno); + } + } + else + { + string newValue; + cin >> newValue; + newValue = unquote(newValue); + if(checkCin("update " + field)) + { + _currentEmp->updateField(field, newValue); + } + } } else { - invalidCommand(command); + invalidCommand(command); } } @@ -494,15 +494,15 @@ HRClient::printDepts(const DeptPrxSeq& depts) const cout << "Deptno\t Dname\t Loc" << endl; if(depts.size() == 0) { - cout << "<None found>" << endl; + cout << "<None found>" << endl; } else { - for(DeptPrxSeq::const_iterator p = depts.begin(); p != depts.end(); ++p) - { - HR::DeptDesc desc = (*p)->getDesc(); - cout << desc.deptno << "\t " << desc.dname << "\t " << desc.loc << endl; - } + for(DeptPrxSeq::const_iterator p = depts.begin(); p != depts.end(); ++p) + { + HR::DeptDesc desc = (*p)->getDesc(); + cout << desc.deptno << "\t " << desc.dname << "\t " << desc.loc << endl; + } } } @@ -512,15 +512,15 @@ HRClient::printEmps(const EmpPrxSeq& emps) const cout << "Empno\t Ename" << endl; if(emps.size() == 0) { - cout << "<None found>" << endl; + cout << "<None found>" << endl; } else { - for(EmpPrxSeq::const_iterator p = emps.begin(); p != emps.end(); ++p) - { - HR::EmpDesc desc = (*p)->getDesc(); - cout << desc.empno << "\t " << desc.ename << endl; - } + for(EmpPrxSeq::const_iterator p = emps.begin(); p != emps.end(); ++p) + { + HR::EmpDesc desc = (*p)->getDesc(); + cout << desc.empno << "\t " << desc.ename << endl; + } } } @@ -530,11 +530,11 @@ HRClient::quote(const string& str) { if(str == "") { - return "''"; + return "''"; } else { - return str; + return str; } } @@ -544,10 +544,10 @@ HRClient::unquote(const string& str) { if(str == "''") { - return ""; + return ""; } else { - return str; + return str; } } diff --git a/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp b/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp index 03a9d7538b7..336d4dc6a1b 100644 --- a/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp +++ b/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp @@ -23,7 +23,7 @@ using namespace std; using namespace oracle::occi; DeptFactoryI::DeptFactoryI(Environment* env, StatelessConnectionPool* pool, - const string& category) : + const string& category) : _env(env), _pool(pool), _category(category) @@ -58,18 +58,18 @@ DeptFactoryI::findAll(const Ice::Current& current) ConnectionHolderPtr conh = new ConnectionHolder(_pool); { - StatementHolder stmth(conh); + StatementHolder stmth(conh); - auto_ptr<ResultSet> rs(stmth.statement()->executeQuery("SELECT REF(d) FROM DEPT_VIEW d")); - - while(rs->next() != ResultSet::END_OF_FETCH) - { - Ice::Identity deptId; - deptId.category = _category; - deptId.name = encodeRef(rs->getRef(1), _env); - - result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); - } + auto_ptr<ResultSet> rs(stmth.statement()->executeQuery("SELECT REF(d) FROM DEPT_VIEW d")); + + while(rs->next() != ResultSet::END_OF_FETCH) + { + Ice::Identity deptId; + deptId.category = _category; + deptId.name = encodeRef(rs->getRef(1), _env); + + result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); + } } conh->commit(); return result; @@ -82,20 +82,20 @@ DeptFactoryI::findByName(const string& name, const Ice::Current& current) HR::DeptPrxSeq result; ConnectionHolderPtr conh = new ConnectionHolder(_pool); { - StatementHolder stmth(conh); - stmth.statement()->setSQL("SELECT REF(d) FROM DEPT_VIEW d WHERE DNAME = :1"); - stmth.statement()->setString(1, name); - - auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); - - while(rs->next() != ResultSet::END_OF_FETCH) - { - Ice::Identity deptId; - deptId.category = _category; - deptId.name = encodeRef(rs->getRef(1), _env); - - result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); - } + StatementHolder stmth(conh); + stmth.statement()->setSQL("SELECT REF(d) FROM DEPT_VIEW d WHERE DNAME = :1"); + stmth.statement()->setString(1, name); + + auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); + + while(rs->next() != ResultSet::END_OF_FETCH) + { + Ice::Identity deptId; + deptId.category = _category; + deptId.name = encodeRef(rs->getRef(1), _env); + + result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); + } } conh->commit(); return result; @@ -111,10 +111,10 @@ DeptFactoryI::findDeptByNo(int deptno, const Ice::Current& current) if(!ref.isNull()) { - Ice::Identity deptId; - deptId.category = _category; - deptId.name = encodeRef(ref, _env); - result = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); + Ice::Identity deptId; + deptId.category = _category; + deptId.name = encodeRef(ref, _env); + result = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); } conh->commit(); return result; @@ -129,10 +129,10 @@ DeptFactoryI::findEmpByNo(int empno, const Ice::Current& current) if(!ref.isNull()) { - Ice::Identity empId; - empId.category = _category; - empId.name = encodeRef(ref, _env); - result = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId)); + Ice::Identity empId; + empId.category = _category; + empId.name = encodeRef(ref, _env); + result = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId)); } conh->commit(); return result; @@ -148,7 +148,7 @@ DeptFactoryI::findDeptRefByNo(int deptno, Connection* con) const if(rs->next() == ResultSet::END_OF_FETCH) { - return Ref<DEPT_T>(); + return Ref<DEPT_T>(); } return rs->getRef(1); } @@ -163,7 +163,7 @@ DeptFactoryI::findEmpRefByNo(int empno, Connection* con) const if(rs->next() == ResultSet::END_OF_FETCH) { - return Ref<EMP_T>(); + return Ref<EMP_T>(); } return rs->getRef(1); } diff --git a/cpp/demo/Database/Oracle/occi/DeptFactoryI.h b/cpp/demo/Database/Oracle/occi/DeptFactoryI.h index 13cf0402fc6..96ff67d28cc 100644 --- a/cpp/demo/Database/Oracle/occi/DeptFactoryI.h +++ b/cpp/demo/Database/Oracle/occi/DeptFactoryI.h @@ -19,7 +19,7 @@ class DeptFactoryI : public HR::DeptFactory public: DeptFactoryI(oracle::occi::Environment* env, oracle::occi::StatelessConnectionPool*, - const std::string&); + const std::string&); virtual HR::DeptPrx createDept(int, const HR::DeptDesc&, const Ice::Current&); @@ -34,17 +34,17 @@ public: oracle::occi::Environment* getEnv() const { - return _env; + return _env; } oracle::occi::StatelessConnectionPool* getConnectionPool() const { - return _pool; + return _pool; } const std::string& getCategory() const { - return _category; + return _category; } private: diff --git a/cpp/demo/Database/Oracle/occi/DeptI.cpp b/cpp/demo/Database/Oracle/occi/DeptI.cpp index 0703cfb9fac..d74f7ccf7cc 100644 --- a/cpp/demo/Database/Oracle/occi/DeptI.cpp +++ b/cpp/demo/Database/Oracle/occi/DeptI.cpp @@ -34,36 +34,36 @@ DeptI::createEmp(int empno, const HR::EmpDesc& desc, const Ice::Current& current // Inserted into the OCCI cache // EMP_T* emp = new(_conh->connection(), "EMP_VIEW")EMP_T; - + emp->setEmpno(empno); emp->setEname(desc.ename); emp->setJob(desc.job); if(desc.mgr != 0) { - Ref<EMP_T> mgrRef = decodeRef(desc.mgr->ice_getIdentity().name, env, _conh->connection()); - - emp->setMgrref(mgrRef); + Ref<EMP_T> mgrRef = decodeRef(desc.mgr->ice_getIdentity().name, env, _conh->connection()); + + emp->setMgrref(mgrRef); } if(desc.hiredate != "") { - Date hiredate(env); - hiredate.fromText(desc.hiredate); - emp->setHiredate(hiredate); + Date hiredate(env); + hiredate.fromText(desc.hiredate); + emp->setHiredate(hiredate); } if(desc.sal != "") { - Number sal(0); - sal.fromText(env, desc.sal, "99999.99"); - emp->setSal(sal); + Number sal(0); + sal.fromText(env, desc.sal, "99999.99"); + emp->setSal(sal); } if(desc.comm != "") { - Number comm(0); - comm.fromText(env, desc.comm, "0.999"); - emp->setComm(comm); + Number comm(0); + comm.fromText(env, desc.comm, "0.999"); + emp->setComm(comm); } emp->setDeptref(_ref); @@ -93,18 +93,18 @@ void DeptI::updateField(const string& field, const string& newValue, const Ice::Current& current) { Ref<DEPT_T> deptRef = decodeRef(current.id.name, _factory->getEnv(), _conh->connection()); - + if(field == "dname") { - deptRef->setDname(newValue); + deptRef->setDname(newValue); } else if(field == "loc") { - deptRef->setLoc(newValue); + deptRef->setLoc(newValue); } else { - throw HR::SqlException("There is no field " + field + " in object DEPT_T"); + throw HR::SqlException("There is no field " + field + " in object DEPT_T"); } deptRef->markModified(); _conh->commit(); @@ -123,21 +123,21 @@ DeptI::findAll(const Ice::Current& current) { HR::EmpPrxSeq result; { - Ref<DEPT_T> deptRef = decodeRef(current.id.name, _factory->getEnv(), _conh->connection()); + Ref<DEPT_T> deptRef = decodeRef(current.id.name, _factory->getEnv(), _conh->connection()); - StatementHolder stmth(_conh); - stmth.statement()->setSQL("SELECT REF(e) FROM EMP_VIEW e WHERE DEPTREF = :1"); - stmth.statement()->setRef(1, deptRef); - auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); - - while(rs->next() != ResultSet::END_OF_FETCH) - { - Ice::Identity empId; - empId.category = _factory->getCategory(); - empId.name = encodeRef(rs->getRef(1), _factory->getEnv()); - - result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); - } + StatementHolder stmth(_conh); + stmth.statement()->setSQL("SELECT REF(e) FROM EMP_VIEW e WHERE DEPTREF = :1"); + stmth.statement()->setRef(1, deptRef); + auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); + + while(rs->next() != ResultSet::END_OF_FETCH) + { + Ice::Identity empId; + empId.category = _factory->getCategory(); + empId.name = encodeRef(rs->getRef(1), _factory->getEnv()); + + result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); + } } _conh->commit(); return result; @@ -148,22 +148,22 @@ DeptI::findByName(const string& name, const Ice::Current& current) { HR::EmpPrxSeq result; { - Ref<DEPT_T> deptRef = decodeRef(current.id.name, _factory->getEnv(), _conh->connection()); + Ref<DEPT_T> deptRef = decodeRef(current.id.name, _factory->getEnv(), _conh->connection()); - StatementHolder stmth(_conh); - stmth.statement()->setSQL("SELECT REF(e) FROM EMP_VIEW e WHERE DEPTREF = :1 AND ENAME = :2"); - stmth.statement()->setRef(1, deptRef); - stmth.statement()->setString(2, name); - auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); - - while(rs->next() != ResultSet::END_OF_FETCH) - { - Ice::Identity empId; - empId.category = _factory->getCategory(); - empId.name = encodeRef(rs->getRef(1), _factory->getEnv()); - - result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); - } + StatementHolder stmth(_conh); + stmth.statement()->setSQL("SELECT REF(e) FROM EMP_VIEW e WHERE DEPTREF = :1 AND ENAME = :2"); + stmth.statement()->setRef(1, deptRef); + stmth.statement()->setString(2, name); + auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); + + while(rs->next() != ResultSet::END_OF_FETCH) + { + Ice::Identity empId; + empId.category = _factory->getCategory(); + empId.name = encodeRef(rs->getRef(1), _factory->getEnv()); + + result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); + } } _conh->commit(); return result; diff --git a/cpp/demo/Database/Oracle/occi/EmpI.cpp b/cpp/demo/Database/Oracle/occi/EmpI.cpp index d591542cafe..7ae0bd39461 100644 --- a/cpp/demo/Database/Oracle/occi/EmpI.cpp +++ b/cpp/demo/Database/Oracle/occi/EmpI.cpp @@ -32,31 +32,31 @@ EmpI::getDesc(const Ice::Current& current) Ref<EMP_T> mgrRef = empRef->getMgrref(); if(!mgrRef.isNull()) { - Ice::Identity mgrId; - mgrId.name = encodeRef(mgrRef, env); - mgrId.category = _factory->getCategory(); - result.mgr = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(mgrId)); + Ice::Identity mgrId; + mgrId.name = encodeRef(mgrRef, env); + mgrId.category = _factory->getCategory(); + result.mgr = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(mgrId)); } result.hiredate = empRef->getHiredate().toText(); if(!empRef->getSal().isNull()) { - result.sal = empRef->getSal().toText(env, "99999.99"); + result.sal = empRef->getSal().toText(env, "99999.99"); } if(!empRef->getComm().isNull()) { - result.comm = empRef->getComm().toText(env, "0.999"); + result.comm = empRef->getComm().toText(env, "0.999"); } Ref<DEPT_T> deptRef = empRef->getDeptref(); if(!deptRef.isNull()) { - Ice::Identity deptId; - deptId.name = encodeRef(deptRef, env); - deptId.category = _factory->getCategory(); - result.edept = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); + Ice::Identity deptId; + deptId.name = encodeRef(deptRef, env); + deptId.category = _factory->getCategory(); + result.edept = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); } _conh->commit(); return result; @@ -69,55 +69,55 @@ EmpI::updateField(const string& field, const string& newValue, const Ice::Curren if(field == "ename") { - empRef->setEname(newValue); + empRef->setEname(newValue); } else if(field == "job") { - empRef->setJob(newValue); + empRef->setJob(newValue); } else if(field == "hiredate") { - if(newValue == "") - { - empRef->setHiredate(Date()); - } - else - { - Date hiredate(_factory->getEnv()); - hiredate.fromText(newValue); - empRef->setHiredate(hiredate); - } + if(newValue == "") + { + empRef->setHiredate(Date()); + } + else + { + Date hiredate(_factory->getEnv()); + hiredate.fromText(newValue); + empRef->setHiredate(hiredate); + } } else if(field == "sal") { - if(newValue == "") - { - empRef->setSal(Number()); - } - else - { - Number sal(0); - sal.fromText(_factory->getEnv(), newValue, "99999.99"); - empRef->setSal(sal); - } + if(newValue == "") + { + empRef->setSal(Number()); + } + else + { + Number sal(0); + sal.fromText(_factory->getEnv(), newValue, "99999.99"); + empRef->setSal(sal); + } } else if(field == "comm") { - if(newValue == "") - { - empRef->setComm(Number()); - } - else - { - Number comm(0); - comm.fromText(_factory->getEnv(), newValue, "0.999"); - empRef->setComm(comm); - } + if(newValue == "") + { + empRef->setComm(Number()); + } + else + { + Number comm(0); + comm.fromText(_factory->getEnv(), newValue, "0.999"); + empRef->setComm(comm); + } } else { - throw HR::SqlException("There is no field " + field + " in type EMP_T"); - } + throw HR::SqlException("There is no field " + field + " in type EMP_T"); + } empRef->markModified(); _conh->commit(); } @@ -129,17 +129,17 @@ EmpI::updateMgr(int newMgr, const Ice::Current& current) if(newMgr == 0) { - empRef->setMgrref(Ref<EMP_T>()); + empRef->setMgrref(Ref<EMP_T>()); } else { - Ref<EMP_T> mgrRef = _factory->findEmpRefByNo(newMgr, _conh->connection()); - - if(mgrRef.isNull()) - { - throw HR::SqlException("There is no employee with this empno"); - } - empRef->setMgrref(mgrRef); + Ref<EMP_T> mgrRef = _factory->findEmpRefByNo(newMgr, _conh->connection()); + + if(mgrRef.isNull()) + { + throw HR::SqlException("There is no employee with this empno"); + } + empRef->setMgrref(mgrRef); } empRef->markModified(); _conh->commit(); @@ -152,17 +152,17 @@ EmpI::updateDept(int newDept, const Ice::Current& current) if(newDept == 0) { - empRef->setDeptref(Ref<DEPT_T>()); + empRef->setDeptref(Ref<DEPT_T>()); } else { - Ref<DEPT_T> deptRef = _factory->findDeptRefByNo(newDept, _conh->connection()); - - if(deptRef.isNull()) - { - throw HR::SqlException("There is no department with this deptno"); - } - empRef->setDeptref(deptRef); + Ref<DEPT_T> deptRef = _factory->findDeptRefByNo(newDept, _conh->connection()); + + if(deptRef.isNull()) + { + throw HR::SqlException("There is no department with this deptno"); + } + empRef->setDeptref(deptRef); } empRef->markModified(); _conh->commit(); diff --git a/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp b/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp index 4236c9dc542..6d8b0ba8449 100755 --- a/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp +++ b/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp @@ -30,37 +30,37 @@ OCCIServantLocator::locate(const Ice::Current& current, Ice::LocalObjectPtr& coo try
{
- //
- // Extract SQL type from target object
- //
- string sqlType = Ref<PObject>(ref)->getSQLTypeName();
+ //
+ // Extract SQL type from target object
+ //
+ string sqlType = Ref<PObject>(ref)->getSQLTypeName();
- //
- // Create and return the servant, used only for this one operation
- //
- if(sqlType.find("EMP_T") != string::npos)
- {
- return new EmpI(ref, con, _factory);
- }
- else if(sqlType.find("DEPT_T") != string::npos)
- {
- return new DeptI(ref, con, _factory);
- }
- else
- {
- return 0;
- }
+ //
+ // Create and return the servant, used only for this one operation
+ //
+ if(sqlType.find("EMP_T") != string::npos)
+ {
+ return new EmpI(ref, con, _factory);
+ }
+ else if(sqlType.find("DEPT_T") != string::npos)
+ {
+ return new DeptI(ref, con, _factory);
+ }
+ else
+ {
+ return 0;
+ }
}
catch(const SQLException& sqle)
{
- if(sqle.getErrorCode() == 21700)
- {
- return 0;
- }
- else
- {
- throw;
- }
+ if(sqle.getErrorCode() == 21700)
+ {
+ return 0;
+ }
+ else
+ {
+ throw;
+ }
}
}
diff --git a/cpp/demo/Database/Oracle/occi/Server.cpp b/cpp/demo/Database/Oracle/occi/Server.cpp index aff2f171ea3..8df9dceb43f 100644 --- a/cpp/demo/Database/Oracle/occi/Server.cpp +++ b/cpp/demo/Database/Oracle/occi/Server.cpp @@ -47,42 +47,42 @@ HRServer::run(int argc, char* argv[]) try { - env = Environment::createEnvironment(Environment::Mode(Environment::THREADED_MUTEXED | Environment::OBJECT)); - DbTypesMap(env); - - pool = env->createStatelessConnectionPool(username, password, connectString, 5, 2, 1, - StatelessConnectionPool::HOMOGENEOUS); + env = Environment::createEnvironment(Environment::Mode(Environment::THREADED_MUTEXED | Environment::OBJECT)); + DbTypesMap(env); + + pool = env->createStatelessConnectionPool(username, password, connectString, 5, 2, 1, + StatelessConnectionPool::HOMOGENEOUS); - Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("HR"); - - DeptFactoryIPtr factory = new DeptFactoryI(env, pool, category); - adapter->addServantLocator(new OCCIServantLocator(factory), category); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("HR"); + + DeptFactoryIPtr factory = new DeptFactoryI(env, pool, category); + adapter->addServantLocator(new OCCIServantLocator(factory), category); - adapter->add(factory, communicator()->stringToIdentity("DeptFactory")); - - adapter->activate(); - communicator()->waitForShutdown(); + adapter->add(factory, communicator()->stringToIdentity("DeptFactory")); + + adapter->activate(); + communicator()->waitForShutdown(); } catch(...) { - if(pool != 0) - { - env->terminateStatelessConnectionPool(pool); - } - if(env != 0) - { - Environment::terminateEnvironment(env); - } - throw; + if(pool != 0) + { + env->terminateStatelessConnectionPool(pool); + } + if(env != 0) + { + Environment::terminateEnvironment(env); + } + throw; } if(pool != 0) { - env->terminateStatelessConnectionPool(pool); + env->terminateStatelessConnectionPool(pool); } if(env != 0) { - Environment::terminateEnvironment(env); + Environment::terminateEnvironment(env); } return EXIT_SUCCESS; } diff --git a/cpp/demo/Database/Oracle/occi/Util.cpp b/cpp/demo/Database/Oracle/occi/Util.cpp index 44c6dda8912..7b6a109e494 100644 --- a/cpp/demo/Database/Oracle/occi/Util.cpp +++ b/cpp/demo/Database/Oracle/occi/Util.cpp @@ -28,11 +28,11 @@ ConnectionHolder::commit() _txDone = true; try { - _con->commit(); + _con->commit(); } catch(const SQLException& e) { - throw HR::SqlException(e.what()); + throw HR::SqlException(e.what()); } } @@ -42,11 +42,11 @@ ConnectionHolder::rollback() _txDone = true; try { - _con->rollback(); + _con->rollback(); } catch(const SQLException& e) { - throw HR::SqlException(e.what()); + throw HR::SqlException(e.what()); } } @@ -54,19 +54,19 @@ ConnectionHolder::~ConnectionHolder() { if(!_txDone) { - _txDone = true; - try - { - _con->rollback(); - } - catch(const std::exception&) - { - } + _txDone = true; + try + { + _con->rollback(); + } + catch(const std::exception&) + { + } } try { - _pool->releaseConnection(_con); + _pool->releaseConnection(_con); } catch(const std::exception&) { @@ -104,15 +104,15 @@ encodeRef(const RefAny& ref, Environment* env) if(status == OCI_SUCCESS) { - result.assign(reinterpret_cast<char*>(buffer), length); + result.assign(reinterpret_cast<char*>(buffer), length); } else { - cerr << "encodeRef failed: "; - sb4 errcode = 0; - OraText buf[512]; - OCIErrorGet(error, 1, 0, &errcode, buf, 512, OCI_HTYPE_ERROR); - cerr << reinterpret_cast<char*>(buf) << endl; + cerr << "encodeRef failed: "; + sb4 errcode = 0; + OraText buf[512]; + OCIErrorGet(error, 1, 0, &errcode, buf, 512, OCI_HTYPE_ERROR); + cerr << reinterpret_cast<char*>(buf) << endl; } OCIHandleFree(error, OCI_HTYPE_ERROR); @@ -128,26 +128,26 @@ decodeRef(const string& str, Environment* env, Connection* con) OCIHandleAlloc(env->getOCIEnvironment(), reinterpret_cast<void**>(&error), OCI_HTYPE_ERROR, 0, 0); sword status = OCIRefFromHex(env->getOCIEnvironment(), error, - con->getOCIServiceContext(), - reinterpret_cast<const OraText*>(str.c_str()), str.length(), - &ref); + con->getOCIServiceContext(), + reinterpret_cast<const OraText*>(str.c_str()), str.length(), + &ref); if(status == OCI_SUCCESS) - { - OCIHandleFree(error, OCI_HTYPE_ERROR); - return RefAny(con, ref); + { + OCIHandleFree(error, OCI_HTYPE_ERROR); + return RefAny(con, ref); } else { - cerr << "decodeRef failed: "; - sb4 errcode = 0; - OraText buf[512]; - OCIErrorGet(error, 1, 0, &errcode, buf, 512, OCI_HTYPE_ERROR); - cerr << reinterpret_cast<char*>(buf) << endl; - - OCIHandleFree(error, OCI_HTYPE_ERROR); - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + cerr << "decodeRef failed: "; + sb4 errcode = 0; + OraText buf[512]; + OCIErrorGet(error, 1, 0, &errcode, buf, 512, OCI_HTYPE_ERROR); + cerr << reinterpret_cast<char*>(buf) << endl; + + OCIHandleFree(error, OCI_HTYPE_ERROR); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } } diff --git a/cpp/demo/Database/Oracle/occi/Util.h b/cpp/demo/Database/Oracle/occi/Util.h index dbe44d6b9c3..2655b2281ec 100644 --- a/cpp/demo/Database/Oracle/occi/Util.h +++ b/cpp/demo/Database/Oracle/occi/Util.h @@ -25,7 +25,7 @@ public: oracle::occi::Connection* connection() const { - return _con; + return _con; } void commit(); @@ -55,7 +55,7 @@ public: oracle::occi::Statement* statement() const { - return _stmt; + return _stmt; } private: diff --git a/cpp/demo/Database/Oracle/proc/Client.cpp b/cpp/demo/Database/Oracle/proc/Client.cpp index 2260decdd0b..569fdf620fc 100644 --- a/cpp/demo/Database/Oracle/proc/Client.cpp +++ b/cpp/demo/Database/Oracle/proc/Client.cpp @@ -63,32 +63,32 @@ HRClient::HRClient() : _currentMenu(rootMenu) { _commonCommands = - "dept <number>: set department <number> as the current department\n" - "emp <number>: set employee <number> as the current employee\n" - "exit or quit: exit client\n" - "help: print this list of commands\n" - "root: go back to the root menu\n"; + "dept <number>: set department <number> as the current department\n" + "emp <number>: set employee <number> as the current employee\n" + "exit or quit: exit client\n" + "help: print this list of commands\n" + "root: go back to the root menu\n"; _rootCommands = - "create: create a new department\n" - "find <name>: find the department(s) with the given name\n" - "list: list all departments\n"; + "create: create a new department\n" + "find <name>: find the department(s) with the given name\n" + "list: list all departments\n"; - + _deptCommands = - "create: create a new employee in this department\n" - "find <name>: find employee(s) named <name> in this department\n" - "list: list all employees in this department\n" - "ping: ping this department\n" - "remove: remove this department\n" - "show: describe this department\n" - "update <dname|loc> <new value>: update this department\n"; + "create: create a new employee in this department\n" + "find <name>: find employee(s) named <name> in this department\n" + "list: list all employees in this department\n" + "ping: ping this department\n" + "remove: remove this department\n" + "show: describe this department\n" + "update <dname|loc> <new value>: update this department\n"; _empCommands = - "ping: ping this employee\n" - "remove: remove this employee\n" - "show: describe this employee\n" - "update <ename|job|mgr|hiredate|sal|comm|dept> <new-value>: update this employee\n"; + "ping: ping this employee\n" + "remove: remove this employee\n" + "show: describe this employee\n" + "update <ename|job|mgr|hiredate|sal|comm|dept> <new-value>: update this employee\n"; } void @@ -96,13 +96,13 @@ HRClient::checkEof(const string& command) const { if(!cin.eof()) { - string extra; - getline(cin, extra); - if(extra.size() > 0) - { - cout << "Warning: ignoring extra args '" << extra - << "' for '" << command << "'" << endl; - } + string extra; + getline(cin, extra); + if(extra.size() > 0) + { + cout << "Warning: ignoring extra args '" << extra + << "' for '" << command << "'" << endl; + } } } @@ -111,10 +111,10 @@ HRClient::checkCin(const string& command) const { if(!cin) { - cout << "Error: failed to read arguments for '" << command << "'" << endl; - cin.clear(); - cin.ignore(numeric_limits<streamsize>::max(), '\n'); - return false; + cout << "Error: failed to read arguments for '" << command << "'" << endl; + cin.clear(); + cin.ignore(numeric_limits<streamsize>::max(), '\n'); + return false; } checkEof(command); return true; @@ -124,7 +124,7 @@ void HRClient::invalidCommand(const string& command) const { cout << "Invalid command '" << command << "'. " - "Type 'help' for help." << endl; + "Type 'help' for help." << endl; cin.ignore(numeric_limits<streamsize>::max(), '\n'); } @@ -136,21 +136,21 @@ HRClient::help() const switch(_currentMenu) { - case rootMenu: - { - cout << _rootCommands; - break; - } - case deptMenu: - { - cout << _deptCommands; - break; - } - case empMenu: - { - cout << _empCommands; - break; - } + case rootMenu: + { + cout << _rootCommands; + break; + } + case deptMenu: + { + cout << _deptCommands; + break; + } + case empMenu: + { + cout << _empCommands; + break; + } } cout << "--- Common to all menus ---\n"; cout << _commonCommands << endl; @@ -163,8 +163,8 @@ HRClient::run(int argc, char* argv[]) _factory = DeptFactoryPrx::checkedCast(base); if(_factory == 0) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } Ice::EndpointSeq endpoints = _factory->ice_getEndpoints(); @@ -178,102 +178,102 @@ HRClient::run(int argc, char* argv[]) do { - cout << "==> "; - cin >> command; - - if(!cin) - { - break; - } - - try - { - - // - // Common commands - // - if(command == "dept") - { - int deptno; - cin >> deptno; - if(checkCin(command)) - { - _currentDept = DeptPrx::uncheckedCast(_factory->findDeptByNo(deptno)); - if(_currentDept != 0) - { - _currentMenu = deptMenu; - } - else - { - cout << "There is no department with deptno " << deptno << endl; - } - } - } - else if(command == "emp") - { - int empno; - cin >> empno; - if(checkCin(command)) - { - _currentEmp = EmpPrx::uncheckedCast(_factory->findEmpByNo(empno)); - if(_currentEmp != 0) - { - _currentMenu = empMenu; - } - else - { - cout << "There is no employee with empno " << empno << endl; - } - } - } - else if(command == "exit" || command == "quit") - { - checkEof(command); - break; - } - else if(command == "help") - { - checkEof(command); - help(); - } - else if(command == "root") - { - checkEof(command); - _currentMenu = rootMenu; - } - else if(_currentMenu == rootMenu) - { - doRootMenu(command); - } - else if(_currentMenu == deptMenu) - { - doDeptMenu(command); - } - else if(_currentMenu == empMenu) - { - doEmpMenu(command); - } - else - { - assert(0); - } - } - catch(const SqlException& e) - { - cout << "Caught a SqlException: " << e.reason << endl; - } - catch(const IceUtil::Exception& e) - { - cout << "Caught an Ice exception: " << e << endl; - } - catch(const std::exception& e) - { - cout << "Caught a std::exception: " << e.what() << endl; - } - catch(...) - { - cout << "Caught an unknown exception" << endl; - } + cout << "==> "; + cin >> command; + + if(!cin) + { + break; + } + + try + { + + // + // Common commands + // + if(command == "dept") + { + int deptno; + cin >> deptno; + if(checkCin(command)) + { + _currentDept = DeptPrx::uncheckedCast(_factory->findDeptByNo(deptno)); + if(_currentDept != 0) + { + _currentMenu = deptMenu; + } + else + { + cout << "There is no department with deptno " << deptno << endl; + } + } + } + else if(command == "emp") + { + int empno; + cin >> empno; + if(checkCin(command)) + { + _currentEmp = EmpPrx::uncheckedCast(_factory->findEmpByNo(empno)); + if(_currentEmp != 0) + { + _currentMenu = empMenu; + } + else + { + cout << "There is no employee with empno " << empno << endl; + } + } + } + else if(command == "exit" || command == "quit") + { + checkEof(command); + break; + } + else if(command == "help") + { + checkEof(command); + help(); + } + else if(command == "root") + { + checkEof(command); + _currentMenu = rootMenu; + } + else if(_currentMenu == rootMenu) + { + doRootMenu(command); + } + else if(_currentMenu == deptMenu) + { + doDeptMenu(command); + } + else if(_currentMenu == empMenu) + { + doEmpMenu(command); + } + else + { + assert(0); + } + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } } while(cin.good()); @@ -285,38 +285,38 @@ HRClient::doRootMenu(const string& command) const { if(command == "create") { - checkEof(command); - cout << "Please enter: deptno dname loc ==> "; - int deptno; - DeptDesc desc; - cin >> deptno >> desc.dname >> desc.loc; - - desc.dname = unquote(desc.dname); - desc.loc = unquote(desc.loc); - - if(checkCin("create parameters")) - { - _factory->createDept(deptno, desc); - cout << "Created new department number " << deptno << endl; - } + checkEof(command); + cout << "Please enter: deptno dname loc ==> "; + int deptno; + DeptDesc desc; + cin >> deptno >> desc.dname >> desc.loc; + + desc.dname = unquote(desc.dname); + desc.loc = unquote(desc.loc); + + if(checkCin("create parameters")) + { + _factory->createDept(deptno, desc); + cout << "Created new department number " << deptno << endl; + } } else if(command == "find") { - string name; - cin >> name; - if(checkCin(command)) - { - printDepts(_factory->findByName(name)); - } + string name; + cin >> name; + if(checkCin(command)) + { + printDepts(_factory->findByName(name)); + } } else if(command == "list") { - checkEof(command); - printDepts(_factory->findAll()); + checkEof(command); + printDepts(_factory->findAll()); } else { - invalidCommand(command); + invalidCommand(command); } } @@ -325,84 +325,84 @@ HRClient::doDeptMenu(const string& command) const { if(command == "create") { - checkEof(command); - cout << "Please enter: empno ename job mgr(empno) hiredate sal comm ==> "; - int empno; - int mgrEmpno; - EmpDesc desc; - cin >> empno >> desc.ename >> desc.job >> mgrEmpno >> desc.hiredate >> desc.sal >> desc.comm; - - desc.ename = unquote(desc.ename); - desc.job = unquote(desc.job); - - if(mgrEmpno != 0) - { - desc.mgr = _factory->findEmpByNo(mgrEmpno); - if(desc.mgr == 0) - { - cout << "Manager #" << mgrEmpno << " does not exist: clearing manager" << endl; - } - } - desc.hiredate = unquote(desc.hiredate); - desc.sal = unquote(desc.sal); - desc.comm = unquote(desc.comm); - - desc.edept = _currentDept; - - if(checkCin("create parameters")) - { - _currentDept->createEmp(empno, desc); - cout << "Created new employee number " << empno << endl; - } + checkEof(command); + cout << "Please enter: empno ename job mgr(empno) hiredate sal comm ==> "; + int empno; + int mgrEmpno; + EmpDesc desc; + cin >> empno >> desc.ename >> desc.job >> mgrEmpno >> desc.hiredate >> desc.sal >> desc.comm; + + desc.ename = unquote(desc.ename); + desc.job = unquote(desc.job); + + if(mgrEmpno != 0) + { + desc.mgr = _factory->findEmpByNo(mgrEmpno); + if(desc.mgr == 0) + { + cout << "Manager #" << mgrEmpno << " does not exist: clearing manager" << endl; + } + } + desc.hiredate = unquote(desc.hiredate); + desc.sal = unquote(desc.sal); + desc.comm = unquote(desc.comm); + + desc.edept = _currentDept; + + if(checkCin("create parameters")) + { + _currentDept->createEmp(empno, desc); + cout << "Created new employee number " << empno << endl; + } } else if(command == "find") { - string name; - cin >> name; - if(checkCin(command)) - { - printEmps(_currentDept->findByName(name)); - } + string name; + cin >> name; + if(checkCin(command)) + { + printEmps(_currentDept->findByName(name)); + } } else if(command == "list") { - checkEof(command); - printEmps(_currentDept->findAll()); + checkEof(command); + printEmps(_currentDept->findAll()); } else if(command == "ping") { - checkEof(command); - _currentDept->ice_ping(); - cout << "ice_ping: success!" << endl; + checkEof(command); + _currentDept->ice_ping(); + cout << "ice_ping: success!" << endl; } else if(command == "remove") { - checkEof(command); - _currentDept->remove(); + checkEof(command); + _currentDept->remove(); } else if(command == "show") { - checkEof(command); - DeptDesc desc = _currentDept->getDesc(); - cout << "deptno: " << desc.deptno << endl; - cout << "dname: " << quote(desc.dname) << endl; - cout << "loc: " << quote(desc.loc) << endl; + checkEof(command); + DeptDesc desc = _currentDept->getDesc(); + cout << "deptno: " << desc.deptno << endl; + cout << "dname: " << quote(desc.dname) << endl; + cout << "loc: " << quote(desc.loc) << endl; } else if(command == "update") { - string field; - string newValue; - cin >> field >> newValue; - newValue = unquote(newValue); - - if(checkCin("update " + field)) - { - _currentDept->updateField(field, newValue); - } + string field; + string newValue; + cin >> field >> newValue; + newValue = unquote(newValue); + + if(checkCin("update " + field)) + { + _currentDept->updateField(field, newValue); + } } else { - invalidCommand(command); + invalidCommand(command); } } @@ -411,80 +411,80 @@ HRClient::doEmpMenu(const string& command) const { if(command == "ping") { - checkEof(command); - _currentEmp->ice_ping(); - cout << "ice_ping: success!" << endl; + checkEof(command); + _currentEmp->ice_ping(); + cout << "ice_ping: success!" << endl; } else if(command == "remove") { - checkEof(command); - _currentEmp->remove(); + checkEof(command); + _currentEmp->remove(); } else if(command == "show") { - checkEof(command); - EmpDesc desc = _currentEmp->getDesc(); - cout << "empno: " << desc.empno << endl; - cout << "ename: " << quote(desc.ename) << endl; - cout << "job: " << quote(desc.job) << endl; - cout << "mgr: "; - if(desc.mgr == 0) - { - cout << "<null>" << endl; - } - else - { - cout << desc.mgr->getDesc().empno << endl; - } - cout << "hiredate: " << quote(desc.hiredate) << endl; - cout << "sal: " << quote(desc.sal) << endl; - cout << "comm: " << quote(desc.comm) << endl; - cout << "dept: "; - if(desc.edept == 0) - { - cout << "<null>" << endl; - } - else - { - cout << desc.edept->getDesc().deptno << endl; - } + checkEof(command); + EmpDesc desc = _currentEmp->getDesc(); + cout << "empno: " << desc.empno << endl; + cout << "ename: " << quote(desc.ename) << endl; + cout << "job: " << quote(desc.job) << endl; + cout << "mgr: "; + if(desc.mgr == 0) + { + cout << "<null>" << endl; + } + else + { + cout << desc.mgr->getDesc().empno << endl; + } + cout << "hiredate: " << quote(desc.hiredate) << endl; + cout << "sal: " << quote(desc.sal) << endl; + cout << "comm: " << quote(desc.comm) << endl; + cout << "dept: "; + if(desc.edept == 0) + { + cout << "<null>" << endl; + } + else + { + cout << desc.edept->getDesc().deptno << endl; + } } else if(command == "update") { - string field; - cin >> field; - if(field == "mgr") - { - int mgr; - cin >> mgr; - if(checkCin("update mgr")) - { - _currentEmp->updateMgr(mgr); - } - } - else if(field == "dept") - { - int deptno; - cin >> deptno; - if(checkCin("update dept")) - { - _currentEmp->updateDept(deptno); - } - } - else - { - string newValue; - cin >> newValue; - newValue = unquote(newValue); - if(checkCin("update " + field)) - { - _currentEmp->updateField(field, newValue); - } - } + string field; + cin >> field; + if(field == "mgr") + { + int mgr; + cin >> mgr; + if(checkCin("update mgr")) + { + _currentEmp->updateMgr(mgr); + } + } + else if(field == "dept") + { + int deptno; + cin >> deptno; + if(checkCin("update dept")) + { + _currentEmp->updateDept(deptno); + } + } + else + { + string newValue; + cin >> newValue; + newValue = unquote(newValue); + if(checkCin("update " + field)) + { + _currentEmp->updateField(field, newValue); + } + } } else { - invalidCommand(command); + invalidCommand(command); } } @@ -494,15 +494,15 @@ HRClient::printDepts(const DeptPrxSeq& depts) const cout << "Deptno\t Dname\t Loc" << endl; if(depts.size() == 0) { - cout << "<None found>" << endl; + cout << "<None found>" << endl; } else { - for(DeptPrxSeq::const_iterator p = depts.begin(); p != depts.end(); ++p) - { - HR::DeptDesc desc = (*p)->getDesc(); - cout << desc.deptno << "\t " << desc.dname << "\t " << desc.loc << endl; - } + for(DeptPrxSeq::const_iterator p = depts.begin(); p != depts.end(); ++p) + { + HR::DeptDesc desc = (*p)->getDesc(); + cout << desc.deptno << "\t " << desc.dname << "\t " << desc.loc << endl; + } } } @@ -512,15 +512,15 @@ HRClient::printEmps(const EmpPrxSeq& emps) const cout << "Empno\t Ename" << endl; if(emps.size() == 0) { - cout << "<None found>" << endl; + cout << "<None found>" << endl; } else { - for(EmpPrxSeq::const_iterator p = emps.begin(); p != emps.end(); ++p) - { - HR::EmpDesc desc = (*p)->getDesc(); - cout << desc.empno << "\t " << desc.ename << endl; - } + for(EmpPrxSeq::const_iterator p = emps.begin(); p != emps.end(); ++p) + { + HR::EmpDesc desc = (*p)->getDesc(); + cout << desc.empno << "\t " << desc.ename << endl; + } } } @@ -530,11 +530,11 @@ HRClient::quote(const string& str) { if(str == "") { - return "''"; + return "''"; } else { - return str; + return str; } } @@ -544,10 +544,10 @@ HRClient::unquote(const string& str) { if(str == "''") { - return ""; + return ""; } else { - return str; + return str; } } diff --git a/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc b/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc index 862196b8718..35e27fc3749 100644 --- a/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc +++ b/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc @@ -38,7 +38,7 @@ class Notification : public Ice::ThreadNotification public: Notification(size_t index) : - _index(index) + _index(index) { } @@ -48,35 +48,35 @@ public: virtual void stop() { - if(_current != 0 && _index < _current->size()) - { + if(_current != 0 && _index < _current->size()) + { #ifdef TRACE - cerr << "Disconnecting from Oracle in thread " << IceUtil::ThreadControl().id() << endl; + cerr << "Disconnecting from Oracle in thread " << IceUtil::ThreadControl().id() << endl; #endif - EXEC SQL BEGIN DECLARE SECTION; - sql_context ctx = (*_current)[_index]; - EXEC SQL END DECLARE SECTION; - - if(ctx != 0) - { - (*_current)[_index] = 0; - EXEC SQL CONTEXT USE :ctx; - - sqlca sqlca; - EXEC SQL ROLLBACK RELEASE; - EXEC SQL CONTEXT FREE :ctx; - } - - if(find_if(_current->begin(), _current->end(), bind2nd(not_equal_to<sql_context>(), static_cast<void*>(0))) - == _current->end()) - { + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = (*_current)[_index]; + EXEC SQL END DECLARE SECTION; + + if(ctx != 0) + { + (*_current)[_index] = 0; + EXEC SQL CONTEXT USE :ctx; + + sqlca sqlca; + EXEC SQL ROLLBACK RELEASE; + EXEC SQL CONTEXT FREE :ctx; + } + + if(find_if(_current->begin(), _current->end(), bind2nd(not_equal_to<sql_context>(), static_cast<void*>(0))) + == _current->end()) + { #ifdef TRACE - cerr << "Deleting _current in thread " << IceUtil::ThreadControl().id() << endl; + cerr << "Deleting _current in thread " << IceUtil::ThreadControl().id() << endl; #endif - delete _current; - _current = 0; - } - } + delete _current; + _current = 0; + } + } } private: @@ -90,8 +90,8 @@ CurrentSqlContext::CurrentSqlContext(const string& connectInfo) : _connectInfo(connectInfo) { { - IceUtil::StaticMutex::Lock lock(IceUtil::globalMutex); - _index = _currentIndex++; + IceUtil::StaticMutex::Lock lock(IceUtil::globalMutex); + _index = _currentIndex++; } _hook = new Notification(_index); } @@ -106,11 +106,11 @@ CurrentSqlContext::operator sql_context() const { if(_current == 0) { - _current = new std::vector<sql_context>(_index + 1); + _current = new std::vector<sql_context>(_index + 1); } if(_index >= _current->size()) { - _current->resize(_index + 1); + _current->resize(_index + 1); } EXEC SQL BEGIN DECLARE SECTION; @@ -123,18 +123,18 @@ CurrentSqlContext::operator sql_context() const if(ctx == 0) { #ifdef TRACE - cerr << "Connecting to Oracle in thread " << IceUtil::ThreadControl().id() << endl; + cerr << "Connecting to Oracle in thread " << IceUtil::ThreadControl().id() << endl; #endif - // - // Allocate and connect - // - sqlca sqlca; - - EXEC SQL CONTEXT ALLOCATE :ctx; - EXEC SQL CONTEXT USE :ctx; - EXEC SQL CONNECT :connectInfo; - - (*_current)[_index] = ctx; + // + // Allocate and connect + // + sqlca sqlca; + + EXEC SQL CONTEXT ALLOCATE :ctx; + EXEC SQL CONTEXT USE :ctx; + EXEC SQL CONNECT :connectInfo; + + (*_current)[_index] = ctx; } return ctx; diff --git a/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc b/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc index 1d72b58d0db..e6bcdd56145 100644 --- a/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc +++ b/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc @@ -62,13 +62,13 @@ DeptFactoryI::findAll(const Ice::Current& current) for(;;) { - EXEC SQL FETCH depCursor1 INTO :deptno; + EXEC SQL FETCH depCursor1 INTO :deptno; - Ice::Identity deptId; - deptId.category = _deptCategory; - deptId.name = encodeName(deptno); + Ice::Identity deptId; + deptId.category = _deptCategory; + deptId.name = encodeName(deptno); - result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); + result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); } EXEC SQL CLOSE depCursor1; @@ -94,13 +94,13 @@ DeptFactoryI::findByName(const string& name, const Ice::Current& current) for(;;) { - EXEC SQL FETCH depCursor2 INTO :deptno; + EXEC SQL FETCH depCursor2 INTO :deptno; - Ice::Identity deptId; - deptId.category = _deptCategory; - deptId.name = encodeName(deptno); + Ice::Identity deptId; + deptId.category = _deptCategory; + deptId.name = encodeName(deptno); - result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); + result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); } EXEC SQL CLOSE depCursor2; @@ -121,11 +121,11 @@ DeptFactoryI::findDeptByNo(int deptno, const Ice::Current& current) // try { - prx->ice_ping(); + prx->ice_ping(); } catch(const Ice::ObjectNotExistException&) { - return 0; + return 0; } return HR::DeptPrx::uncheckedCast(prx); @@ -144,11 +144,11 @@ DeptFactoryI::findEmpByNo(int empno, const Ice::Current& current) // try { - prx->ice_ping(); + prx->ice_ping(); } catch(const Ice::ObjectNotExistException&) { - return 0; + return 0; } return HR::EmpPrx::uncheckedCast(prx); diff --git a/cpp/demo/Database/Oracle/proc/DeptI.pc b/cpp/demo/Database/Oracle/proc/DeptI.pc index 7a9d2c63f1c..203ab110a5a 100644 --- a/cpp/demo/Database/Oracle/proc/DeptI.pc +++ b/cpp/demo/Database/Oracle/proc/DeptI.pc @@ -38,7 +38,7 @@ DeptI::ice_ping(const Ice::Current& current) const if(count == 0) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } } @@ -64,19 +64,19 @@ DeptI::createEmp(int key, const HR::EmpDesc& desc, const Ice::Current& current) if(desc.mgr == 0) { - // - // mgr is NULL - // - mgrInd = -1; + // + // mgr is NULL + // + mgrInd = -1; } else { - mgr = decodeName(desc.mgr->ice_getIdentity().name); + mgr = decodeName(desc.mgr->ice_getIdentity().name); } EXEC SQL CONTEXT USE :ctx; EXEC SQL INSERT INTO EMP(empno, ename, job, mgr, hiredate, sal, comm, deptno) - VALUES(:empno, :ename, :job, :mgr:mgrInd, :hiredate, :sal, :comm, :deptno); + VALUES(:empno, :ename, :job, :mgr:mgrInd, :hiredate, :sal, :comm, :deptno); EXEC SQL COMMIT; Ice::Identity empId; @@ -107,10 +107,10 @@ DeptI::getDesc(const Ice::Current& current) if(dnameInd >= 0) { - // - // Should log a warning if > 0! - // - result.dname = dname; + // + // Should log a warning if > 0! + // + result.dname = dname; } // // else null @@ -118,10 +118,10 @@ DeptI::getDesc(const Ice::Current& current) if(locInd >= 0) { - // - // Should log a warning if > 0! - // - result.loc = loc; + // + // Should log a warning if > 0! + // + result.loc = loc; } // // else null @@ -134,7 +134,7 @@ void DeptI::updateField(const string& field, const string& newValue, const Ice::Current& current) { const string updateDeptStr = - "UPDATE DEPT SET " + field + " = '" + newValue + "' WHERE DEPTNO = " + current.id.name; + "UPDATE DEPT SET " + field + " = '" + newValue + "' WHERE DEPTNO = " + current.id.name; sqlca sqlca; EXEC SQL BEGIN DECLARE SECTION; @@ -185,13 +185,13 @@ DeptI::findAll(const Ice::Current& current) for(;;) { - EXEC SQL FETCH empCursor1 INTO :empno; + EXEC SQL FETCH empCursor1 INTO :empno; - Ice::Identity empId; - empId.category = _empCategory; - empId.name = encodeName(empno); + Ice::Identity empId; + empId.category = _empCategory; + empId.name = encodeName(empno); - result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); + result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); } EXEC SQL CLOSE empCursor1; @@ -218,13 +218,13 @@ DeptI::findByName(const string& name, const Ice::Current& current) for(;;) { - EXEC SQL FETCH empCursor2 INTO :empno; + EXEC SQL FETCH empCursor2 INTO :empno; - Ice::Identity empId; - empId.category = _empCategory; - empId.name = encodeName(empno); + Ice::Identity empId; + empId.category = _empCategory; + empId.name = encodeName(empno); - result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); + result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); } EXEC SQL CLOSE empCursor2; diff --git a/cpp/demo/Database/Oracle/proc/EmpI.pc b/cpp/demo/Database/Oracle/proc/EmpI.pc index e74887a939d..5506d0d0d84 100644 --- a/cpp/demo/Database/Oracle/proc/EmpI.pc +++ b/cpp/demo/Database/Oracle/proc/EmpI.pc @@ -17,7 +17,7 @@ EXEC SQL WHENEVER NOT FOUND DO handleNotFound(current, ctx); using namespace std; EmpI::EmpI(const CurrentSqlContext& currentCtx, - const string& empCategory, const string& deptCategory) : + const string& empCategory, const string& deptCategory) : _currentCtx(currentCtx), _empCategory(empCategory), _deptCategory(deptCategory) @@ -40,7 +40,7 @@ EmpI::ice_ping(const Ice::Current& current) const if(count == 0) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } } @@ -69,7 +69,7 @@ EmpI::getDesc(const Ice::Current& current) EXEC SQL CONTEXT USE :ctx; EXEC SQL SELECT ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO - INTO :ename:enameInd, :job:jobInd, :mgr:mgrInd, :hiredate:hiredateInd, :sal:salInd, :comm:commInd, + INTO :ename:enameInd, :job:jobInd, :mgr:mgrInd, :hiredate:hiredateInd, :sal:salInd, :comm:commInd, :deptno:deptnoInd FROM EMP WHERE EMPNO = :empno; EXEC SQL COMMIT; @@ -79,37 +79,37 @@ EmpI::getDesc(const Ice::Current& current) if(enameInd >= 0) { - result.ename = ename; + result.ename = ename; } if(jobInd >= 0) { - result.job = job; + result.job = job; } if(mgrInd >= 0) { - Ice::Identity mgrId; - mgrId.name = encodeName(mgr); - mgrId.category = _empCategory; - result.mgr = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(mgrId)); + Ice::Identity mgrId; + mgrId.name = encodeName(mgr); + mgrId.category = _empCategory; + result.mgr = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(mgrId)); } if(hiredateInd >= 0) { - result.hiredate = hiredate; + result.hiredate = hiredate; } if(salInd >= 0) { - result.sal = sal; + result.sal = sal; } if(commInd >= 0) { - result.comm = comm; + result.comm = comm; } if(deptnoInd >= 0) { - Ice::Identity deptId; - deptId.name = encodeName(deptno); - deptId.category = _deptCategory; - result.edept = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); + Ice::Identity deptId; + deptId.name = encodeName(deptno); + deptId.category = _deptCategory; + result.edept = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); } return result; } @@ -118,7 +118,7 @@ void EmpI::updateField(const string& field, const string& newValue, const Ice::Current& current) { const string updateEmpStr = - "UPDATE EMP SET " + field + " = '" + newValue + "' WHERE EMPNO = " + current.id.name; + "UPDATE EMP SET " + field + " = '" + newValue + "' WHERE EMPNO = " + current.id.name; sqlca sqlca; EXEC SQL BEGIN DECLARE SECTION; diff --git a/cpp/demo/Database/Oracle/proc/Server.pc b/cpp/demo/Database/Oracle/proc/Server.pc index a0a0d80e083..bc325649259 100644 --- a/cpp/demo/Database/Oracle/proc/Server.pc +++ b/cpp/demo/Database/Oracle/proc/Server.pc @@ -34,18 +34,18 @@ class DefaultServantLocator : public Ice::ServantLocator public: DefaultServantLocator(const Ice::ObjectPtr& servant) : - _servant(servant) + _servant(servant) { } virtual Ice::ObjectPtr locate(const Ice::Current&, Ice::LocalObjectPtr&) { - return _servant; + return _servant; } virtual void finished(const Ice::Current& curr, - const Ice::ObjectPtr& servant, - const Ice::LocalObjectPtr& cookie) + const Ice::ObjectPtr& servant, + const Ice::LocalObjectPtr& cookie) { } @@ -70,7 +70,7 @@ main(int argc, char* argv[]) initData.properties->load("config.server"); const string connectInfo = initData.properties - ->getPropertyWithDefault("Oracle.ConnectInfo", "scott/tiger"); + ->getPropertyWithDefault("Oracle.ConnectInfo", "scott/tiger"); CurrentSqlContext currentCtx(connectInfo); initData.threadHook = currentCtx.getHook(); @@ -92,12 +92,12 @@ HRServer::run(int argc, char* argv[]) const string deptCategory = "Dept"; adapter->addServantLocator(new DefaultServantLocator(new EmpI(_currentCtx, empCategory, deptCategory)), - empCategory); + empCategory); adapter->addServantLocator(new DefaultServantLocator(new DeptI(_currentCtx, empCategory)), deptCategory); adapter->add(new DeptFactoryI(_currentCtx, deptCategory, empCategory), - communicator()->stringToIdentity("DeptFactory")); + communicator()->stringToIdentity("DeptFactory")); adapter->activate(); communicator()->waitForShutdown(); diff --git a/cpp/demo/Database/Oracle/proc/Util.pc b/cpp/demo/Database/Oracle/proc/Util.pc index 9e96d81d88a..6a3ab69c03d 100644 --- a/cpp/demo/Database/Oracle/proc/Util.pc +++ b/cpp/demo/Database/Oracle/proc/Util.pc @@ -57,8 +57,8 @@ decodeName(const string& name) is >> result; if(!is || !is.eof()) { - cerr << "Unable to decode " << name << endl; - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + cerr << "Unable to decode " << name << endl; + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } return result; } diff --git a/cpp/demo/Freeze/backup/Client.cpp b/cpp/demo/Freeze/backup/Client.cpp index 89008fa26b2..4630a15858f 100644 --- a/cpp/demo/Freeze/backup/Client.cpp +++ b/cpp/demo/Freeze/backup/Client.cpp @@ -38,51 +38,51 @@ main(int argc, char* argv[]) const int size = 10000; if(m.size() == 0) - { - cout << "********* Creating new map ***********" << endl; - Freeze::TransactionHolder txHolder(connection); - - IceUtil::Time time = IceUtil::Time::now(); - IceUtil::Int64 ms = time.toMilliSeconds(); - - for(int i = 0; i < size; ++i) - { - m.insert(IntLongMap::value_type(i, ms)); - } - txHolder.commit(); + { + cout << "********* Creating new map ***********" << endl; + Freeze::TransactionHolder txHolder(connection); + + IceUtil::Time time = IceUtil::Time::now(); + IceUtil::Int64 ms = time.toMilliSeconds(); + + for(int i = 0; i < size; ++i) + { + m.insert(IntLongMap::value_type(i, ms)); + } + txHolder.commit(); } cout << "Updating map" << endl; for(;;) { - int count = 0; - - Freeze::TransactionHolder txHolder(connection); - IceUtil::Time time = IceUtil::Time::now(); - IceUtil::Int64 ms = time.toMilliSeconds(); - - IntLongMap::iterator p = m.begin(); - IceUtil::Int64 oldMs = p->second; - do - { - if(p->second != oldMs) - { - cerr << "old time (ms) == " << oldMs << endl; - cerr << "current current (ms) == " << p->second << endl; - } - - test(p->second == oldMs); - p.set(ms); - count++; - } while(++p != m.end()); - - cout << "Read " << IceUtil::Time::milliSeconds(oldMs).toDateTime() << " in all records;" - << " updating with " << time.toDateTime() << " ... " << flush; - - txHolder.commit(); - cout << "done" << endl; - test(count == size); + int count = 0; + + Freeze::TransactionHolder txHolder(connection); + IceUtil::Time time = IceUtil::Time::now(); + IceUtil::Int64 ms = time.toMilliSeconds(); + + IntLongMap::iterator p = m.begin(); + IceUtil::Int64 oldMs = p->second; + do + { + if(p->second != oldMs) + { + cerr << "old time (ms) == " << oldMs << endl; + cerr << "current current (ms) == " << p->second << endl; + } + + test(p->second == oldMs); + p.set(ms); + count++; + } while(++p != m.end()); + + cout << "Read " << IceUtil::Time::milliSeconds(oldMs).toDateTime() << " in all records;" + << " updating with " << time.toDateTime() << " ... " << flush; + + txHolder.commit(); + cout << "done" << endl; + test(count == size); } connection->close(); diff --git a/cpp/demo/Freeze/bench/Client.cpp b/cpp/demo/Freeze/bench/Client.cpp index 07b95e14f38..67f71de2a2e 100644 --- a/cpp/demo/Freeze/bench/Client.cpp +++ b/cpp/demo/Freeze/bench/Client.cpp @@ -36,20 +36,20 @@ public: void start() { - _stopped = false; - _start = IceUtil::Time::now(); + _stopped = false; + _start = IceUtil::Time::now(); } IceUtil::Time stop() { - if(!_stopped) - { - _stopped = true; - _stop = IceUtil::Time::now(); - } + if(!_stopped) + { + _stopped = true; + _stop = IceUtil::Time::now(); + } - return _stop - _start; + return _stop - _start; } private: @@ -75,23 +75,23 @@ class RandomGenerator : public Generator public: RandomGenerator(int seed, int max) : - _max(max) + _max(max) { - srand(seed); + srand(seed); } virtual int next() { - return rand() % _max; + return rand() % _max; } virtual string toString() { - ostringstream os; - os << "random(" << _max << ")"; - return os.str(); + ostringstream os; + os << "random(" << _max << ")"; + return os.str(); } private: @@ -104,30 +104,30 @@ class SequentialGenerator : public Generator public: SequentialGenerator(int min, int max) : - _min(min), - _max(max), - _current(0) + _min(min), + _max(max), + _current(0) { } virtual int next() { - int n = _current; - ++_current; - if(_current > _max) - { - _current = _min; - } - return n; + int n = _current; + ++_current; + if(_current > _max) + { + _current = _min; + } + return n; } virtual string toString() { - ostringstream os; - os << ((_max - _min)+1); - return os.str(); + ostringstream os; + os << ((_max - _min)+1); + return os.str(); } private: @@ -157,68 +157,68 @@ private: void IntIntMapIndexTest(IndexedIntIntMap&); template<class T> void IntIntMapTest(const string& mapName, T* = 0) { - T m(_connection, mapName); - // - // Populate the database. - // - int i; - _watch.start(); - { - Freeze::TransactionHolder txHolder(_connection); - for(i = 0; i < _repetitions; ++i) - { + T m(_connection, mapName); + // + // Populate the database. + // + int i; + _watch.start(); + { + Freeze::TransactionHolder txHolder(_connection); + for(i = 0; i < _repetitions; ++i) + { #if defined(__BCPLUSPLUS__) || (defined(_MSC_VER) && (_MSC_VER < 1310)) - m.put(T::value_type(i, i)); + m.put(T::value_type(i, i)); #else - m.put(typename T::value_type(i, i)); + m.put(typename T::value_type(i, i)); #endif - } - txHolder.commit(); - } - IceUtil::Time total = _watch.stop(); - IceUtil::Time perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " writes: " << total * 1000 << "ms" << endl; - cout << "\ttime per write: " << perRecord * 1000 << "ms" << endl; - - // - // Read each record. - // - _watch.start(); - for(i = 0; i < _repetitions; ++i) - { - typename T::iterator p = m.find(i); - test(p != m.end()); - test(p->second == i); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " reads: " << total * 1000 << "ms" << endl; - cout << "\ttime per read: " << perRecord * 1000 << "ms" << endl; - - // - // Optional index sub-test - // - IntIntMapIndexTest(m); - - // - // Remove each record. - // - _watch.start(); - { - Freeze::TransactionHolder txHolder(_connection); - for(i = 0; i < _repetitions; ++i) - { - m.erase(i); - } - txHolder.commit(); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " removes: " << total * 1000 << "ms" << endl; - cout << "\ttime per remove: " << perRecord * 1000 << "ms" << endl; + } + txHolder.commit(); + } + IceUtil::Time total = _watch.stop(); + IceUtil::Time perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " writes: " << total * 1000 << "ms" << endl; + cout << "\ttime per write: " << perRecord * 1000 << "ms" << endl; + + // + // Read each record. + // + _watch.start(); + for(i = 0; i < _repetitions; ++i) + { + typename T::iterator p = m.find(i); + test(p != m.end()); + test(p->second == i); + } + total = _watch.stop(); + perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " reads: " << total * 1000 << "ms" << endl; + cout << "\ttime per read: " << perRecord * 1000 << "ms" << endl; + + // + // Optional index sub-test + // + IntIntMapIndexTest(m); + + // + // Remove each record. + // + _watch.start(); + { + Freeze::TransactionHolder txHolder(_connection); + for(i = 0; i < _repetitions; ++i) + { + m.erase(i); + } + txHolder.commit(); + } + total = _watch.stop(); + perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " removes: " << total * 1000 << "ms" << endl; + cout << "\ttime per remove: " << perRecord * 1000 << "ms" << endl; } @@ -227,22 +227,22 @@ private: void generatedReadWithIndex(IndexedIntIntMap&, int, const GeneratorPtr&); template<class T> void generatedRead(T& m, int reads , const GeneratorPtr& gen) { - _watch.start(); - for(int i = 0; i < reads; ++i) - { - int key = gen->next(); - typename T::iterator p = m.find(key); - test(p != m.end()); - test(p->second == key); - } - IceUtil::Time total = _watch.stop(); - IceUtil::Time perRecord = total / reads; - - cout << "\ttime for " << reads << " reads of " << gen->toString() << " records: " << total * 1000 << "ms" - << endl; - cout << "\ttime per read: " << perRecord * 1000 << "ms" << endl; - - generatedReadWithIndex(m, reads, gen); + _watch.start(); + for(int i = 0; i < reads; ++i) + { + int key = gen->next(); + typename T::iterator p = m.find(key); + test(p != m.end()); + test(p->second == key); + } + IceUtil::Time total = _watch.stop(); + IceUtil::Time perRecord = total / reads; + + cout << "\ttime for " << reads << " reads of " << gen->toString() << " records: " << total * 1000 << "ms" + << endl; + cout << "\ttime per read: " << perRecord * 1000 << "ms" << endl; + + generatedReadWithIndex(m, reads, gen); } @@ -251,81 +251,81 @@ private: void Struct1Struct2MapIndexTest(IndexedStruct1Struct2Map&); template<class T> void Struct1Struct2MapTest(const string& mapName, T* = 0) { - T m(_connection, mapName); - - // - // Populate the database. - // - Struct1 s1; - Struct2 s2; - int i; - _watch.start(); - { - Freeze::TransactionHolder txHolder(_connection); - for(i = 0; i < _repetitions; ++i) - { - s1.l = i; - ostringstream os; - os << i; - s2.s = os.str(); - s2.s1 = s1; + T m(_connection, mapName); + + // + // Populate the database. + // + Struct1 s1; + Struct2 s2; + int i; + _watch.start(); + { + Freeze::TransactionHolder txHolder(_connection); + for(i = 0; i < _repetitions; ++i) + { + s1.l = i; + ostringstream os; + os << i; + s2.s = os.str(); + s2.s1 = s1; #if defined(__BCPLUSPLUS__) || (defined(_MSC_VER) && (_MSC_VER < 1310)) - m.put(T::value_type(s1, s2)); + m.put(T::value_type(s1, s2)); #else - m.put(typename T::value_type(s1, s2)); + m.put(typename T::value_type(s1, s2)); #endif - } - txHolder.commit(); - } - IceUtil::Time total = _watch.stop(); - IceUtil::Time perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " writes: " << total * 1000 << "ms" << endl; - cout << "\ttime per write: " << perRecord * 1000 << "ms" << endl; - - // - // Read each record. - // - _watch.start(); - for(i = 0; i < _repetitions; ++i) - { - s1.l = i; - typename T::iterator p = m.find(s1); - test(p != m.end()); - ostringstream os; - os << i; - test(p->second.s == os.str()); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " reads: " << total * 1000 << "ms" << endl; - cout << "\ttime per read: " << perRecord * 1000 << "ms" << endl; - - // - // Optional index test - // - Struct1Struct2MapIndexTest(m); - - // - // Remove each record. - // - _watch.start(); - { - Freeze::TransactionHolder txHolder(_connection); - for(i = 0; i < _repetitions; ++i) - { - s1.l = i; - m.erase(s1); - } - txHolder.commit(); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " removes: " << total * 1000 << "ms" << endl; - cout << "\ttime per remove: " << perRecord * 1000 << "ms" << endl; + } + txHolder.commit(); + } + IceUtil::Time total = _watch.stop(); + IceUtil::Time perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " writes: " << total * 1000 << "ms" << endl; + cout << "\ttime per write: " << perRecord * 1000 << "ms" << endl; + + // + // Read each record. + // + _watch.start(); + for(i = 0; i < _repetitions; ++i) + { + s1.l = i; + typename T::iterator p = m.find(s1); + test(p != m.end()); + ostringstream os; + os << i; + test(p->second.s == os.str()); + } + total = _watch.stop(); + perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " reads: " << total * 1000 << "ms" << endl; + cout << "\ttime per read: " << perRecord * 1000 << "ms" << endl; + + // + // Optional index test + // + Struct1Struct2MapIndexTest(m); + + // + // Remove each record. + // + _watch.start(); + { + Freeze::TransactionHolder txHolder(_connection); + for(i = 0; i < _repetitions; ++i) + { + s1.l = i; + m.erase(s1); + } + txHolder.commit(); + } + total = _watch.stop(); + perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " removes: " << total * 1000 << "ms" << endl; + cout << "\ttime per remove: " << perRecord * 1000 << "ms" << endl; } @@ -334,80 +334,80 @@ private: void Struct1Class1MapIndexTest(IndexedStruct1Class1Map&); template<class T> void Struct1Class1MapTest(const string& mapName, T* = 0) { - T m(_connection, mapName); - - // - // Populate the database. - // - Struct1 s1; - Class1Ptr c1 = new Class1(); - int i; - _watch.start(); - { - Freeze::TransactionHolder txHolder(_connection); - for(i = 0; i < _repetitions; ++i) - { - s1.l = i; - ostringstream os; - os << i; - c1->s = os.str(); + T m(_connection, mapName); + + // + // Populate the database. + // + Struct1 s1; + Class1Ptr c1 = new Class1(); + int i; + _watch.start(); + { + Freeze::TransactionHolder txHolder(_connection); + for(i = 0; i < _repetitions; ++i) + { + s1.l = i; + ostringstream os; + os << i; + c1->s = os.str(); #if defined(__BCPLUSPLUS__) || (defined(_MSC_VER) && (_MSC_VER < 1310)) - m.put(T::value_type(s1, c1)); + m.put(T::value_type(s1, c1)); #else - m.put(typename T::value_type(s1, c1)); + m.put(typename T::value_type(s1, c1)); #endif - } - txHolder.commit(); - } - IceUtil::Time total = _watch.stop(); - IceUtil::Time perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " writes: " << total * 1000 << "ms" << endl; - cout << "\ttime per write: " << perRecord * 1000 << "ms" << endl; - - // - // Read each record. - // - _watch.start(); - for(i = 0; i < _repetitions; ++i) - { - s1.l = i; - typename T::iterator p = m.find(s1); - test(p != m.end()); - ostringstream os; - os << i; - test(p->second->s == os.str()); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " reads: " << total * 1000 << "ms" << endl; - cout << "\ttime per read: " << perRecord * 1000 << "ms" << endl; - - // - // Optional index test - // - - Struct1Class1MapIndexTest(m); - - // - // Remove each record. - // - _watch.start(); - { - Freeze::TransactionHolder txHolder(_connection); - for(i = 0; i < _repetitions; ++i) - { - s1.l = i; - m.erase(s1); - } - txHolder.commit(); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " removes: " << total * 1000 << "ms" << endl; - cout << "\ttime per remove: " << perRecord * 1000 << "ms" << endl; + } + txHolder.commit(); + } + IceUtil::Time total = _watch.stop(); + IceUtil::Time perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " writes: " << total * 1000 << "ms" << endl; + cout << "\ttime per write: " << perRecord * 1000 << "ms" << endl; + + // + // Read each record. + // + _watch.start(); + for(i = 0; i < _repetitions; ++i) + { + s1.l = i; + typename T::iterator p = m.find(s1); + test(p != m.end()); + ostringstream os; + os << i; + test(p->second->s == os.str()); + } + total = _watch.stop(); + perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " reads: " << total * 1000 << "ms" << endl; + cout << "\ttime per read: " << perRecord * 1000 << "ms" << endl; + + // + // Optional index test + // + + Struct1Class1MapIndexTest(m); + + // + // Remove each record. + // + _watch.start(); + { + Freeze::TransactionHolder txHolder(_connection); + for(i = 0; i < _repetitions; ++i) + { + s1.l = i; + m.erase(s1); + } + txHolder.commit(); + } + total = _watch.stop(); + perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " removes: " << total * 1000 << "ms" << endl; + cout << "\ttime per remove: " << perRecord * 1000 << "ms" << endl; } void IntIntMapReadIndexTest(IntIntMap&) @@ -415,62 +415,62 @@ private: void IntIntMapReadIndexTest(IndexedIntIntMap&); template<class T> void IntIntMapReadTest(const string& mapName, T* = 0) { - T m(_connection, mapName); - - // - // Populate the database. - // - int i; - _watch.start(); - { - Freeze::TransactionHolder txHolder(_connection); - for(i = 0; i < _repetitions; ++i) - { + T m(_connection, mapName); + + // + // Populate the database. + // + int i; + _watch.start(); + { + Freeze::TransactionHolder txHolder(_connection); + for(i = 0; i < _repetitions; ++i) + { #if defined(__BCPLUSPLUS__) || (defined(_MSC_VER) && (_MSC_VER < 1310)) - m.put(T::value_type(i, i)); + m.put(T::value_type(i, i)); #else - m.put(typename T::value_type(i, i)); + m.put(typename T::value_type(i, i)); #endif - } - txHolder.commit(); - } - IceUtil::Time total = _watch.stop(); - IceUtil::Time perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " writes: " << total * 1000 << "ms" << endl; - cout << "\ttime per write: " << perRecord * 1000 << "ms" << endl; - - // - // Do some read tests. - // - generatedRead(m, _repetitions, new SequentialGenerator(1000, 1000)); - generatedRead(m, _repetitions, new SequentialGenerator(2000, 2009)); - generatedRead(m, _repetitions, new SequentialGenerator(3000, 3099)); - generatedRead(m, _repetitions, new SequentialGenerator(4000, 4999)); - - // - // Do a random read test. - // - generatedRead(m, _repetitions, new RandomGenerator(0, 10000)); - - // - // Remove each record. - // - /* - * For this test I don't want to remove the records because I - * want to examine the cache stats for the database. - * - _watch.start(); - for(i = 0; i < _repetitions; ++i) - { - m.erase(i); - } - total = _watch.stop(); - perRecord = total / _repetitions; - - cout << "\ttime for " << _repetitions << " removes: " << total * 1000 << "ms" << endl; - cout << "\ttime per remove: " << perRecord * 1000 << "ms" << endl; - */ + } + txHolder.commit(); + } + IceUtil::Time total = _watch.stop(); + IceUtil::Time perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " writes: " << total * 1000 << "ms" << endl; + cout << "\ttime per write: " << perRecord * 1000 << "ms" << endl; + + // + // Do some read tests. + // + generatedRead(m, _repetitions, new SequentialGenerator(1000, 1000)); + generatedRead(m, _repetitions, new SequentialGenerator(2000, 2009)); + generatedRead(m, _repetitions, new SequentialGenerator(3000, 3099)); + generatedRead(m, _repetitions, new SequentialGenerator(4000, 4999)); + + // + // Do a random read test. + // + generatedRead(m, _repetitions, new RandomGenerator(0, 10000)); + + // + // Remove each record. + // + /* + * For this test I don't want to remove the records because I + * want to examine the cache stats for the database. + * + _watch.start(); + for(i = 0; i < _repetitions; ++i) + { + m.erase(i); + } + total = _watch.stop(); + perRecord = total / _repetitions; + + cout << "\ttime for " << _repetitions << " removes: " << total * 1000 << "ms" << endl; + cout << "\ttime per remove: " << perRecord * 1000 << "ms" << endl; + */ } @@ -497,15 +497,15 @@ TestApp::IntIntMapIndexTest(IndexedIntIntMap& m) _watch.start(); for(int i = 0; i < _repetitions; ++i) { - IndexedIntIntMap::iterator p = m.findByValue(i); - test(p != m.end()); - test(p->second == i); + IndexedIntIntMap::iterator p = m.findByValue(i); + test(p != m.end()); + test(p->second == i); } IceUtil::Time total = _watch.stop(); IceUtil::Time perRecord = total / _repetitions; cout << "\ttime for " << _repetitions << " reverse (indexed) reads: " << total * 1000 << "ms" - << endl; + << endl; cout << "\ttime per reverse read: " << perRecord * 1000 << "ms" << endl; } @@ -515,16 +515,16 @@ TestApp::generatedReadWithIndex(IndexedIntIntMap& m, int reads, const GeneratorP _watch.start(); for(int i = 0; i < reads; ++i) { - int value = gen->next(); - IndexedIntIntMap::iterator p = m.findByValue(value); - test(p != m.end()); - test(p->second == value); + int value = gen->next(); + IndexedIntIntMap::iterator p = m.findByValue(value); + test(p != m.end()); + test(p->second == value); } IceUtil::Time total = _watch.stop(); IceUtil::Time perRecord = total / reads; cout << "\ttime for " << reads << " reverse (indexed) reads of " << gen->toString() << " records: " - << total * 1000 << "ms" << endl; + << total * 1000 << "ms" << endl; cout << "\ttime per reverse read: " << perRecord * 1000 << "ms" << endl; } @@ -536,23 +536,23 @@ TestApp::Struct1Struct2MapIndexTest(IndexedStruct1Struct2Map& m) _watch.start(); for(i = 0; i < _repetitions; ++i) { - ostringstream os; - os << i; + ostringstream os; + os << i; - IndexedStruct1Struct2Map::iterator p = m.findByS(os.str()); - test(p != m.end()); - test(p->first.l == i); - test(p->second.s1.l == i); + IndexedStruct1Struct2Map::iterator p = m.findByS(os.str()); + test(p != m.end()); + test(p->first.l == i); + test(p->second.s1.l == i); } for(i = 0; i < _repetitions; ++i) { - Struct1 s1; - s1.l = i; - IndexedStruct1Struct2Map::iterator p = m.findByS1(s1); - test(p != m.end()); - test(p->first.l == i); - test(p->second.s1.l == i); + Struct1 s1; + s1.l = i; + IndexedStruct1Struct2Map::iterator p = m.findByS1(s1); + test(p != m.end()); + test(p->first.l == i); + test(p->second.s1.l == i); } IceUtil::Time total = _watch.stop(); @@ -571,12 +571,12 @@ TestApp::Struct1Class1MapIndexTest(IndexedStruct1Class1Map& m) _watch.start(); for(int i = 0; i < _repetitions; ++i) { - ostringstream os; - os << i; + ostringstream os; + os << i; - IndexedStruct1Class1Map::iterator p = m.findByS(os.str()); - test(p != m.end()); - test(p->first.l == i); + IndexedStruct1Class1Map::iterator p = m.findByS(os.str()); + test(p != m.end()); + test(p->first.l == i); } IceUtil::Time total = _watch.stop(); IceUtil::Time perRecord = total / _repetitions; @@ -603,25 +603,25 @@ TestApp::Struct1ObjectMapTest() int i; _watch.start(); { - Freeze::TransactionHolder txHolder(_connection); - for(i = 0; i < _repetitions; ++i) - { - s1.l = i; - Ice::ObjectPtr o; - if((i % 2) == 0) - { - o = c2; - } - else - { - o = c1; - } - ostringstream os; - os << i; - c1->s = os.str(); - m.put(Struct1ObjectMap::value_type(s1, o)); - } - txHolder.commit(); + Freeze::TransactionHolder txHolder(_connection); + for(i = 0; i < _repetitions; ++i) + { + s1.l = i; + Ice::ObjectPtr o; + if((i % 2) == 0) + { + o = c2; + } + else + { + o = c1; + } + ostringstream os; + os << i; + c1->s = os.str(); + m.put(Struct1ObjectMap::value_type(s1, o)); + } + txHolder.commit(); } IceUtil::Time total = _watch.stop(); IceUtil::Time perRecord = total / _repetitions; @@ -635,27 +635,27 @@ TestApp::Struct1ObjectMapTest() _watch.start(); for(i = 0; i < _repetitions; ++i) { - s1.l = i; - Struct1ObjectMap::iterator p = m.find(s1); - test(p != m.end()); - Ice::ObjectPtr o = p->second; - Class1Ptr nc1; - if((i % 2) == 0) - { - Class2Ptr nc2 = Class2Ptr::dynamicCast(o); - test(nc2); - - test(nc2->rec == nc2); - nc1 = Class1Ptr::dynamicCast(nc2->obj); - } - else - { - nc1 = Class1Ptr::dynamicCast(o); - } - test(nc1); - ostringstream os; - os << i; - test(nc1->s == os.str()); + s1.l = i; + Struct1ObjectMap::iterator p = m.find(s1); + test(p != m.end()); + Ice::ObjectPtr o = p->second; + Class1Ptr nc1; + if((i % 2) == 0) + { + Class2Ptr nc2 = Class2Ptr::dynamicCast(o); + test(nc2); + + test(nc2->rec == nc2); + nc1 = Class1Ptr::dynamicCast(nc2->obj); + } + else + { + nc1 = Class1Ptr::dynamicCast(o); + } + test(nc1); + ostringstream os; + os << i; + test(nc1->s == os.str()); } total = _watch.stop(); perRecord = total / _repetitions; @@ -668,13 +668,13 @@ TestApp::Struct1ObjectMapTest() // _watch.start(); { - Freeze::TransactionHolder txHolder(_connection); - for(i = 0; i < _repetitions; ++i) - { - s1.l = i; - m.erase(s1); - } - txHolder.commit(); + Freeze::TransactionHolder txHolder(_connection); + for(i = 0; i < _repetitions; ++i) + { + s1.l = i; + m.erase(s1); + } + txHolder.commit(); } total = _watch.stop(); perRecord = total / _repetitions; @@ -690,15 +690,15 @@ public: Ice::ObjectPtr create(const string& type) { - if(type == "::Class1") - { - return new Class1(); - } - else if(type == "::Class2") - { - return new Class2(); - } - return 0; + if(type == "::Class1") + { + return new Class1(); + } + else if(type == "::Class2") + { + return new Class2(); + } + return 0; } void @@ -709,8 +709,8 @@ public: void install(const Ice::CommunicatorPtr& communicator) { - communicator->addObjectFactory(this, "::Class1"); - communicator->addObjectFactory(this, "::Class2"); + communicator->addObjectFactory(this, "::Class1"); + communicator->addObjectFactory(this, "::Class2"); } }; typedef IceUtil::Handle<MyFactory> MyFactoryPtr; @@ -729,8 +729,8 @@ TestApp::run(int argc, char* argv[]) cout << "IntIntMap" << endl; #if defined(_MSC_VER) && (_MSC_VER < 1310) { - IntIntMap* dummy = 0; - IntIntMapTest("IntIntMap", dummy); + IntIntMap* dummy = 0; + IntIntMapTest("IntIntMap", dummy); } #else IntIntMapTest<IntIntMap>("IntIntMap"); @@ -739,8 +739,8 @@ TestApp::run(int argc, char* argv[]) cout << "IntIntMap with index" << endl; #if defined(_MSC_VER) && (_MSC_VER < 1310) { - IndexedIntIntMap* dummy = 0; - IntIntMapTest("IndexedIntIntMap", dummy); + IndexedIntIntMap* dummy = 0; + IntIntMapTest("IndexedIntIntMap", dummy); } #else IntIntMapTest<IndexedIntIntMap>("IndexedIntIntMap"); @@ -749,8 +749,8 @@ TestApp::run(int argc, char* argv[]) cout <<"Struct1Struct2Map" << endl; #if defined(_MSC_VER) && (_MSC_VER < 1310) { - Struct1Struct2Map* dummy = 0; - Struct1Struct2MapTest("Struct1Struct2Map", dummy); + Struct1Struct2Map* dummy = 0; + Struct1Struct2MapTest("Struct1Struct2Map", dummy); } #else Struct1Struct2MapTest<Struct1Struct2Map>("Struct1Struct2Map"); @@ -759,8 +759,8 @@ TestApp::run(int argc, char* argv[]) cout <<"Struct1Struct2Map with index" << endl; #if defined(_MSC_VER) && (_MSC_VER < 1310) { - IndexedStruct1Struct2Map* dummy = 0; - Struct1Struct2MapTest("IndexedStruct1Struct2Map", dummy); + IndexedStruct1Struct2Map* dummy = 0; + Struct1Struct2MapTest("IndexedStruct1Struct2Map", dummy); } #else Struct1Struct2MapTest<IndexedStruct1Struct2Map>("IndexedStruct1Struct2Map"); @@ -769,8 +769,8 @@ TestApp::run(int argc, char* argv[]) cout <<"Struct1Class1Map" << endl; #if defined(_MSC_VER) && (_MSC_VER < 1310) { - Struct1Class1Map* dummy = 0; - Struct1Class1MapTest("Struct1Class1Map", dummy); + Struct1Class1Map* dummy = 0; + Struct1Class1MapTest("Struct1Class1Map", dummy); } #else Struct1Class1MapTest<Struct1Class1Map>("Struct1Class1Map"); @@ -779,8 +779,8 @@ TestApp::run(int argc, char* argv[]) cout <<"Struct1Class1Map with index" << endl; #if defined(_MSC_VER) && (_MSC_VER < 1310) { - IndexedStruct1Class1Map* dummy = 0; - Struct1Class1MapTest("IndexedStruct1Class1Map", dummy); + IndexedStruct1Class1Map* dummy = 0; + Struct1Class1MapTest("IndexedStruct1Class1Map", dummy); } #else Struct1Class1MapTest<IndexedStruct1Class1Map>("IndexedStruct1Class1Map"); @@ -795,8 +795,8 @@ TestApp::run(int argc, char* argv[]) cout <<"IntIntMap (read test)" << endl; #if defined(_MSC_VER) && (_MSC_VER < 1310) { - IntIntMap* dummy = 0; - IntIntMapReadTest("IntIntMap", dummy); + IntIntMap* dummy = 0; + IntIntMapReadTest("IntIntMap", dummy); } #else IntIntMapReadTest<IntIntMap>("IntIntMap"); @@ -805,8 +805,8 @@ TestApp::run(int argc, char* argv[]) cout <<"IntIntMap with index(read test)" << endl; #if defined(_MSC_VER) && (_MSC_VER < 1310) { - IndexedIntIntMap* dummy = 0; - IntIntMapReadTest("IndexedIntIntMap", dummy); + IndexedIntIntMap* dummy = 0; + IntIntMapReadTest("IndexedIntIntMap", dummy); } #else IntIntMapReadTest<IndexedIntIntMap>("IndexedIntIntMap"); diff --git a/cpp/demo/Freeze/library/Client.cpp b/cpp/demo/Freeze/library/Client.cpp index 2cd23ba1bf8..4c13a512683 100644 --- a/cpp/demo/Freeze/library/Client.cpp +++ b/cpp/demo/Freeze/library/Client.cpp @@ -43,15 +43,15 @@ LibraryClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/Freeze/library/Collocated.cpp b/cpp/demo/Freeze/library/Collocated.cpp index 5c7ed0261d3..a3457c081dc 100644 --- a/cpp/demo/Freeze/library/Collocated.cpp +++ b/cpp/demo/Freeze/library/Collocated.cpp @@ -19,7 +19,7 @@ class LibraryCollocated : public Ice::Application public: LibraryCollocated(const string& envName) : - _envName(envName) + _envName(envName) { } @@ -61,7 +61,7 @@ LibraryCollocated::run(int argc, char* argv[]) Ice::Int evictorSize = properties->getPropertyAsInt("Library.EvictorSize"); if(evictorSize > 0) { - evictor->setSize(evictorSize); + evictor->setSize(evictorSize); } // @@ -96,15 +96,15 @@ LibraryCollocated::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/Freeze/library/Library.ice b/cpp/demo/Freeze/library/Library.ice index 7111b0f1eac..87663189286 100644 --- a/cpp/demo/Freeze/library/Library.ice +++ b/cpp/demo/Freeze/library/Library.ice @@ -92,7 +92,7 @@ class Book * **/ ["freeze:write"] void destroy() - throws DatabaseException; + throws DatabaseException; /** * @@ -105,7 +105,7 @@ class Book * **/ ["freeze:write"] void rentBook(string name) - throws BookRentedException; + throws BookRentedException; /** * @@ -118,7 +118,7 @@ class Book * **/ ["cpp:const"] idempotent string getRenterName() - throws BookNotRentedException; + throws BookNotRentedException; /** * @@ -129,7 +129,7 @@ class Book * **/ ["freeze:write"] void returnBook() - throws BookNotRentedException; + throws BookNotRentedException; /** * @@ -177,7 +177,7 @@ interface Library * **/ Book* createBook(BookDescription description) - throws DatabaseException, BookExistsException; + throws DatabaseException, BookExistsException; /** * @@ -192,7 +192,7 @@ interface Library * **/ ["cpp:const"] idempotent Book* findByIsbn(string isbn) - throws DatabaseException; + throws DatabaseException; /** * @@ -207,7 +207,7 @@ interface Library * **/ ["cpp:const"] idempotent BookPrxSeq findByAuthors(string authors) - throws DatabaseException; + throws DatabaseException; /** * @@ -220,7 +220,7 @@ interface Library * **/ idempotent void setEvictorSize(int size) - throws DatabaseException; + throws DatabaseException; /** * diff --git a/cpp/demo/Freeze/library/LibraryI.cpp b/cpp/demo/Freeze/library/LibraryI.cpp index 450420c6f55..8a950d3b95c 100644 --- a/cpp/demo/Freeze/library/LibraryI.cpp +++ b/cpp/demo/Freeze/library/LibraryI.cpp @@ -24,19 +24,19 @@ BookI::destroy(const Ice::Current&) IceUtil::Mutex::Lock lock(*this); if(_destroyed) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } _destroyed = true; try { - _library->remove(description); + _library->remove(description); } catch(const Freeze::DatabaseException& ex) { - DatabaseException e; - e.message = ex.message; - throw e; + DatabaseException e; + e.message = ex.message; + throw e; } } @@ -68,7 +68,7 @@ BookI::getRenterName(const Ice::Current&) const if(rentalCustomerName.empty()) { - throw BookNotRentedException(); + throw BookNotRentedException(); } return rentalCustomerName; } @@ -85,7 +85,7 @@ BookI::rentBook(const string& name, const Ice::Current&) if(!rentalCustomerName.empty()) { - throw BookRentedException(); + throw BookRentedException(); } rentalCustomerName = name; } @@ -102,7 +102,7 @@ BookI::returnBook(const Ice::Current&) if(rentalCustomerName.empty()) { - throw BookNotRentedException(); + throw BookNotRentedException(); } rentalCustomerName.clear();; } @@ -128,14 +128,14 @@ class IsbnToBook public: IsbnToBook(const Ice::ObjectAdapterPtr& adapter) : - _adapter(adapter) + _adapter(adapter) { } BookPrx operator()(const string& isbn) { - return BookPrx::uncheckedCast(_adapter->createProxy(createBookIdentity(isbn))); + return BookPrx::uncheckedCast(_adapter->createProxy(createBookIdentity(isbn))); } private: @@ -144,8 +144,8 @@ private: }; LibraryI::LibraryI(const Ice::CommunicatorPtr& communicator, - const string& envName, const string& dbName, - const Freeze::EvictorPtr& evictor) : + const string& envName, const string& dbName, + const Freeze::EvictorPtr& evictor) : _evictor(evictor), _connection(Freeze::createConnection(communicator, envName)), _authors(_connection, dbName) @@ -163,25 +163,25 @@ LibraryI::createBook(const Demo::BookDescription& description, const Ice::Curren // BookPrx book; { - book = IsbnToBook(c.adapter)(description.isbn); + book = IsbnToBook(c.adapter)(description.isbn); } #else BookPrx book = IsbnToBook(c.adapter)(description.isbn); #endif try { - book->ice_ping(); + book->ice_ping(); - // - // The book already exists. - // - throw BookExistsException(); + // + // The book already exists. + // + throw BookExistsException(); } catch(const Ice::ObjectNotExistException&) { - // - // Book doesn't exist, ignore the exception. - // + // + // Book doesn't exist, ignore the exception. + // } BookPtr bookI = new BookI(this); @@ -205,7 +205,7 @@ LibraryI::createBook(const Demo::BookDescription& description, const Ice::Curren StringIsbnSeqDict::iterator p = _authors.find(description.authors); if(p != _authors.end()) { - isbnSeq = p->second; + isbnSeq = p->second; } isbnSeq.push_back(description.isbn); @@ -224,16 +224,16 @@ LibraryI::findByIsbn(const string& isbn, const Ice::Current& c) const try { - BookPrx book = IsbnToBook(c.adapter)(isbn); - book->ice_ping(); - return book; + BookPrx book = IsbnToBook(c.adapter)(isbn); + book->ice_ping(); + return book; } catch(const Ice::ObjectNotExistException&) { - // - // Book doesn't exist, return a null proxy. - // - return 0; + // + // Book doesn't exist, return a null proxy. + // + return 0; } } @@ -252,8 +252,8 @@ LibraryI::findByAuthors(const string& authors, const Ice::Current& c) const if(p != _authors.end()) { - books.reserve(p->second.size()); - transform(p->second.begin(), p->second.end(), back_inserter(books), IsbnToBook(c.adapter)); + books.reserve(p->second.size()); + transform(p->second.begin(), p->second.end(), back_inserter(books), IsbnToBook(c.adapter)); } return books; @@ -286,43 +286,43 @@ LibraryI::remove(const BookDescription& description) try { - StringIsbnSeqDict::iterator p = _authors.find(description.authors); - - assert(p != _authors.end()); - - // - // Remove the isbn number from the sequence. - // - Ice::StringSeq isbnSeq = p->second; - isbnSeq.erase(remove_if(isbnSeq.begin(), isbnSeq.end(), bind2nd(equal_to<string>(), description.isbn)), - isbnSeq.end()); - - if(isbnSeq.empty()) - { - // - // If there are no further associated isbn numbers then remove - // the record. - // - _authors.erase(p); - } - else - { - // - // Otherwise, write back the new record. - // - p.set(isbnSeq); - } - - // - // This can throw EvictorDeactivatedException (which indicates - // an internal error). The exception is currently ignored. - // - _evictor->remove(createBookIdentity(description.isbn)); + StringIsbnSeqDict::iterator p = _authors.find(description.authors); + + assert(p != _authors.end()); + + // + // Remove the isbn number from the sequence. + // + Ice::StringSeq isbnSeq = p->second; + isbnSeq.erase(remove_if(isbnSeq.begin(), isbnSeq.end(), bind2nd(equal_to<string>(), description.isbn)), + isbnSeq.end()); + + if(isbnSeq.empty()) + { + // + // If there are no further associated isbn numbers then remove + // the record. + // + _authors.erase(p); + } + else + { + // + // Otherwise, write back the new record. + // + p.set(isbnSeq); + } + + // + // This can throw EvictorDeactivatedException (which indicates + // an internal error). The exception is currently ignored. + // + _evictor->remove(createBookIdentity(description.isbn)); } catch(const Freeze::DatabaseException& ex) { - DatabaseException e; - e.message = ex.message; - throw e; + DatabaseException e; + e.message = ex.message; + throw e; } } diff --git a/cpp/demo/Freeze/library/LibraryI.h b/cpp/demo/Freeze/library/LibraryI.h index 6733f6e3f35..aba7775842d 100644 --- a/cpp/demo/Freeze/library/LibraryI.h +++ b/cpp/demo/Freeze/library/LibraryI.h @@ -21,8 +21,8 @@ class LibraryI : public Demo::Library, public IceUtil::Mutex public: LibraryI(const Ice::CommunicatorPtr& communicator, - const std::string& envName, const std::string& dbName, - const Freeze::EvictorPtr& evictor); + const std::string& envName, const std::string& dbName, + const Freeze::EvictorPtr& evictor); virtual Demo::BookPrx createBook(const Demo::BookDescription&, const Ice::Current&); virtual Demo::BookPrx findByIsbn(const std::string&, const Ice::Current&) const; diff --git a/cpp/demo/Freeze/library/Parser.cpp b/cpp/demo/Freeze/library/Parser.cpp index eeb8046327d..c884b42fd6e 100644 --- a/cpp/demo/Freeze/library/Parser.cpp +++ b/cpp/demo/Freeze/library/Parser.cpp @@ -51,37 +51,37 @@ Parser::addBook(const list<string>& _args) { if(_args.size() != 3) { - error("`add' requires at exactly three arguments (type `help' for more info)"); - return; + error("`add' requires at exactly three arguments (type `help' for more info)"); + return; } try { - list<string> args = _args; + list<string> args = _args; - BookDescription desc; - desc.isbn = args.front(); - args.pop_front(); - desc.title = args.front(); - args.pop_front(); - desc.authors = args.front(); + BookDescription desc; + desc.isbn = args.front(); + args.pop_front(); + desc.title = args.front(); + args.pop_front(); + desc.authors = args.front(); - BookPrx book = _library->createBook(desc); - cout << "added new book with isbn " << desc.isbn << endl; + BookPrx book = _library->createBook(desc); + cout << "added new book with isbn " << desc.isbn << endl; } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const BookExistsException&) { - error("the book already exists."); + error("the book already exists."); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -90,36 +90,36 @@ Parser::findIsbn(const list<string>& args) { if(args.size() != 1) { - error("`isbn' requires exactly one argument (type `help' for more info)"); - return; + error("`isbn' requires exactly one argument (type `help' for more info)"); + return; } try { - _foundBooks.clear(); - _current = _foundBooks.begin(); - - BookPrx book = _library->findByIsbn(args.front()); - if(!book) - { - cout << "no book with that ISBN number exists." << endl; - } - else - { - _foundBooks.push_back(book); - _current = _foundBooks.begin(); - printCurrent(); - } + _foundBooks.clear(); + _current = _foundBooks.begin(); + + BookPrx book = _library->findByIsbn(args.front()); + if(!book) + { + cout << "no book with that ISBN number exists." << endl; + } + else + { + _foundBooks.push_back(book); + _current = _foundBooks.begin(); + printCurrent(); + } } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -128,26 +128,26 @@ Parser::findAuthors(const list<string>& args) { if(args.size() != 1) { - error("`authors' requires exactly one argument (type `help' for more info)"); - return; + error("`authors' requires exactly one argument (type `help' for more info)"); + return; } try { - _foundBooks = _library->findByAuthors(args.front()); - _current = _foundBooks.begin(); - cout << "number of books found: " << _foundBooks.size() << endl; - printCurrent(); + _foundBooks = _library->findByAuthors(args.front()); + _current = _foundBooks.begin(); + cout << "number of books found: " << _foundBooks.size() << endl; + printCurrent(); } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -156,7 +156,7 @@ Parser::nextFoundBook() { if(_current != _foundBooks.end()) { - ++_current; + ++_current; } printCurrent(); } @@ -166,31 +166,31 @@ Parser::printCurrent() { try { - if(_current != _foundBooks.end()) - { - BookDescription desc = (*_current)->getBookDescription(); - string renter; - try - { - renter = (*_current)->getRenterName(); - } - catch(const BookNotRentedException&) - { - } - - cout << "current book is:" << endl; - cout << "isbn: " << desc.isbn << endl; - cout << "title: " << desc.title << endl; - cout << "authors: " << desc.authors << endl; - if(!renter.empty()) - { - cout << "rented: " << renter << endl; - } - } - else - { - cout << "no current book" << endl; - } + if(_current != _foundBooks.end()) + { + BookDescription desc = (*_current)->getBookDescription(); + string renter; + try + { + renter = (*_current)->getRenterName(); + } + catch(const BookNotRentedException&) + { + } + + cout << "current book is:" << endl; + cout << "isbn: " << desc.isbn << endl; + cout << "title: " << desc.title << endl; + cout << "authors: " << desc.authors << endl; + if(!renter.empty()) + { + cout << "rented: " << renter << endl; + } + } + else + { + cout << "no current book" << endl; + } } catch(const Ice::ObjectNotExistException&) { @@ -198,9 +198,9 @@ Parser::printCurrent() } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -209,25 +209,25 @@ Parser::rentCurrent(const list<string>& args) { if(args.size() != 1) { - error("`rent' requires exactly one argument (type `help' for more info)"); - return; + error("`rent' requires exactly one argument (type `help' for more info)"); + return; } try { - if(_current != _foundBooks.end()) - { - (*_current)->rentBook(args.front()); - cout << "the book is now rented by `" << args.front() << "'" << endl; - } - else - { - cout << "no current book" << endl; - } + if(_current != _foundBooks.end()) + { + (*_current)->rentBook(args.front()); + cout << "the book is now rented by `" << args.front() << "'" << endl; + } + else + { + cout << "no current book" << endl; + } } catch(const BookRentedException&) { - cout << "the book has already been rented." << endl; + cout << "the book has already been rented." << endl; } catch(const Ice::ObjectNotExistException&) { @@ -235,13 +235,13 @@ Parser::rentCurrent(const list<string>& args) } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -250,19 +250,19 @@ Parser::returnCurrent() { try { - if(_current != _foundBooks.end()) - { - (*_current)->returnBook(); - cout << "the book has been returned." << endl; - } - else - { - cout << "no current book" << endl; - } + if(_current != _foundBooks.end()) + { + (*_current)->returnBook(); + cout << "the book has been returned." << endl; + } + else + { + cout << "no current book" << endl; + } } catch(const BookNotRentedException&) { - cout << "the book is not currently rented." << endl; + cout << "the book is not currently rented." << endl; } catch(const Ice::ObjectNotExistException&) { @@ -270,13 +270,13 @@ Parser::returnCurrent() } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -285,15 +285,15 @@ Parser::removeCurrent() { try { - if(_current != _foundBooks.end()) - { - (*_current)->destroy(); - cout << "removed current book" << endl; - } - else - { - cout << "no current book" << endl; - } + if(_current != _foundBooks.end()) + { + (*_current)->destroy(); + cout << "removed current book" << endl; + } + else + { + cout << "no current book" << endl; + } } catch(const Ice::ObjectNotExistException&) { @@ -301,13 +301,13 @@ Parser::removeCurrent() } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -316,23 +316,23 @@ Parser::setEvictorSize(const list<string>& args) { if(args.size() != 1) { - error("`size' requires exactly one argument (type `help' for more info)"); - return; + error("`size' requires exactly one argument (type `help' for more info)"); + return; } try { - _library->setEvictorSize(atoi(args.front().c_str())); + _library->setEvictorSize(atoi(args.front().c_str())); } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -341,13 +341,13 @@ Parser::shutdown() { try { - _library->shutdown(); + _library->shutdown(); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -356,105 +356,105 @@ Parser::getInput(char* buf, int& result, int maxSize) { if(!_commands.empty()) { - if(_commands == ";") - { - result = 0; - } - else - { + if(_commands == ";") + { + result = 0; + } + else + { #if defined(_MSC_VER) && !defined(_STLP_MSVC) - // COMPILERBUG: Stupid Visual C++ defines min and max as macros - result = _MIN(maxSize, static_cast<int>(_commands.length())); + // COMPILERBUG: Stupid Visual C++ defines min and max as macros + result = _MIN(maxSize, static_cast<int>(_commands.length())); #else - result = min(maxSize, static_cast<int>(_commands.length())); + result = min(maxSize, static_cast<int>(_commands.length())); #endif - strncpy(buf, _commands.c_str(), result); - _commands.erase(0, result); - if(_commands.empty()) - { - _commands = ";"; - } - } + strncpy(buf, _commands.c_str(), result); + _commands.erase(0, result); + if(_commands.empty()) + { + _commands = ";"; + } + } } else if(isatty(fileno(yyin))) { #ifdef HAVE_READLINE const char* prompt = parser->getPrompt(); - char* line = readline(const_cast<char*>(prompt)); - if(!line) - { - result = 0; - } - else - { - if(*line) - { - add_history(line); - } - - result = strlen(line) + 1; - if(result > maxSize) - { - free(line); - error("input line too long"); - result = 0; - } - else - { - strcpy(buf, line); - strcat(buf, "\n"); - free(line); - } - } + char* line = readline(const_cast<char*>(prompt)); + if(!line) + { + result = 0; + } + else + { + if(*line) + { + add_history(line); + } + + result = strlen(line) + 1; + if(result > maxSize) + { + free(line); + error("input line too long"); + result = 0; + } + else + { + strcpy(buf, line); + strcat(buf, "\n"); + free(line); + } + } #else - cout << parser->getPrompt() << flush; - - string line; - while(true) - { - char c = static_cast<char>(getc(yyin)); - if(c == EOF) - { - if(line.size()) - { - line += '\n'; - } - break; - } - - line += c; - - if(c == '\n') - { - break; - } - } - - result = static_cast<int>(line.length()); - if(result > maxSize) - { - error("input line too long"); - buf[0] = EOF; - result = 1; - } - else - { - strcpy(buf, line.c_str()); - } + cout << parser->getPrompt() << flush; + + string line; + while(true) + { + char c = static_cast<char>(getc(yyin)); + if(c == EOF) + { + if(line.size()) + { + line += '\n'; + } + break; + } + + line += c; + + if(c == '\n') + { + break; + } + } + + result = static_cast<int>(line.length()); + if(result > maxSize) + { + error("input line too long"); + buf[0] = EOF; + result = 1; + } + else + { + strcpy(buf, line.c_str()); + } #endif } else { - if(((result = static_cast<int>(fread(buf, 1, maxSize, yyin))) == 0) && ferror(yyin)) - { - error("input in flex scanner failed"); - buf[0] = EOF; - result = 1; - } + if(((result = static_cast<int>(fread(buf, 1, maxSize, yyin))) == 0) && ferror(yyin)) + { + error("input in flex scanner failed"); + buf[0] = EOF; + result = 1; + } } } @@ -477,12 +477,12 @@ Parser::getPrompt() if(_continue) { - _continue = false; - return "(cont) "; + _continue = false; + return "(cont) "; } else { - return ">>> "; + return ">>> "; } } @@ -491,11 +491,11 @@ Parser::error(const char* s) { if(_commands.empty() && !isatty(fileno(yyin))) { - cerr << _currentFile << ':' << _currentLine << ": " << s << endl; + cerr << _currentFile << ':' << _currentLine << ": " << s << endl; } else { - cerr << "error: " << s << endl; + cerr << "error: " << s << endl; } _errors++; } @@ -511,11 +511,11 @@ Parser::warning(const char* s) { if(_commands.empty() && !isatty(fileno(yyin))) { - cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl; + cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl; } else { - cerr << "warning: " << s << endl; + cerr << "warning: " << s << endl; } } @@ -550,7 +550,7 @@ Parser::parse(FILE* file, bool debug) int status = yyparse(); if(_errors) { - status = EXIT_FAILURE; + status = EXIT_FAILURE; } parser = 0; @@ -582,7 +582,7 @@ Parser::parse(const string& commands, bool debug) int status = yyparse(); if(_errors) { - status = EXIT_FAILURE; + status = EXIT_FAILURE; } parser = 0; diff --git a/cpp/demo/Freeze/library/RunParser.cpp b/cpp/demo/Freeze/library/RunParser.cpp index 87500d3a6f3..f1a79c08d5f 100644 --- a/cpp/demo/Freeze/library/RunParser.cpp +++ b/cpp/demo/Freeze/library/RunParser.cpp @@ -17,13 +17,13 @@ void usage(const char* appName) { cerr << "Usage: " << appName << " [options] [file...]\n"; - cerr << - "Options:\n" - "-h, --help Show this message.\n" - "-v, --version Display the Ice version.\n" - "-e COMMANDS Execute COMMANDS.\n" - "-d, --debug Print debug messages.\n" - ; + cerr << + "Options:\n" + "-h, --help Show this message.\n" + "-v, --version Display the Ice version.\n" + "-e COMMANDS Execute COMMANDS.\n" + "-d, --debug Print debug messages.\n" + ; } int @@ -35,67 +35,67 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) int idx = 1; while(idx < argc) { - if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) - { - usage(argv[0]); - return EXIT_SUCCESS; - } - else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) - { - cout << ICE_STRING_VERSION << endl; - return EXIT_SUCCESS; - } - else if(strcmp(argv[idx], "-e") == 0) - { - if(idx + 1 >= argc) + if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + { + usage(argv[0]); + return EXIT_SUCCESS; + } + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + { + cout << ICE_STRING_VERSION << endl; + return EXIT_SUCCESS; + } + else if(strcmp(argv[idx], "-e") == 0) + { + if(idx + 1 >= argc) { - cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; - usage(argv[0]); - return EXIT_FAILURE; + cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; + usage(argv[0]); + return EXIT_FAILURE; } - - commands += argv[idx + 1]; - commands += ';'; + + commands += argv[idx + 1]; + commands += ';'; - for(int i = idx ; i + 2 < argc ; ++i) - { - argv[i] = argv[i + 2]; - } - argc -= 2; - } - else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) - { - debug = true; - for(int i = idx ; i + 1 < argc ; ++i) - { - argv[i] = argv[i + 1]; - } - --argc; - } - else if(argv[idx][0] == '-') - { - cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; - usage(argv[0]); - return EXIT_FAILURE; - } - else - { - ++idx; - } + for(int i = idx ; i + 2 < argc ; ++i) + { + argv[i] = argv[i + 2]; + } + argc -= 2; + } + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + { + debug = true; + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } + else if(argv[idx][0] == '-') + { + cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + else + { + ++idx; + } } if(argc >= 2 && !commands.empty()) { - cerr << argv[0] << ": `-e' option cannot be used if input files are given" << endl; - usage(argv[0]); - return EXIT_FAILURE; + cerr << argv[0] << ": `-e' option cannot be used if input files are given" << endl; + usage(argv[0]); + return EXIT_FAILURE; } LibraryPrx phoneBook = LibraryPrx::checkedCast(communicator->propertyToProxy("Library.Proxy")); if(!phoneBook) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } ParserPtr p = Parser::createParser(phoneBook); @@ -103,43 +103,43 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) if(argc < 2) // No files given { - if(!commands.empty()) // Commands were given - { - int parseStatus = p->parse(commands, debug); - if(parseStatus == EXIT_FAILURE) - { - status = EXIT_FAILURE; - } - } - else // No commands, let's use standard input - { - int parseStatus = p->parse(stdin, debug); - if(parseStatus == EXIT_FAILURE) - { - status = EXIT_FAILURE; - } - } + if(!commands.empty()) // Commands were given + { + int parseStatus = p->parse(commands, debug); + if(parseStatus == EXIT_FAILURE) + { + status = EXIT_FAILURE; + } + } + else // No commands, let's use standard input + { + int parseStatus = p->parse(stdin, debug); + if(parseStatus == EXIT_FAILURE) + { + status = EXIT_FAILURE; + } + } } else // Process files given on the command line { - for(idx = 1 ; idx < argc ; ++idx) - { - FILE* file = fopen(argv[idx], "r"); - if(file == NULL) - { - cerr << argv[0] << ": can't open file `" << argv[idx] << "': " << strerror(errno) << endl; - return EXIT_FAILURE; - } - - int parseStatus = p->parse(file, debug); + for(idx = 1 ; idx < argc ; ++idx) + { + FILE* file = fopen(argv[idx], "r"); + if(file == NULL) + { + cerr << argv[0] << ": can't open file `" << argv[idx] << "': " << strerror(errno) << endl; + return EXIT_FAILURE; + } + + int parseStatus = p->parse(file, debug); - fclose(file); + fclose(file); - if(parseStatus == EXIT_FAILURE) - { - status = EXIT_FAILURE; - } - } + if(parseStatus == EXIT_FAILURE) + { + status = EXIT_FAILURE; + } + } } return status; diff --git a/cpp/demo/Freeze/library/Server.cpp b/cpp/demo/Freeze/library/Server.cpp index a819e74ee1b..fda90db0811 100644 --- a/cpp/demo/Freeze/library/Server.cpp +++ b/cpp/demo/Freeze/library/Server.cpp @@ -18,7 +18,7 @@ class LibraryServer : public Ice::Application public: LibraryServer(const string& envName) : - _envName(envName) + _envName(envName) { } @@ -53,7 +53,7 @@ LibraryServer::run(int argc, char* argv[]) Ice::Int evictorSize = properties->getPropertyAsInt("Library.EvictorSize"); if(evictorSize > 0) { - evictor->setSize(evictorSize); + evictor->setSize(evictorSize); } // diff --git a/cpp/demo/Freeze/phonebook/Client.cpp b/cpp/demo/Freeze/phonebook/Client.cpp index 5f7c3c032a2..d027ae411a0 100644 --- a/cpp/demo/Freeze/phonebook/Client.cpp +++ b/cpp/demo/Freeze/phonebook/Client.cpp @@ -43,15 +43,15 @@ PhoneBookClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/Freeze/phonebook/Collocated.cpp b/cpp/demo/Freeze/phonebook/Collocated.cpp index 6b1efc3c75f..692f33e425e 100644 --- a/cpp/demo/Freeze/phonebook/Collocated.cpp +++ b/cpp/demo/Freeze/phonebook/Collocated.cpp @@ -19,7 +19,7 @@ class PhoneBookCollocated : public Ice::Application public: PhoneBookCollocated(const string& envName) : - _envName(envName) + _envName(envName) { } @@ -82,7 +82,7 @@ PhoneBookCollocated::run(int argc, char* argv[]) Ice::Int evictorSize = properties->getPropertyAsInt("PhoneBook.EvictorSize"); if(evictorSize > 0) { - evictor->setSize(evictorSize); + evictor->setSize(evictorSize); } // @@ -113,15 +113,15 @@ PhoneBookCollocated::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/Freeze/phonebook/Parser.cpp b/cpp/demo/Freeze/phonebook/Parser.cpp index a09f663ceec..a93bab7648d 100644 --- a/cpp/demo/Freeze/phonebook/Parser.cpp +++ b/cpp/demo/Freeze/phonebook/Parser.cpp @@ -52,28 +52,28 @@ Parser::addContacts(const list<string>& args) { if(args.empty()) { - error("`add' requires at least one argument (type `help' for more info)"); - return; + error("`add' requires at least one argument (type `help' for more info)"); + return; } try { - for(list<string>::const_iterator p = args.begin(); p != args.end(); ++p) - { - ContactPrx contact = _phoneBook->createContact(); - contact->setName(*p); - cout << "added new contact for `" << *p << "'" << endl; - } + for(list<string>::const_iterator p = args.begin(); p != args.end(); ++p) + { + ContactPrx contact = _phoneBook->createContact(); + contact->setName(*p); + cout << "added new contact for `" << *p << "'" << endl; + } } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -82,26 +82,26 @@ Parser::findContacts(const list<string>& args) { if(args.size() != 1) { - error("`find' requires exactly one argument (type `help' for more info)"); - return; + error("`find' requires exactly one argument (type `help' for more info)"); + return; } try { - _foundContacts = _phoneBook->findContacts(args.front()); - _current = _foundContacts.begin(); - cout << "number of contacts found: " << _foundContacts.size() << endl; - printCurrent(); + _foundContacts = _phoneBook->findContacts(args.front()); + _current = _foundContacts.begin(); + cout << "number of contacts found: " << _foundContacts.size() << endl; + printCurrent(); } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -110,7 +110,7 @@ Parser::nextFoundContact() { if(_current != _foundContacts.end()) { - ++_current; + ++_current; } printCurrent(); } @@ -120,17 +120,17 @@ Parser::printCurrent() { try { - if(_current != _foundContacts.end()) - { - cout << "current contact is:" << endl; - cout << "name: " << (*_current)->getName() << endl; - cout << "address: " << (*_current)->getAddress() << endl; - cout << "phone: " << (*_current)->getPhone() << endl; - } - else - { - cout << "no current contact" << endl; - } + if(_current != _foundContacts.end()) + { + cout << "current contact is:" << endl; + cout << "name: " << (*_current)->getName() << endl; + cout << "address: " << (*_current)->getAddress() << endl; + cout << "phone: " << (*_current)->getPhone() << endl; + } + else + { + cout << "no current contact" << endl; + } } catch(const Ice::ObjectNotExistException&) { @@ -138,13 +138,13 @@ Parser::printCurrent() } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -153,21 +153,21 @@ Parser::setCurrentName(const list<string>& args) { if(args.size() != 1) { - error("`name' requires exactly one argument (type `help' for more info)"); - return; + error("`name' requires exactly one argument (type `help' for more info)"); + return; } try { - if(_current != _foundContacts.end()) - { - (*_current)->setName(args.front()); - cout << "changed name to `" << args.front() << "'" << endl; - } - else - { - cout << "no current contact" << endl; - } + if(_current != _foundContacts.end()) + { + (*_current)->setName(args.front()); + cout << "changed name to `" << args.front() << "'" << endl; + } + else + { + cout << "no current contact" << endl; + } } catch(const Ice::ObjectNotExistException&) { @@ -175,13 +175,13 @@ Parser::setCurrentName(const list<string>& args) } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -190,21 +190,21 @@ Parser::setCurrentAddress(const list<string>& args) { if(args.size() != 1) { - error("`address' requires exactly one argument (type `help' for more info)"); - return; + error("`address' requires exactly one argument (type `help' for more info)"); + return; } try { - if(_current != _foundContacts.end()) - { - (*_current)->setAddress(args.front()); - cout << "changed address to `" << args.front() << "'" << endl; - } - else - { - cout << "no current contact" << endl; - } + if(_current != _foundContacts.end()) + { + (*_current)->setAddress(args.front()); + cout << "changed address to `" << args.front() << "'" << endl; + } + else + { + cout << "no current contact" << endl; + } } catch(const Ice::ObjectNotExistException&) { @@ -212,13 +212,13 @@ Parser::setCurrentAddress(const list<string>& args) } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -227,21 +227,21 @@ Parser::setCurrentPhone(const list<string>& args) { if(args.size() != 1) { - error("`phone' requires exactly one argument (type `help' for more info)"); - return; + error("`phone' requires exactly one argument (type `help' for more info)"); + return; } try { - if(_current != _foundContacts.end()) - { - (*_current)->setPhone(args.front()); - cout << "changed phone number to `" << args.front() << "'" << endl; - } - else - { - cout << "no current contact" << endl; - } + if(_current != _foundContacts.end()) + { + (*_current)->setPhone(args.front()); + cout << "changed phone number to `" << args.front() << "'" << endl; + } + else + { + cout << "no current contact" << endl; + } } catch(const Ice::ObjectNotExistException&) { @@ -249,13 +249,13 @@ Parser::setCurrentPhone(const list<string>& args) } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -264,15 +264,15 @@ Parser::removeCurrent() { try { - if(_current != _foundContacts.end()) - { - (*_current)->destroy(); - cout << "removed current contact" << endl; - } - else - { - cout << "no current contact" << endl; - } + if(_current != _foundContacts.end()) + { + (*_current)->destroy(); + cout << "removed current contact" << endl; + } + else + { + cout << "no current contact" << endl; + } } catch(const Ice::ObjectNotExistException&) { @@ -280,13 +280,13 @@ Parser::removeCurrent() } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -295,23 +295,23 @@ Parser::setEvictorSize(const list<string>& args) { if(args.size() != 1) { - error("`size' requires exactly one argument (type `help' for more info)"); - return; + error("`size' requires exactly one argument (type `help' for more info)"); + return; } try { - _phoneBook->setEvictorSize(atoi(args.front().c_str())); + _phoneBook->setEvictorSize(atoi(args.front().c_str())); } catch(const DatabaseException& ex) { - error(ex.message); + error(ex.message); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -320,13 +320,13 @@ Parser::shutdown() { try { - _phoneBook->shutdown(); + _phoneBook->shutdown(); } catch(const Ice::Exception& ex) { - ostringstream s; - s << ex; - error(s.str()); + ostringstream s; + s << ex; + error(s.str()); } } @@ -335,105 +335,105 @@ Parser::getInput(char* buf, int& result, int maxSize) { if(!_commands.empty()) { - if(_commands == ";") - { - result = 0; - } - else - { + if(_commands == ";") + { + result = 0; + } + else + { #if defined(_MSC_VER) && !defined(_STLP_MSVC) - // COMPILERBUG: Stupid Visual C++ defines min and max as macros - result = _MIN(maxSize, static_cast<int>(_commands.length())); + // COMPILERBUG: Stupid Visual C++ defines min and max as macros + result = _MIN(maxSize, static_cast<int>(_commands.length())); #else - result = min(maxSize, static_cast<int>(_commands.length())); + result = min(maxSize, static_cast<int>(_commands.length())); #endif - strncpy(buf, _commands.c_str(), result); - _commands.erase(0, result); - if(_commands.empty()) - { - _commands = ";"; - } - } + strncpy(buf, _commands.c_str(), result); + _commands.erase(0, result); + if(_commands.empty()) + { + _commands = ";"; + } + } } else if(isatty(fileno(yyin))) { #ifdef HAVE_READLINE const char* prompt = parser->getPrompt(); - char* line = readline(const_cast<char*>(prompt)); - if(!line) - { - result = 0; - } - else - { - if(*line) - { - add_history(line); - } - - result = strlen(line) + 1; - if(result > maxSize) - { - free(line); - error("input line too long"); - result = 0; - } - else - { - strcpy(buf, line); - strcat(buf, "\n"); - free(line); - } - } + char* line = readline(const_cast<char*>(prompt)); + if(!line) + { + result = 0; + } + else + { + if(*line) + { + add_history(line); + } + + result = strlen(line) + 1; + if(result > maxSize) + { + free(line); + error("input line too long"); + result = 0; + } + else + { + strcpy(buf, line); + strcat(buf, "\n"); + free(line); + } + } #else - cout << parser->getPrompt() << flush; - - string line; - while(true) - { - char c = static_cast<char>(getc(yyin)); - if(c == EOF) - { - if(line.size()) - { - line += '\n'; - } - break; - } - - line += c; - - if(c == '\n') - { - break; - } - } - - result = static_cast<int>(line.length()); - if(result > maxSize) - { - error("input line too long"); - buf[0] = EOF; - result = 1; - } - else - { - strcpy(buf, line.c_str()); - } + cout << parser->getPrompt() << flush; + + string line; + while(true) + { + char c = static_cast<char>(getc(yyin)); + if(c == EOF) + { + if(line.size()) + { + line += '\n'; + } + break; + } + + line += c; + + if(c == '\n') + { + break; + } + } + + result = static_cast<int>(line.length()); + if(result > maxSize) + { + error("input line too long"); + buf[0] = EOF; + result = 1; + } + else + { + strcpy(buf, line.c_str()); + } #endif } else { - if(((result = static_cast<int>(fread(buf, 1, maxSize, yyin))) == 0) && ferror(yyin)) - { - error("input in flex scanner failed"); - buf[0] = EOF; - result = 1; - } + if(((result = static_cast<int>(fread(buf, 1, maxSize, yyin))) == 0) && ferror(yyin)) + { + error("input in flex scanner failed"); + buf[0] = EOF; + result = 1; + } } } @@ -456,12 +456,12 @@ Parser::getPrompt() if(_continue) { - _continue = false; - return "(cont) "; + _continue = false; + return "(cont) "; } else { - return ">>> "; + return ">>> "; } } @@ -470,11 +470,11 @@ Parser::error(const char* s) { if(_commands.empty() && !isatty(fileno(yyin))) { - cerr << _currentFile << ':' << _currentLine << ": " << s << endl; + cerr << _currentFile << ':' << _currentLine << ": " << s << endl; } else { - cerr << "error: " << s << endl; + cerr << "error: " << s << endl; } _errors++; } @@ -490,11 +490,11 @@ Parser::warning(const char* s) { if(_commands.empty() && !isatty(fileno(yyin))) { - cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl; + cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl; } else { - cerr << "warning: " << s << endl; + cerr << "warning: " << s << endl; } } @@ -529,7 +529,7 @@ Parser::parse(FILE* file, bool debug) int status = yyparse(); if(_errors) { - status = EXIT_FAILURE; + status = EXIT_FAILURE; } parser = 0; @@ -561,7 +561,7 @@ Parser::parse(const string& commands, bool debug) int status = yyparse(); if(_errors) { - status = EXIT_FAILURE; + status = EXIT_FAILURE; } parser = 0; diff --git a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp index b58fa5adedb..208eac42620 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp +++ b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp @@ -65,18 +65,18 @@ ContactI::destroy(const Ice::Current& c) { try { - _factory->getEvictor()->remove(c.id); + _factory->getEvictor()->remove(c.id); } catch(const Freeze::DatabaseException& ex) { - DatabaseException e; - e.message = ex.message; - throw e; + DatabaseException e; + e.message = ex.message; + throw e; } } PhoneBookI::PhoneBookI(const Freeze::EvictorPtr& evictor, const ContactFactoryPtr& contactFactory, - const NameIndexPtr& index) : + const NameIndexPtr& index) : _evictor(evictor), _contactFactory(contactFactory), _index(index) @@ -88,13 +88,13 @@ class IdentityToContact public: IdentityToContact(const Ice::ObjectAdapterPtr& adapter) : - _adapter(adapter) + _adapter(adapter) { } - ContactPrx operator()(const Ice::Identity& ident) + ContactPrx operator()(const Ice::Identity& ident) { - return ContactPrx::uncheckedCast(_adapter->createProxy(ident)); + return ContactPrx::uncheckedCast(_adapter->createProxy(ident)); } private: @@ -136,19 +136,19 @@ PhoneBookI::findContacts(const string& name, const Ice::Current& c) const { try { - vector<Ice::Identity> identities = _index->find(name); - - Contacts contacts; - contacts.reserve(identities.size()); - transform(identities.begin(), identities.end(), back_inserter(contacts), IdentityToContact(c.adapter)); + vector<Ice::Identity> identities = _index->find(name); + + Contacts contacts; + contacts.reserve(identities.size()); + transform(identities.begin(), identities.end(), back_inserter(contacts), IdentityToContact(c.adapter)); - return contacts; + return contacts; } catch(const Freeze::DatabaseException& ex) { - DatabaseException e; - e.message = ex.message; - throw e; + DatabaseException e; + e.message = ex.message; + throw e; } } diff --git a/cpp/demo/Freeze/phonebook/RunParser.cpp b/cpp/demo/Freeze/phonebook/RunParser.cpp index eac469e60e1..6fce1244c50 100644 --- a/cpp/demo/Freeze/phonebook/RunParser.cpp +++ b/cpp/demo/Freeze/phonebook/RunParser.cpp @@ -17,13 +17,13 @@ void usage(const char* appName) { cerr << "Usage: " << appName << " [options] [file...]\n"; - cerr << - "Options:\n" - "-h, --help Show this message.\n" - "-v, --version Display the Ice version.\n" - "-e COMMANDS Execute COMMANDS.\n" - "-d, --debug Print debug messages.\n" - ; + cerr << + "Options:\n" + "-h, --help Show this message.\n" + "-v, --version Display the Ice version.\n" + "-e COMMANDS Execute COMMANDS.\n" + "-d, --debug Print debug messages.\n" + ; } int @@ -35,67 +35,67 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) int idx = 1; while(idx < argc) { - if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) - { - usage(argv[0]); - return EXIT_SUCCESS; - } - else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) - { - cout << ICE_STRING_VERSION << endl; - return EXIT_SUCCESS; - } - else if(strcmp(argv[idx], "-e") == 0) - { - if(idx + 1 >= argc) + if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + { + usage(argv[0]); + return EXIT_SUCCESS; + } + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + { + cout << ICE_STRING_VERSION << endl; + return EXIT_SUCCESS; + } + else if(strcmp(argv[idx], "-e") == 0) + { + if(idx + 1 >= argc) { - cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; - usage(argv[0]); - return EXIT_FAILURE; + cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; + usage(argv[0]); + return EXIT_FAILURE; } - - commands += argv[idx + 1]; - commands += ';'; + + commands += argv[idx + 1]; + commands += ';'; - for(int i = idx ; i + 2 < argc ; ++i) - { - argv[i] = argv[i + 2]; - } - argc -= 2; - } - else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) - { - debug = true; - for(int i = idx ; i + 1 < argc ; ++i) - { - argv[i] = argv[i + 1]; - } - --argc; - } - else if(argv[idx][0] == '-') - { - cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; - usage(argv[0]); - return EXIT_FAILURE; - } - else - { - ++idx; - } + for(int i = idx ; i + 2 < argc ; ++i) + { + argv[i] = argv[i + 2]; + } + argc -= 2; + } + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + { + debug = true; + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } + else if(argv[idx][0] == '-') + { + cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + else + { + ++idx; + } } if(argc >= 2 && !commands.empty()) { - cerr << argv[0] << ": `-e' option cannot be used if input files are given" << endl; - usage(argv[0]); - return EXIT_FAILURE; + cerr << argv[0] << ": `-e' option cannot be used if input files are given" << endl; + usage(argv[0]); + return EXIT_FAILURE; } PhoneBookPrx phoneBook = PhoneBookPrx::checkedCast(communicator->propertyToProxy("PhoneBook.Proxy")); if(!phoneBook) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } ParserPtr p = Parser::createParser(phoneBook); @@ -103,43 +103,43 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) if(argc < 2) // No files given { - if(!commands.empty()) // Commands were given - { - int parseStatus = p->parse(commands, debug); - if(parseStatus == EXIT_FAILURE) - { - status = EXIT_FAILURE; - } - } - else // No commands, let's use standard input - { - int parseStatus = p->parse(stdin, debug); - if(parseStatus == EXIT_FAILURE) - { - status = EXIT_FAILURE; - } - } + if(!commands.empty()) // Commands were given + { + int parseStatus = p->parse(commands, debug); + if(parseStatus == EXIT_FAILURE) + { + status = EXIT_FAILURE; + } + } + else // No commands, let's use standard input + { + int parseStatus = p->parse(stdin, debug); + if(parseStatus == EXIT_FAILURE) + { + status = EXIT_FAILURE; + } + } } else // Process files given on the command line { - for(idx = 1 ; idx < argc ; ++idx) - { - FILE* file = fopen(argv[idx], "r"); - if(file == NULL) - { - cerr << argv[0] << ": can't open file `" << argv[idx] << "': " << strerror(errno) << endl; - return EXIT_FAILURE; - } - - int parseStatus = p->parse(file, debug); + for(idx = 1 ; idx < argc ; ++idx) + { + FILE* file = fopen(argv[idx], "r"); + if(file == NULL) + { + cerr << argv[0] << ": can't open file `" << argv[idx] << "': " << strerror(errno) << endl; + return EXIT_FAILURE; + } + + int parseStatus = p->parse(file, debug); - fclose(file); + fclose(file); - if(parseStatus == EXIT_FAILURE) - { - status = EXIT_FAILURE; - } - } + if(parseStatus == EXIT_FAILURE) + { + status = EXIT_FAILURE; + } + } } return status; diff --git a/cpp/demo/Freeze/phonebook/Server.cpp b/cpp/demo/Freeze/phonebook/Server.cpp index e21d25b485d..13f49990880 100644 --- a/cpp/demo/Freeze/phonebook/Server.cpp +++ b/cpp/demo/Freeze/phonebook/Server.cpp @@ -20,7 +20,7 @@ class PhoneBookServer : public Ice::Application public: PhoneBookServer(const string& envName) : - _envName(envName) + _envName(envName) { } @@ -74,7 +74,7 @@ PhoneBookServer::run(int argc, char* argv[]) Ice::Int evictorSize = properties->getPropertyAsInt("PhoneBook.EvictorSize"); if(evictorSize > 0) { - evictor->setSize(evictorSize); + evictor->setSize(evictorSize); } // diff --git a/cpp/demo/Glacier2/callback/CallbackI.cpp b/cpp/demo/Glacier2/callback/CallbackI.cpp index fb9ff794970..24389d5541a 100644 --- a/cpp/demo/Glacier2/callback/CallbackI.cpp +++ b/cpp/demo/Glacier2/callback/CallbackI.cpp @@ -18,14 +18,14 @@ CallbackReceiverI::callback(const Ice::Current&) { #ifdef __xlC__ - // - // The xlC compiler synchronizes cin and cout; to see the messages - // while accepting input through cin, we have to print the messages - // with printf - // + // + // The xlC compiler synchronizes cin and cout; to see the messages + // while accepting input through cin, we have to print the messages + // with printf + // - printf("received callback\n"); - fflush(0); + printf("received callback\n"); + fflush(0); #else cout << "received callback" << endl; #endif @@ -37,11 +37,11 @@ CallbackI::initiateCallback(const CallbackReceiverPrx& proxy, const Ice::Current cout << "initiating callback to: " << current.adapter->getCommunicator()->proxyToString(proxy) << endl; try { - proxy->callback(current.ctx); + proxy->callback(current.ctx); } catch(const Ice::Exception& ex) { - cout << ex << endl; + cout << ex << endl; } } @@ -51,10 +51,10 @@ CallbackI::shutdown(const Ice::Current& c) cout << "shutting down..." << endl; try { - c.adapter->getCommunicator()->shutdown(); + c.adapter->getCommunicator()->shutdown(); } catch(const Ice::Exception& ex) { - cout << ex << endl; + cout << ex << endl; } } diff --git a/cpp/demo/Glacier2/callback/Client.cpp b/cpp/demo/Glacier2/callback/Client.cpp index 063ea984470..c8623250faf 100644 --- a/cpp/demo/Glacier2/callback/Client.cpp +++ b/cpp/demo/Glacier2/callback/Client.cpp @@ -33,16 +33,16 @@ void menu() { cout << - "usage:\n" - "t: invoke callback as twoway\n" - "o: invoke callback as oneway\n" - "O: invoke callback as batch oneway\n" - "f: flush all batch requests\n" - "v: set/reset override context field\n" - "F: set/reset fake category\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: invoke callback as twoway\n" + "o: invoke callback as oneway\n" + "O: invoke callback as batch oneway\n" + "f: flush all batch requests\n" + "v: set/reset override context field\n" + "F: set/reset fake category\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } int @@ -57,38 +57,38 @@ CallbackClient::run(int argc, char* argv[]) Ice::RouterPrx defaultRouter = communicator()->getDefaultRouter(); if(!defaultRouter) { - cerr << argv[0] << ": no default router set" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": no default router set" << endl; + return EXIT_FAILURE; } Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(defaultRouter); if(!router) { - cerr << argv[0] << ": configured router is not a Glacier2 router" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": configured router is not a Glacier2 router" << endl; + return EXIT_FAILURE; } while(true) { - cout << "This demo accepts any user-id / password combination.\n"; + cout << "This demo accepts any user-id / password combination.\n"; - string id; - cout << "user id: " << flush; - cin >> id; + string id; + cout << "user id: " << flush; + cin >> id; - string pw; - cout << "password: " << flush; - cin >> pw; + string pw; + cout << "password: " << flush; + cin >> pw; - try - { - router->createSession(id, pw); - break; - } - catch(const Glacier2::PermissionDeniedException& ex) - { - cout << "permission denied:\n" << ex.reason << endl; - } + try + { + router->createSession(id, pw); + break; + } + catch(const Glacier2::PermissionDeniedException& ex) + { + cout << "permission denied:\n" << ex.reason << endl; + } } Ice::Identity callbackReceiverIdent; @@ -119,97 +119,97 @@ CallbackClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - Ice::Context context; - context["_fwd"] = "t"; - if(!override.empty()) - { - context["_ovrd"] = override; - } - twoway->initiateCallback(twowayR, context); - } - else if(c == 'o') - { - Ice::Context context; - context["_fwd"] = "o"; - if(!override.empty()) - { - context["_ovrd"] = override; - } - oneway->initiateCallback(onewayR, context); - } - else if(c == 'O') - { - Ice::Context context; - context["_fwd"] = "O"; - if(!override.empty()) - { - context["_ovrd"] = override; - } - batchOneway->initiateCallback(onewayR, context); - } - else if(c == 'f') - { - communicator()->flushBatchRequests(); - } - else if(c == 'v') - { - if(override.empty()) + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + Ice::Context context; + context["_fwd"] = "t"; + if(!override.empty()) { - override = "some_value"; - cout << "override context field is now `" << override << "'" << endl; - } - else - { - override.clear(); - cout << "override context field is empty" << endl; - } - } - else if(c == 'F') - { - fake = !fake; - - if(fake) - { - twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_identity(callbackReceiverFakeIdent)); - onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_identity(callbackReceiverFakeIdent)); - } - else - { - twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_identity(callbackReceiverIdent)); - onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_identity(callbackReceiverIdent)); - } - - cout << "callback receiver identity: " << communicator()->identityToString(twowayR->ice_getIdentity()) - << endl; - } - else if(c == 's') - { - twoway->shutdown(); - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + context["_ovrd"] = override; + } + twoway->initiateCallback(twowayR, context); + } + else if(c == 'o') + { + Ice::Context context; + context["_fwd"] = "o"; + if(!override.empty()) + { + context["_ovrd"] = override; + } + oneway->initiateCallback(onewayR, context); + } + else if(c == 'O') + { + Ice::Context context; + context["_fwd"] = "O"; + if(!override.empty()) + { + context["_ovrd"] = override; + } + batchOneway->initiateCallback(onewayR, context); + } + else if(c == 'f') + { + communicator()->flushBatchRequests(); + } + else if(c == 'v') + { + if(override.empty()) + { + override = "some_value"; + cout << "override context field is now `" << override << "'" << endl; + } + else + { + override.clear(); + cout << "override context field is empty" << endl; + } + } + else if(c == 'F') + { + fake = !fake; + + if(fake) + { + twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_identity(callbackReceiverFakeIdent)); + onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_identity(callbackReceiverFakeIdent)); + } + else + { + twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_identity(callbackReceiverIdent)); + onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_identity(callbackReceiverIdent)); + } + + cout << "callback receiver identity: " << communicator()->identityToString(twowayR->ice_getIdentity()) + << endl; + } + else if(c == 's') + { + twoway->shutdown(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && c != 'x'); @@ -221,15 +221,15 @@ CallbackClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/Glacier2/callback/SessionI.cpp b/cpp/demo/Glacier2/callback/SessionI.cpp index 7169270aac9..8bd4a13e769 100644 --- a/cpp/demo/Glacier2/callback/SessionI.cpp +++ b/cpp/demo/Glacier2/callback/SessionI.cpp @@ -14,7 +14,7 @@ using namespace std; bool DummyPermissionsVerifierI::checkPermissions(const string& userId, const string& password, string&, - const Ice::Current&) const + const Ice::Current&) const { cout << "verified user `" << userId << "' with password `" << password << "'" << endl; return true; diff --git a/cpp/demo/Glacier2/chat/ChatSessionI.cpp b/cpp/demo/Glacier2/chat/ChatSessionI.cpp index 33cfe63ad35..21e5c3c5e7e 100755 --- a/cpp/demo/Glacier2/chat/ChatSessionI.cpp +++ b/cpp/demo/Glacier2/chat/ChatSessionI.cpp @@ -44,7 +44,7 @@ ChatRoom::instance() IceUtil::StaticMutex::Lock sync(_instanceMutex); if(!_instance) { - _instance = new ChatRoom; + _instance = new ChatRoom; } return _instance; @@ -64,10 +64,10 @@ ChatRoom::leave(const ChatCallbackPrx& callback) list<ChatCallbackPrx>::iterator p; for(p = _members.begin(); p != _members.end(); ++p) { - if(Ice::proxyIdentityEqual(callback, *p)) - { - break; - } + if(Ice::proxyIdentityEqual(callback, *p)) + { + break; + } } assert(p != _members.end()); @@ -80,13 +80,13 @@ ChatRoom::message(const string& data) const Lock sync(*this); for(list<ChatCallbackPrx>::const_iterator p = _members.begin(); p != _members.end(); ++p) { - try - { - (*p)->message(data); - } - catch(const Ice::LocalException&) - { - } + try + { + (*p)->message(data); + } + catch(const Ice::LocalException&) + { + } } } @@ -101,10 +101,10 @@ ChatSessionI::setCallback(const ChatCallbackPrx& callback, const Ice::Current& c Lock sync(*this); if(!_callback) { - _callback = callback; - ChatRoomPtr chatRoom = ChatRoom::instance(); - chatRoom->message(_userId + " has entered the chat room."); - chatRoom->enter(callback); + _callback = callback; + ChatRoomPtr chatRoom = ChatRoom::instance(); + chatRoom->message(_userId + " has entered the chat room."); + chatRoom->enter(callback); } } @@ -120,10 +120,10 @@ ChatSessionI::destroy(const Ice::Current& current) Lock sync(*this); if(_callback) { - ChatRoomPtr chatRoom = ChatRoom::instance(); - chatRoom->leave(_callback); - _callback = 0; - chatRoom->message(_userId + " has left the chat room."); + ChatRoomPtr chatRoom = ChatRoom::instance(); + chatRoom->leave(_callback); + _callback = 0; + chatRoom->message(_userId + " has left the chat room."); } current.adapter->remove(current.id); } diff --git a/cpp/demo/Glacier2/chat/Client.cpp b/cpp/demo/Glacier2/chat/Client.cpp index 4aadf845f5c..d6c9c46da19 100755 --- a/cpp/demo/Glacier2/chat/Client.cpp +++ b/cpp/demo/Glacier2/chat/Client.cpp @@ -73,16 +73,16 @@ public: { #ifdef __xlC__ - // - // The xlC compiler synchronizes cin and cout; to see the messages - // while accepting input through cin, we have to print the messages - // with printf - // - - printf("%s\n", data.c_str()); - fflush(0); + // + // The xlC compiler synchronizes cin and cout; to see the messages + // while accepting input through cin, we have to print the messages + // with printf + // + + printf("%s\n", data.c_str()); + fflush(0); #else - cout << data << endl; + cout << data << endl; #endif } }; @@ -94,128 +94,128 @@ public: virtual int run(int argc, char* argv[]) { - // - // Since this is an interactive demo we want the custom interrupt - // callback to be called when the process is interrupted. - // - callbackOnInterrupt(); - - { - IceUtil::Mutex::Lock sync(_mutex); - Ice::RouterPrx defaultRouter = communicator()->getDefaultRouter(); - if(!defaultRouter) - { - cerr << argv[0] << ": no default router set" << endl; - return EXIT_FAILURE; - } - - _router = Glacier2::RouterPrx::checkedCast(defaultRouter); - if(!_router) - { - cerr << argv[0] << ": configured router is not a Glacier2 router" << endl; - return EXIT_FAILURE; - } - } - - ChatSessionPrx session; - while(true) - { - cout << "This demo accepts any user-id / password combination.\n"; - - string id; - cout << "user id: " << flush; - getline(cin, id); - id = trim(id); - - string pw; - cout << "password: " << flush; - getline(cin, pw); - pw = trim(pw); - - try - { - session = ChatSessionPrx::uncheckedCast(_router->createSession(id, pw)); - break; - } - catch(const Glacier2::PermissionDeniedException& ex) - { - cout << "permission denied:\n" << ex.reason << endl; - } - } - - { - IceUtil::Mutex::Lock sync(_mutex); - _ping = new SessionPingThread(session, (long)_router->getSessionTimeout() / 2); - _ping->start(); - } - - Ice::Identity callbackReceiverIdent; - callbackReceiverIdent.name = "callbackReceiver"; - callbackReceiverIdent.category = _router->getCategoryForClient(); - - Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Chat.Client"); - ChatCallbackPrx callback = ChatCallbackPrx::uncheckedCast( - adapter->add(new ChatCallbackI, callbackReceiverIdent)); - adapter->activate(); - - session->setCallback(callback); - - menu(); - - try - { - do - { - string s; - cout << "==> "; - getline(cin, s); - s = trim(s); - if(!s.empty()) - { - if(s[0] == '/') - { - if(s == "/quit") - { - break; - } - menu(); - } - else - { - session->say(s); - } - } - } - while(cin.good()); - - cleanup(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - cleanup(); - - return EXIT_FAILURE; - } - return EXIT_SUCCESS; + // + // Since this is an interactive demo we want the custom interrupt + // callback to be called when the process is interrupted. + // + callbackOnInterrupt(); + + { + IceUtil::Mutex::Lock sync(_mutex); + Ice::RouterPrx defaultRouter = communicator()->getDefaultRouter(); + if(!defaultRouter) + { + cerr << argv[0] << ": no default router set" << endl; + return EXIT_FAILURE; + } + + _router = Glacier2::RouterPrx::checkedCast(defaultRouter); + if(!_router) + { + cerr << argv[0] << ": configured router is not a Glacier2 router" << endl; + return EXIT_FAILURE; + } + } + + ChatSessionPrx session; + while(true) + { + cout << "This demo accepts any user-id / password combination.\n"; + + string id; + cout << "user id: " << flush; + getline(cin, id); + id = trim(id); + + string pw; + cout << "password: " << flush; + getline(cin, pw); + pw = trim(pw); + + try + { + session = ChatSessionPrx::uncheckedCast(_router->createSession(id, pw)); + break; + } + catch(const Glacier2::PermissionDeniedException& ex) + { + cout << "permission denied:\n" << ex.reason << endl; + } + } + + { + IceUtil::Mutex::Lock sync(_mutex); + _ping = new SessionPingThread(session, (long)_router->getSessionTimeout() / 2); + _ping->start(); + } + + Ice::Identity callbackReceiverIdent; + callbackReceiverIdent.name = "callbackReceiver"; + callbackReceiverIdent.category = _router->getCategoryForClient(); + + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Chat.Client"); + ChatCallbackPrx callback = ChatCallbackPrx::uncheckedCast( + adapter->add(new ChatCallbackI, callbackReceiverIdent)); + adapter->activate(); + + session->setCallback(callback); + + menu(); + + try + { + do + { + string s; + cout << "==> "; + getline(cin, s); + s = trim(s); + if(!s.empty()) + { + if(s[0] == '/') + { + if(s == "/quit") + { + break; + } + menu(); + } + else + { + session->say(s); + } + } + } + while(cin.good()); + + cleanup(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + cleanup(); + + return EXIT_FAILURE; + } + return EXIT_SUCCESS; } virtual void interruptCallback(int) { - try - { - communicator()->destroy(); - } - catch(const IceUtil::Exception& ex) - { - cerr << appName() << ": " << ex << endl; - } - catch(...) - { - cerr << appName() << ": unknown exception" << endl; - } - exit(EXIT_SUCCESS); + try + { + communicator()->destroy(); + } + catch(const IceUtil::Exception& ex) + { + cerr << appName() << ": " << ex << endl; + } + catch(...) + { + cerr << appName() << ": unknown exception" << endl; + } + exit(EXIT_SUCCESS); } private: @@ -223,45 +223,45 @@ private: void cleanup() { - IceUtil::Mutex::Lock sync(_mutex); - if(_router) - { - try - { - _router->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - // - // Expected: the router closed the connection. - // - } - _router = 0; - } - if(_ping) - { - _ping->destroy(); - _ping->getThreadControl().join(); - _ping = 0; - } + IceUtil::Mutex::Lock sync(_mutex); + if(_router) + { + try + { + _router->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + // + // Expected: the router closed the connection. + // + } + _router = 0; + } + if(_ping) + { + _ping->destroy(); + _ping->getThreadControl().join(); + _ping = 0; + } } void menu() { - cout << "enter /quit to exit." << endl; + cout << "enter /quit to exit." << endl; } string trim(const string& s) { - static const string delims = "\t\r\n "; - string::size_type last = s.find_last_not_of(delims); - if(last != string::npos) - { - return s.substr(s.find_first_not_of(delims), last+1); - } - return s; + static const string delims = "\t\r\n "; + string::size_type last = s.find_last_not_of(delims); + if(last != string::npos) + { + return s.substr(s.find_first_not_of(delims), last+1); + } + return s; } IceUtil::Mutex _mutex; diff --git a/cpp/demo/Glacier2/chat/Server.cpp b/cpp/demo/Glacier2/chat/Server.cpp index e2a26e34c21..53c811a3b64 100755 --- a/cpp/demo/Glacier2/chat/Server.cpp +++ b/cpp/demo/Glacier2/chat/Server.cpp @@ -21,7 +21,7 @@ public: virtual Glacier2::SessionPrx create(const string& userId, const Glacier2::SessionControlPrx&, const Ice::Current& current) { - return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(new ChatSessionI(userId))); + return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(new ChatSessionI(userId))); } }; @@ -32,13 +32,13 @@ public: virtual int run(int, char*[]) { - Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("ChatServer"); - - adapter->add(new ChatSessionManagerI, communicator()->stringToIdentity("ChatSessionManager")); - adapter->activate(); - communicator()->waitForShutdown(); - - return EXIT_SUCCESS; + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("ChatServer"); + + adapter->add(new ChatSessionManagerI, communicator()->stringToIdentity("ChatSessionManager")); + adapter->activate(); + communicator()->waitForShutdown(); + + return EXIT_SUCCESS; } }; diff --git a/cpp/demo/Ice/MFC/client/HelloClient.cpp b/cpp/demo/Ice/MFC/client/HelloClient.cpp index 73d4a30e6f5..cc97e071f20 100644 --- a/cpp/demo/Ice/MFC/client/HelloClient.cpp +++ b/cpp/demo/Ice/MFC/client/HelloClient.cpp @@ -48,9 +48,9 @@ CHelloClientApp::InitInstance() try { int argc = 0; - Ice::InitializationData initData; - initData.properties = Ice::createProperties(); - initData.properties->load("config"); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(); + initData.properties->load("config"); communicator = Ice::initialize(argc, 0, initData); } catch(const IceUtil::Exception& ex) diff --git a/cpp/demo/Ice/MFC/client/stdafx.h b/cpp/demo/Ice/MFC/client/stdafx.h index 81d5a220522..6ad764438f9 100644 --- a/cpp/demo/Ice/MFC/client/stdafx.h +++ b/cpp/demo/Ice/MFC/client/stdafx.h @@ -22,30 +22,30 @@ #endif
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
-#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
+#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
-#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
-#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
-#endif
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
+#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#endif
#if 0
-#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
+#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
-#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
-#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
+#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
+#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#endif
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
@@ -53,9 +53,9 @@ #include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
-#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h> // MFC support for Windows Common Controls
+#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <Ice/Ice.h>
diff --git a/cpp/demo/Ice/MFC/server/HelloServer.cpp b/cpp/demo/Ice/MFC/server/HelloServer.cpp index 064b6e4e0cf..6d60db6f561 100644 --- a/cpp/demo/Ice/MFC/server/HelloServer.cpp +++ b/cpp/demo/Ice/MFC/server/HelloServer.cpp @@ -51,11 +51,11 @@ BOOL CHelloServerApp::InitInstance() try { int argc = 0; - Ice::InitializationData initData; + Ice::InitializationData initData; initData.properties = Ice::createProperties(); - initData.properties->load("config"); + initData.properties->load("config"); log = new LogI; - initData.logger = log; + initData.logger = log; communicator = Ice::initialize(argc, 0, initData); adapter = communicator->createObjectAdapter("Hello"); } diff --git a/cpp/demo/Ice/MFC/server/LogI.cpp b/cpp/demo/Ice/MFC/server/LogI.cpp index a8c18c4e2f5..2e153f952f7 100644 --- a/cpp/demo/Ice/MFC/server/LogI.cpp +++ b/cpp/demo/Ice/MFC/server/LogI.cpp @@ -66,7 +66,7 @@ LogI::message(const string& msg) string line = msg + "\r\n"; if(_hwnd) { - post(line); + post(line); } else { @@ -80,7 +80,7 @@ LogI::setHandle(HWND hwnd) _hwnd = hwnd; if(_hwnd != 0 && !_buffer.empty()) { - post(_buffer); + post(_buffer); _buffer.clear(); } } diff --git a/cpp/demo/Ice/MFC/server/stdafx.h b/cpp/demo/Ice/MFC/server/stdafx.h index 81d5a220522..6ad764438f9 100644 --- a/cpp/demo/Ice/MFC/server/stdafx.h +++ b/cpp/demo/Ice/MFC/server/stdafx.h @@ -22,30 +22,30 @@ #endif
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
-#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
+#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
-#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
-#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
-#endif
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
+#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#endif
#if 0
-#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
+#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
-#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
-#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
+#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
+#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#endif
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
@@ -53,9 +53,9 @@ #include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
-#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h> // MFC support for Windows Common Controls
+#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <Ice/Ice.h>
diff --git a/cpp/demo/Ice/async/Client.cpp b/cpp/demo/Ice/async/Client.cpp index cb3e7e862c0..e164fb18cc3 100644 --- a/cpp/demo/Ice/async/Client.cpp +++ b/cpp/demo/Ice/async/Client.cpp @@ -54,8 +54,8 @@ AsyncClient::run(int argc, char* argv[]) HelloPrx hello = HelloPrx::checkedCast(communicator()->propertyToProxy("Hello.Proxy")); if(!hello) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } menu(); @@ -63,40 +63,40 @@ AsyncClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 'i') - { - hello->sayHello(0); - } - else if(c == 'd') - { - hello->sayHello_async(new AMI_Hello_sayHelloI, 5000); - } - else if(c == 's') - { - hello->shutdown(); - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + try + { + cout << "==> "; + cin >> c; + if(c == 'i') + { + hello->sayHello(0); + } + else if(c == 'd') + { + hello->sayHello_async(new AMI_Hello_sayHelloI, 5000); + } + else if(c == 's') + { + hello->shutdown(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && c != 'x'); @@ -125,10 +125,10 @@ void AsyncClient::menu() { cout << - "usage:\n" - "i: send immediate greeting\n" - "d: send delayed greeting\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "i: send immediate greeting\n" + "d: send delayed greeting\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } diff --git a/cpp/demo/Ice/async/WorkQueue.cpp b/cpp/demo/Ice/async/WorkQueue.cpp index 0493b8087ab..fc506938210 100644 --- a/cpp/demo/Ice/async/WorkQueue.cpp +++ b/cpp/demo/Ice/async/WorkQueue.cpp @@ -25,34 +25,34 @@ WorkQueue::run() while(!_done) { if(_callbacks.size() == 0) - { - _monitor.wait(); - } + { + _monitor.wait(); + } - if(_callbacks.size() != 0) - { - // - // Get next work item. - // - CallbackEntry entry = _callbacks.front(); + if(_callbacks.size() != 0) + { + // + // Get next work item. + // + CallbackEntry entry = _callbacks.front(); - // - // Wait for the amount of time indicated in delay to - // emulate a process that takes a significant period of - // time to complete. - // - _monitor.timedWait(IceUtil::Time::milliSeconds(entry.delay)); + // + // Wait for the amount of time indicated in delay to + // emulate a process that takes a significant period of + // time to complete. + // + _monitor.timedWait(IceUtil::Time::milliSeconds(entry.delay)); - if(!_done) - { - // - // Print greeting and send response. - // - _callbacks.pop_front(); - cout << "Belated Hello World!" << endl; - entry.cb->ice_response(); - } - } + if(!_done) + { + // + // Print greeting and send response. + // + _callbacks.pop_front(); + cout << "Belated Hello World!" << endl; + entry.cb->ice_response(); + } + } } // @@ -79,17 +79,17 @@ WorkQueue::add(const Demo::AMD_Hello_sayHelloPtr& cb, int delay) entry.cb = cb; entry.delay = delay; - if(_callbacks.size() == 0) - { + if(_callbacks.size() == 0) + { _monitor.notify(); - } + } _callbacks.push_back(entry); } else { // - // Destroyed, throw exception. - // + // Destroyed, throw exception. + // cb->ice_exception(Demo::RequestCanceledException()); } } diff --git a/cpp/demo/Ice/async/WorkQueue.h b/cpp/demo/Ice/async/WorkQueue.h index 9147b2f615d..47c3ebf04da 100644 --- a/cpp/demo/Ice/async/WorkQueue.h +++ b/cpp/demo/Ice/async/WorkQueue.h @@ -33,7 +33,7 @@ private: struct CallbackEntry { Demo::AMD_Hello_sayHelloPtr cb; - int delay; + int delay; }; IceUtil::Monitor<IceUtil::Mutex> _monitor; diff --git a/cpp/demo/Ice/bidir/CallbackI.cpp b/cpp/demo/Ice/bidir/CallbackI.cpp index 05c6e288d82..d24888c0dd3 100644 --- a/cpp/demo/Ice/bidir/CallbackI.cpp +++ b/cpp/demo/Ice/bidir/CallbackI.cpp @@ -28,15 +28,15 @@ CallbackSenderI::destroy() IceUtil::ThreadPtr callbackSenderThread; { - IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); - - cout << "destroying callback sender" << endl; - _destroy = true; - - notify(); + IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); + + cout << "destroying callback sender" << endl; + _destroy = true; + + notify(); - callbackSenderThread = _callbackSenderThread; - _callbackSenderThread = 0; // Resolve cyclic dependency. + callbackSenderThread = _callbackSenderThread; + _callbackSenderThread = 0; // Resolve cyclic dependency. } callbackSenderThread->getThreadControl().join(); @@ -66,27 +66,27 @@ CallbackSenderI::run() while(!_destroy) { - timedWait(IceUtil::Time::seconds(2)); + timedWait(IceUtil::Time::seconds(2)); - if(!_destroy && !_clients.empty()) - { - ++_num; - - set<CallbackReceiverPrx>::iterator p = _clients.begin(); - while(p != _clients.end()) - { - try - { - (*p)->callback(_num); - ++p; - } - catch(const Exception& ex) - { - cerr << "removing client `" << _communicator->identityToString((*p)->ice_getIdentity()) << "':\n" - << ex << endl; - _clients.erase(p++); - } - } - } + if(!_destroy && !_clients.empty()) + { + ++_num; + + set<CallbackReceiverPrx>::iterator p = _clients.begin(); + while(p != _clients.end()) + { + try + { + (*p)->callback(_num); + ++p; + } + catch(const Exception& ex) + { + cerr << "removing client `" << _communicator->identityToString((*p)->ice_getIdentity()) << "':\n" + << ex << endl; + _clients.erase(p++); + } + } + } } } diff --git a/cpp/demo/Ice/bidir/CallbackI.h b/cpp/demo/Ice/bidir/CallbackI.h index 2af7a28bce7..e99789bfa31 100644 --- a/cpp/demo/Ice/bidir/CallbackI.h +++ b/cpp/demo/Ice/bidir/CallbackI.h @@ -48,19 +48,19 @@ private: { public: - CallbackSenderThread(const CallbackSenderIPtr& callbackSender) : - _callbackSender(callbackSender) - { - } + CallbackSenderThread(const CallbackSenderIPtr& callbackSender) : + _callbackSender(callbackSender) + { + } - virtual void run() - { - _callbackSender->run(); - } + virtual void run() + { + _callbackSender->run(); + } private: - const CallbackSenderIPtr _callbackSender; + const CallbackSenderIPtr _callbackSender; }; IceUtil::ThreadPtr _callbackSenderThread; diff --git a/cpp/demo/Ice/bidir/Client.cpp b/cpp/demo/Ice/bidir/Client.cpp index a7e8198ab45..9dbd44ab388 100644 --- a/cpp/demo/Ice/bidir/Client.cpp +++ b/cpp/demo/Ice/bidir/Client.cpp @@ -21,7 +21,7 @@ public: virtual void callback(Ice::Int num, const Ice::Current&) { - cout << "received callback #" << num << endl; + cout << "received callback #" << num << endl; } }; @@ -46,8 +46,8 @@ CallbackClient::run(int argc, char* argv[]) CallbackSenderPrx::checkedCast(communicator()->propertyToProxy("Callback.Client.CallbackServer")); if(!server) { - cerr << appName() << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; } Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter(""); diff --git a/cpp/demo/Ice/bidir/Server.cpp b/cpp/demo/Ice/bidir/Server.cpp index a311635864c..170d12ad77d 100644 --- a/cpp/demo/Ice/bidir/Server.cpp +++ b/cpp/demo/Ice/bidir/Server.cpp @@ -38,12 +38,12 @@ CallbackServer::run(int argc, char* argv[]) sender->start(); try { - communicator()->waitForShutdown(); + communicator()->waitForShutdown(); } catch(...) { - sender->destroy(); - throw; + sender->destroy(); + throw; } sender->destroy(); diff --git a/cpp/demo/Ice/callback/CallbackSenderI.cpp b/cpp/demo/Ice/callback/CallbackSenderI.cpp index 302dbecdba4..f50c47e7a32 100644 --- a/cpp/demo/Ice/callback/CallbackSenderI.cpp +++ b/cpp/demo/Ice/callback/CallbackSenderI.cpp @@ -20,11 +20,11 @@ CallbackSenderI::initiateCallback(const CallbackReceiverPrx& proxy, const Curren cout << "initiating callback" << endl; try { - proxy->callback(current.ctx); + proxy->callback(current.ctx); } catch(const Exception& ex) { - cout << ex << endl; + cout << ex << endl; } } @@ -34,10 +34,10 @@ CallbackSenderI::shutdown(const Current& c) cout << "shutting down..." << endl; try { - c.adapter->getCommunicator()->shutdown(); + c.adapter->getCommunicator()->shutdown(); } catch(const Exception& ex) { - cout << ex << endl; + cout << ex << endl; } } diff --git a/cpp/demo/Ice/callback/Client.cpp b/cpp/demo/Ice/callback/Client.cpp index 83959a1e5fe..a68bed47b99 100644 --- a/cpp/demo/Ice/callback/Client.cpp +++ b/cpp/demo/Ice/callback/Client.cpp @@ -20,15 +20,15 @@ public: virtual void callback(const Ice::Current&) { #ifdef __xlC__ - // - // The xlC compiler synchronizes cin and cout; to see the messages - // while accepting input through cin, we have to print the messages - // with printf - // - printf("received callback\n"); - fflush(0); + // + // The xlC compiler synchronizes cin and cout; to see the messages + // while accepting input through cin, we have to print the messages + // with printf + // + printf("received callback\n"); + fflush(0); #else - cout << "received callback" << endl; + cout << "received callback" << endl; #endif } }; @@ -62,12 +62,12 @@ CallbackClient::run(int argc, char* argv[]) callbackOnInterrupt(); CallbackSenderPrx twoway = CallbackSenderPrx::checkedCast( - communicator()->propertyToProxy("Callback.Client.CallbackServer")-> - ice_twoway()->ice_timeout(-1)->ice_secure(false)); + communicator()->propertyToProxy("Callback.Client.CallbackServer")-> + ice_twoway()->ice_timeout(-1)->ice_secure(false)); if(!twoway) { - cerr << appName() << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; } CallbackSenderPrx oneway = CallbackSenderPrx::uncheckedCast(twoway->ice_oneway()); CallbackSenderPrx batchOneway = CallbackSenderPrx::uncheckedCast(twoway->ice_batchOneway()); @@ -79,7 +79,7 @@ CallbackClient::run(int argc, char* argv[]) adapter->activate(); CallbackReceiverPrx twowayR = CallbackReceiverPrx::uncheckedCast( - adapter->createProxy(communicator()->stringToIdentity("callbackReceiver"))); + adapter->createProxy(communicator()->stringToIdentity("callbackReceiver"))); CallbackReceiverPrx onewayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_oneway()); CallbackReceiverPrx datagramR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_datagram()); @@ -91,24 +91,24 @@ CallbackClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - twoway->initiateCallback(twowayR); - } - else if(c == 'o') - { - oneway->initiateCallback(onewayR); - } - else if(c == 'O') - { - batchOneway->initiateCallback(onewayR); - } - else if(c == 'd') - { + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + twoway->initiateCallback(twowayR); + } + else if(c == 'o') + { + oneway->initiateCallback(onewayR); + } + else if(c == 'O') + { + batchOneway->initiateCallback(onewayR); + } + else if(c == 'd') + { if(secure) { cout << "secure datagrams are not supported" << endl; @@ -117,9 +117,9 @@ CallbackClient::run(int argc, char* argv[]) { datagram->initiateCallback(datagramR); } - } - else if(c == 'D') - { + } + else if(c == 'D') + { if(secure) { cout << "secure datagrams are not supported" << endl; @@ -128,57 +128,57 @@ CallbackClient::run(int argc, char* argv[]) { batchDatagram->initiateCallback(datagramR); } - } - else if(c == 'f') - { - communicator()->flushBatchRequests(); - } - else if(c == 'S') - { - secure = !secure; - secureStr = secure ? "s" : ""; - - twoway = CallbackSenderPrx::uncheckedCast(twoway->ice_secure(secure)); - oneway = CallbackSenderPrx::uncheckedCast(oneway->ice_secure(secure)); - batchOneway = CallbackSenderPrx::uncheckedCast(batchOneway->ice_secure(secure)); - datagram = CallbackSenderPrx::uncheckedCast(datagram->ice_secure(secure)); - batchDatagram = CallbackSenderPrx::uncheckedCast(batchDatagram->ice_secure(secure)); - - twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_secure(secure)); - onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_secure(secure)); - datagramR = CallbackReceiverPrx::uncheckedCast(datagramR->ice_secure(secure)); - - if(secure) - { - cout << "secure mode is now on" << endl; - } - else - { - cout << "secure mode is now off" << endl; - } - } - else if(c == 's') - { - twoway->shutdown(); - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + } + else if(c == 'f') + { + communicator()->flushBatchRequests(); + } + else if(c == 'S') + { + secure = !secure; + secureStr = secure ? "s" : ""; + + twoway = CallbackSenderPrx::uncheckedCast(twoway->ice_secure(secure)); + oneway = CallbackSenderPrx::uncheckedCast(oneway->ice_secure(secure)); + batchOneway = CallbackSenderPrx::uncheckedCast(batchOneway->ice_secure(secure)); + datagram = CallbackSenderPrx::uncheckedCast(datagram->ice_secure(secure)); + batchDatagram = CallbackSenderPrx::uncheckedCast(batchDatagram->ice_secure(secure)); + + twowayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_secure(secure)); + onewayR = CallbackReceiverPrx::uncheckedCast(onewayR->ice_secure(secure)); + datagramR = CallbackReceiverPrx::uncheckedCast(datagramR->ice_secure(secure)); + + if(secure) + { + cout << "secure mode is now on" << endl; + } + else + { + cout << "secure mode is now off" << endl; + } + } + else if(c == 's') + { + twoway->shutdown(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && c != 'x'); @@ -190,15 +190,15 @@ CallbackClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -207,15 +207,15 @@ void CallbackClient::menu() { cout << - "usage:\n" - "t: send callback as twoway\n" - "o: send callback as oneway\n" - "O: send callback as batch oneway\n" - "d: send callback as datagram\n" - "D: send callback as batch datagram\n" - "f: flush all batch requests\n" - "S: switch secure mode on/off\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send callback as twoway\n" + "o: send callback as oneway\n" + "O: send callback as batch oneway\n" + "d: send callback as datagram\n" + "D: send callback as batch datagram\n" + "f: flush all batch requests\n" + "S: switch secure mode on/off\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } diff --git a/cpp/demo/Ice/converter/Client.cpp b/cpp/demo/Ice/converter/Client.cpp index 123ad49dc52..3db03370c4f 100644 --- a/cpp/demo/Ice/converter/Client.cpp +++ b/cpp/demo/Ice/converter/Client.cpp @@ -19,12 +19,12 @@ void menu() { cout << - "usage:\n" - "t: send greeting with conversion\n" - "u: send greeting without conversion\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send greeting with conversion\n" + "u: send greeting without conversion\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } int @@ -34,15 +34,15 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator1, const Ice EchoPrx echo1 = EchoPrx::checkedCast(communicator1->propertyToProxy(proxyProperty)); if(!echo1) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } EchoPrx echo2 = EchoPrx::checkedCast(communicator2->propertyToProxy(proxyProperty)); if(!echo2) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } menu(); @@ -52,42 +52,42 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator1, const Ice char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - string ret = echo1->echoString(greeting); - cout << "Received (LATIN-1): \"" << IceUtil::escapeString(ret, "") << '\"' << endl; - } - else if(c == 'u') - { - string ret = echo2->echoString(greeting); - cout << "Received (LATIN-1): \"" << IceUtil::escapeString(ret, "") << '\"' << endl; - } - else if(c == 's') - { - echo1->shutdown(); - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + string ret = echo1->echoString(greeting); + cout << "Received (LATIN-1): \"" << IceUtil::escapeString(ret, "") << '\"' << endl; + } + else if(c == 'u') + { + string ret = echo2->echoString(greeting); + cout << "Received (LATIN-1): \"" << IceUtil::escapeString(ret, "") << '\"' << endl; + } + else if(c == 's') + { + echo1->shutdown(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && c != 'x'); @@ -104,18 +104,18 @@ main(int argc, char* argv[]) try { // - // Create two communicators, one with string converter configured - // and one without. - // + // Create two communicators, one with string converter configured + // and one without. + // Ice::InitializationData initData; initData.stringConverter = new StringConverterI(); - initData.properties = Ice::createProperties(initData.stringConverter); - initData.properties->load("config.client"); + initData.properties = Ice::createProperties(initData.stringConverter); + initData.properties->load("config.client"); communicator1 = Ice::initialize(argc, argv, initData); Ice::InitializationData initData2; - initData2.properties = Ice::createProperties(); - initData2.properties->load("config.client"); + initData2.properties = Ice::createProperties(); + initData2.properties->load("config.client"); communicator2 = Ice::initialize(argc, argv, initData2); status = run(argc, argv, communicator1, communicator2); diff --git a/cpp/demo/Ice/converter/StringConverterI.cpp b/cpp/demo/Ice/converter/StringConverterI.cpp index 0f6a7f3bd64..0da9ee6cdbb 100644 --- a/cpp/demo/Ice/converter/StringConverterI.cpp +++ b/cpp/demo/Ice/converter/StringConverterI.cpp @@ -34,32 +34,32 @@ Demo::StringConverterI::toUTF8(const char* sourceStart, const char* sourceEnd, I { unsigned char byte = sourceStart[i]; if(byte <= 0x7F) - { - if(outputBytesLeft == 0) - { - targetStart = buffer.getMoreBytes(chunkSize, targetStart + chunkSize); - offset = 0; - } + { + if(outputBytesLeft == 0) + { + targetStart = buffer.getMoreBytes(chunkSize, targetStart + chunkSize); + offset = 0; + } - targetStart[offset] = byte; + targetStart[offset] = byte; - ++offset; - --outputBytesLeft; - } - else - { - if(outputBytesLeft <= 1) - { - targetStart = buffer.getMoreBytes(chunkSize, targetStart + chunkSize - outputBytesLeft); - offset = 0; - } + ++offset; + --outputBytesLeft; + } + else + { + if(outputBytesLeft <= 1) + { + targetStart = buffer.getMoreBytes(chunkSize, targetStart + chunkSize - outputBytesLeft); + offset = 0; + } - targetStart[offset] = 0xC0 | ((byte & 0xC0) >> 6); - targetStart[offset + 1] = 0x80 | (byte & 0x3F); + targetStart[offset] = 0xC0 | ((byte & 0xC0) >> 6); + targetStart[offset + 1] = 0x80 | (byte & 0x3F); - offset += 2; - outputBytesLeft -= 2; - } + offset += 2; + outputBytesLeft -= 2; + } } return targetStart + offset; @@ -67,7 +67,7 @@ Demo::StringConverterI::toUTF8(const char* sourceStart, const char* sourceEnd, I void Demo::StringConverterI::fromUTF8(const Ice::Byte* sourceStart, const Ice::Byte* sourceEnd, - string& target) const + string& target) const { size_t inSize = static_cast<size_t>(sourceEnd - sourceStart); target.resize(inSize); @@ -77,21 +77,21 @@ Demo::StringConverterI::fromUTF8(const Ice::Byte* sourceStart, const Ice::Byte* while(i < inSize) { if((sourceStart[i] & 0xC0) == 0xC0) - { - if(i + 1 >= inSize) - { - throw Ice::StringConversionException(__FILE__, __LINE__, "UTF-8 string source exhausted"); - } - target[targetIndex] = (sourceStart[i] & 0x03) << 6; - target[targetIndex] = target[targetIndex] | (sourceStart[i + 1] & 0x3F); - i += 2; - } - else - { - target[targetIndex] = sourceStart[i]; - ++i; - } - ++targetIndex; + { + if(i + 1 >= inSize) + { + throw Ice::StringConversionException(__FILE__, __LINE__, "UTF-8 string source exhausted"); + } + target[targetIndex] = (sourceStart[i] & 0x03) << 6; + target[targetIndex] = target[targetIndex] | (sourceStart[i + 1] & 0x3F); + i += 2; + } + else + { + target[targetIndex] = sourceStart[i]; + ++i; + } + ++targetIndex; } target.resize(targetIndex); diff --git a/cpp/demo/Ice/hello/Client.cpp b/cpp/demo/Ice/hello/Client.cpp index 801a8ebc337..50269cca8af 100644 --- a/cpp/demo/Ice/hello/Client.cpp +++ b/cpp/demo/Ice/hello/Client.cpp @@ -42,11 +42,11 @@ HelloClient::run(int argc, char* argv[]) callbackOnInterrupt(); HelloPrx twoway = HelloPrx::checkedCast( - communicator()->propertyToProxy("Hello.Proxy")->ice_twoway()->ice_timeout(-1)->ice_secure(false)); + communicator()->propertyToProxy("Hello.Proxy")->ice_twoway()->ice_timeout(-1)->ice_secure(false)); if(!twoway) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } HelloPrx oneway = HelloPrx::uncheckedCast(twoway->ice_oneway()); HelloPrx batchOneway = HelloPrx::uncheckedCast(twoway->ice_batchOneway()); @@ -62,133 +62,133 @@ HelloClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - twoway->sayHello(delay); - } - else if(c == 'o') - { - oneway->sayHello(delay); - } - else if(c == 'O') - { - batchOneway->sayHello(delay); - } - else if(c == 'd') - { - if(secure) - { - cout << "secure datagrams are not supported" << endl; - } - else - { - datagram->sayHello(delay); - } - } - else if(c == 'D') - { - if(secure) - { - cout << "secure datagrams are not supported" << endl; - } - else - { - batchDatagram->sayHello(delay); - } - } - else if(c == 'f') - { - communicator()->flushBatchRequests(); - } - else if(c == 'T') - { - if(timeout == -1) - { - timeout = 2000; - } - else - { - timeout = -1; - } - - twoway = HelloPrx::uncheckedCast(twoway->ice_timeout(timeout)); - oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout)); - batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout)); - - if(timeout == -1) - { - cout << "timeout is now switched off" << endl; - } - else - { - cout << "timeout is now set to 2000ms" << endl; - } - } - else if(c == 'P') - { - if(delay == 0) - { - delay = 2500; - } - else - { - delay = 0; - } - - if(delay == 0) - { - cout << "server delay is now disabled" << endl; - } - else - { - cout << "server delay is now set to 2500ms" << endl; - } - } - else if(c == 'S') - { - secure = !secure; - - twoway = HelloPrx::uncheckedCast(twoway->ice_secure(secure)); - oneway = HelloPrx::uncheckedCast(oneway->ice_secure(secure)); - batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_secure(secure)); - datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure)); - batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure)); - - if(secure) - { - cout << "secure mode is now on" << endl; - } - else - { - cout << "secure mode is now off" << endl; - } - } - else if(c == 's') - { - twoway->shutdown(); - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + twoway->sayHello(delay); + } + else if(c == 'o') + { + oneway->sayHello(delay); + } + else if(c == 'O') + { + batchOneway->sayHello(delay); + } + else if(c == 'd') + { + if(secure) + { + cout << "secure datagrams are not supported" << endl; + } + else + { + datagram->sayHello(delay); + } + } + else if(c == 'D') + { + if(secure) + { + cout << "secure datagrams are not supported" << endl; + } + else + { + batchDatagram->sayHello(delay); + } + } + else if(c == 'f') + { + communicator()->flushBatchRequests(); + } + else if(c == 'T') + { + if(timeout == -1) + { + timeout = 2000; + } + else + { + timeout = -1; + } + + twoway = HelloPrx::uncheckedCast(twoway->ice_timeout(timeout)); + oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout)); + batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout)); + + if(timeout == -1) + { + cout << "timeout is now switched off" << endl; + } + else + { + cout << "timeout is now set to 2000ms" << endl; + } + } + else if(c == 'P') + { + if(delay == 0) + { + delay = 2500; + } + else + { + delay = 0; + } + + if(delay == 0) + { + cout << "server delay is now disabled" << endl; + } + else + { + cout << "server delay is now set to 2500ms" << endl; + } + } + else if(c == 'S') + { + secure = !secure; + + twoway = HelloPrx::uncheckedCast(twoway->ice_secure(secure)); + oneway = HelloPrx::uncheckedCast(oneway->ice_secure(secure)); + batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_secure(secure)); + datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure)); + batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure)); + + if(secure) + { + cout << "secure mode is now on" << endl; + } + else + { + cout << "secure mode is now off" << endl; + } + } + else if(c == 's') + { + twoway->shutdown(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && c != 'x'); @@ -200,15 +200,15 @@ HelloClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -217,17 +217,17 @@ void HelloClient::menu() { cout << - "usage:\n" - "t: send greeting as twoway\n" - "o: send greeting as oneway\n" - "O: send greeting as batch oneway\n" - "d: send greeting as datagram\n" - "D: send greeting as batch datagram\n" - "f: flush all batch requests\n" - "T: set a timeout\n" - "P: set server delay\n" - "S: switch secure mode on/off\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send greeting as twoway\n" + "o: send greeting as oneway\n" + "O: send greeting as batch oneway\n" + "d: send greeting as datagram\n" + "D: send greeting as batch datagram\n" + "f: flush all batch requests\n" + "T: set a timeout\n" + "P: set server delay\n" + "S: switch secure mode on/off\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } diff --git a/cpp/demo/Ice/invoke/Client.cpp b/cpp/demo/Ice/invoke/Client.cpp index 3c0bb5bf8c6..e36fb965f31 100644 --- a/cpp/demo/Ice/invoke/Client.cpp +++ b/cpp/demo/Ice/invoke/Client.cpp @@ -304,15 +304,15 @@ InvokeClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/Ice/latency/Client.cpp b/cpp/demo/Ice/latency/Client.cpp index 27347c49dd0..5f59ff10b17 100644 --- a/cpp/demo/Ice/latency/Client.cpp +++ b/cpp/demo/Ice/latency/Client.cpp @@ -34,8 +34,8 @@ LatencyClient::run(int argc, char* argv[]) PingPrx ping = PingPrx::checkedCast(base); if(!ping) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } // Initial ping to setup the connection. @@ -47,7 +47,7 @@ LatencyClient::run(int argc, char* argv[]) cout << "pinging server " << repetitions << " times (this may take a while)" << endl; for(int i = 0; i < repetitions; ++i) { - ping->ice_ping(); + ping->ice_ping(); } tm = IceUtil::Time::now() - tm; diff --git a/cpp/demo/Ice/minimal/Client.cpp b/cpp/demo/Ice/minimal/Client.cpp index 7009383bef6..583379642ef 100644 --- a/cpp/demo/Ice/minimal/Client.cpp +++ b/cpp/demo/Ice/minimal/Client.cpp @@ -21,35 +21,35 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - HelloPrx hello = HelloPrx::checkedCast(communicator->stringToProxy("hello:tcp -p 10000")); - if(!hello) - { - cerr << argv[0] << ": invalid proxy" << endl; - status = EXIT_FAILURE; - } - else - { - hello->sayHello(); - } + communicator = Ice::initialize(argc, argv); + HelloPrx hello = HelloPrx::checkedCast(communicator->stringToProxy("hello:tcp -p 10000")); + if(!hello) + { + cerr << argv[0] << ": invalid proxy" << endl; + status = EXIT_FAILURE; + } + else + { + hello->sayHello(); + } } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/demo/Ice/minimal/Server.cpp b/cpp/demo/Ice/minimal/Server.cpp index dc243ba9e49..6b2e4874689 100644 --- a/cpp/demo/Ice/minimal/Server.cpp +++ b/cpp/demo/Ice/minimal/Server.cpp @@ -20,29 +20,29 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "tcp -p 10000"); - adapter->add(new HelloI, communicator->stringToIdentity("hello")); - adapter->activate(); - communicator->waitForShutdown(); + communicator = Ice::initialize(argc, argv); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "tcp -p 10000"); + adapter->add(new HelloI, communicator->stringToIdentity("hello")); + adapter->activate(); + communicator->waitForShutdown(); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/demo/Ice/nested/Client.cpp b/cpp/demo/Ice/nested/Client.cpp index 12235c1d0ea..30c6edc42f2 100644 --- a/cpp/demo/Ice/nested/Client.cpp +++ b/cpp/demo/Ice/nested/Client.cpp @@ -41,8 +41,8 @@ NestedClient::run(int argc, char* argv[]) NestedPrx nested = NestedPrx::checkedCast(communicator()->propertyToProxy("Nested.Client.NestedServer")); if(!nested) { - cerr << appName() << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; } Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Nested.Client"); @@ -51,28 +51,28 @@ NestedClient::run(int argc, char* argv[]) adapter->activate(); cout << "Note: The maximum nesting level is sz * 2, with sz being\n" - << "the maximum number of threads in the server thread pool. if\n" - << "you specify a value higher than that, the application will\n" - << "block or timeout.\n" - << endl; + << "the maximum number of threads in the server thread pool. if\n" + << "you specify a value higher than that, the application will\n" + << "block or timeout.\n" + << endl; string s; do { - try - { - cout << "enter nesting level or 'x' for exit: "; - cin >> s; - int level = atoi(s.c_str()); - if(level > 0) - { - nested->nestedCall(level, self); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + try + { + cout << "enter nesting level or 'x' for exit: "; + cin >> s; + int level = atoi(s.c_str()); + if(level > 0) + { + nested->nestedCall(level, self); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && s != "x"); @@ -89,15 +89,15 @@ NestedClient::interruptCallback(int) * try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } */ exit(EXIT_SUCCESS); diff --git a/cpp/demo/Ice/nested/NestedI.cpp b/cpp/demo/Ice/nested/NestedI.cpp index 133e34b896a..bb129b6dcdf 100644 --- a/cpp/demo/Ice/nested/NestedI.cpp +++ b/cpp/demo/Ice/nested/NestedI.cpp @@ -25,6 +25,6 @@ NestedI::nestedCall(Int level, const NestedPrx& proxy, const Ice::Current& curre cout << level << endl; if(--level > 0) { - proxy->nestedCall(level, _self, current.ctx); + proxy->nestedCall(level, _self, current.ctx); } } diff --git a/cpp/demo/Ice/session/Client.cpp b/cpp/demo/Ice/session/Client.cpp index 28a0393a1bd..89b05b09c1d 100755 --- a/cpp/demo/Ice/session/Client.cpp +++ b/cpp/demo/Ice/session/Client.cpp @@ -19,42 +19,42 @@ class SessionRefreshThread : public IceUtil::Thread, public IceUtil::Monitor<Ice public: SessionRefreshThread(const Ice::LoggerPtr& logger, const IceUtil::Time& timeout, const SessionPrx& session) : - _logger(logger), - _session(session), - _timeout(timeout), - _terminated(false) + _logger(logger), + _session(session), + _timeout(timeout), + _terminated(false) { } virtual void run() { - Lock sync(*this); - while(!_terminated) - { - timedWait(_timeout); - if(!_terminated) - { - try - { - _session->refresh(); - } - catch(const Ice::Exception& ex) - { - Ice::Warning warn(_logger); - warn << "SessionRefreshThread: " << ex; - _terminated = true; - } - } - } + Lock sync(*this); + while(!_terminated) + { + timedWait(_timeout); + if(!_terminated) + { + try + { + _session->refresh(); + } + catch(const Ice::Exception& ex) + { + Ice::Warning warn(_logger); + warn << "SessionRefreshThread: " << ex; + _terminated = true; + } + } + } } void terminate() { - Lock sync(*this); - _terminated = true; - notify(); + Lock sync(*this); + _terminated = true; + notify(); } private: @@ -109,24 +109,24 @@ SessionClient::run(int argc, char* argv[]) cin >> name; if(!cin.good()) { - return EXIT_FAILURE; + return EXIT_FAILURE; } Ice::ObjectPrx base = communicator()->propertyToProxy("SessionFactory.Proxy"); SessionFactoryPrx factory = SessionFactoryPrx::checkedCast(base); if(!factory) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } { - IceUtil::Mutex::Lock sync(_mutex); - _session = factory->create(name); - - _refresh = new SessionRefreshThread( - communicator()->getLogger(), IceUtil::Time::seconds(5), _session); - _refresh->start(); + IceUtil::Mutex::Lock sync(_mutex); + _session = factory->create(name); + + _refresh = new SessionRefreshThread( + communicator()->getLogger(), IceUtil::Time::seconds(5), _session); + _refresh->start(); } vector<HelloPrx> hellos; @@ -135,85 +135,85 @@ SessionClient::run(int argc, char* argv[]) try { - bool destroy = true; - bool shutdown = false; - while(true) - { - cout << "==> "; - char c; - cin >> c; - if(!cin.good()) - { - break; - } - if(isdigit(c)) - { - string s; - s += c; - vector<HelloPrx>::size_type index = atoi(s.c_str()); - if(index < hellos.size()) - { - hellos[index]->sayHello(); - } - else - { - cout << "Index is too high. " << hellos.size() << " hello objects exist so far.\n" - << "Use `c' to create a new hello object." << endl; - } - } - else if(c == 'c') - { - hellos.push_back(_session->createHello()); - cout << "Created hello object " << hellos.size() - 1 << endl; - } - else if(c == 's') - { - destroy = false; - shutdown = true; - break; - } - else if(c == 'x') - { - break; - } - else if(c == 't') - { - destroy = false; - break; - } - else if(c == '?') - { - menu(); - } - else - { - cout << "Unknown command `" << c << "'." << endl; - menu(); - } - } + bool destroy = true; + bool shutdown = false; + while(true) + { + cout << "==> "; + char c; + cin >> c; + if(!cin.good()) + { + break; + } + if(isdigit(c)) + { + string s; + s += c; + vector<HelloPrx>::size_type index = atoi(s.c_str()); + if(index < hellos.size()) + { + hellos[index]->sayHello(); + } + else + { + cout << "Index is too high. " << hellos.size() << " hello objects exist so far.\n" + << "Use `c' to create a new hello object." << endl; + } + } + else if(c == 'c') + { + hellos.push_back(_session->createHello()); + cout << "Created hello object " << hellos.size() - 1 << endl; + } + else if(c == 's') + { + destroy = false; + shutdown = true; + break; + } + else if(c == 'x') + { + break; + } + else if(c == 't') + { + destroy = false; + break; + } + else if(c == '?') + { + menu(); + } + else + { + cout << "Unknown command `" << c << "'." << endl; + menu(); + } + } - // - // The refresher thread must be terminated before destroy is - // called, otherwise it might get ObjectNotExistException. refresh - // is set to 0 so that if session->destroy() raises an exception - // the thread will not be re-terminated and re-joined. - // - cleanup(destroy); - if(shutdown) - { - factory->shutdown(); - } + // + // The refresher thread must be terminated before destroy is + // called, otherwise it might get ObjectNotExistException. refresh + // is set to 0 so that if session->destroy() raises an exception + // the thread will not be re-terminated and re-joined. + // + cleanup(destroy); + if(shutdown) + { + factory->shutdown(); + } } catch(...) { - try - { - cleanup(true); - } - catch(...) - { - } - throw; + try + { + cleanup(true); + } + catch(...) + { + } + throw; } return EXIT_SUCCESS; @@ -232,15 +232,15 @@ SessionClient::interruptCallback(int) try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -251,15 +251,15 @@ SessionClient::cleanup(bool destroy) IceUtil::Mutex::Lock sync(_mutex); if(_refresh) { - _refresh->terminate(); - _refresh->getThreadControl().join(); - _refresh = 0; + _refresh->terminate(); + _refresh->getThreadControl().join(); + _refresh = 0; } if(destroy && _session) { - _session->destroy(); - _session = 0; + _session->destroy(); + _session = 0; } } @@ -267,11 +267,11 @@ void SessionClient::menu() { cout << - "usage:\n" - "c: create a new per-client hello object\n" - "0-9: send a greeting to a hello object\n" - "s: shutdown the server and exit\n" - "x: exit\n" - "t: exit without destroying the session\n" - "?: help\n"; + "usage:\n" + "c: create a new per-client hello object\n" + "0-9: send a greeting to a hello object\n" + "s: shutdown the server and exit\n" + "x: exit\n" + "t: exit without destroying the session\n" + "?: help\n"; } diff --git a/cpp/demo/Ice/session/ReapThread.cpp b/cpp/demo/Ice/session/ReapThread.cpp index 26d25ff506a..7257bd0994c 100755 --- a/cpp/demo/Ice/session/ReapThread.cpp +++ b/cpp/demo/Ice/session/ReapThread.cpp @@ -25,38 +25,38 @@ ReapThread::run() while(!_terminated) { - timedWait(_timeout); + timedWait(_timeout); - if(!_terminated) - { - list<SessionProxyPair>::iterator p = _sessions.begin(); - while(p != _sessions.end()) - { - try - { - // - // Session destruction may take time in a - // real-world example. Therefore the current time - // is computed for each iteration. - // - if((IceUtil::Time::now() - p->session->timestamp()) > _timeout) - { - string name = p->proxy->getName(); - p->proxy->destroy(); - cout << "The session " << name << " has timed out." << endl; - p = _sessions.erase(p); - } - else - { - ++p; - } - } - catch(const Ice::ObjectNotExistException&) - { - p = _sessions.erase(p); - } - } - } + if(!_terminated) + { + list<SessionProxyPair>::iterator p = _sessions.begin(); + while(p != _sessions.end()) + { + try + { + // + // Session destruction may take time in a + // real-world example. Therefore the current time + // is computed for each iteration. + // + if((IceUtil::Time::now() - p->session->timestamp()) > _timeout) + { + string name = p->proxy->getName(); + p->proxy->destroy(); + cout << "The session " << name << " has timed out." << endl; + p = _sessions.erase(p); + } + else + { + ++p; + } + } + catch(const Ice::ObjectNotExistException&) + { + p = _sessions.erase(p); + } + } + } } } diff --git a/cpp/demo/Ice/session/ReapThread.h b/cpp/demo/Ice/session/ReapThread.h index b7fc1434cf0..f96cf25036a 100755 --- a/cpp/demo/Ice/session/ReapThread.h +++ b/cpp/demo/Ice/session/ReapThread.h @@ -30,10 +30,10 @@ private: bool _terminated; struct SessionProxyPair { - SessionProxyPair(const Demo::SessionPrx& p, const SessionIPtr& s) : - proxy(p), session(s) { } - const Demo::SessionPrx proxy; - const SessionIPtr session; + SessionProxyPair(const Demo::SessionPrx& p, const SessionIPtr& s) : + proxy(p), session(s) { } + const Demo::SessionPrx proxy; + const SessionIPtr session; }; std::list<SessionProxyPair> _sessions; }; diff --git a/cpp/demo/Ice/session/SessionI.cpp b/cpp/demo/Ice/session/SessionI.cpp index d458b4117e4..a0e70e24168 100755 --- a/cpp/demo/Ice/session/SessionI.cpp +++ b/cpp/demo/Ice/session/SessionI.cpp @@ -17,21 +17,21 @@ class HelloI : public Hello public: HelloI(const string& name, int id) : - _name(name), - _id(id) + _name(name), + _id(id) { } virtual ~HelloI() { - cout << "Hello object #" << _id << " for session `" << _name << "' destroyed" << endl; + cout << "Hello object #" << _id << " for session `" << _name << "' destroyed" << endl; } void sayHello(const Ice::Current&) const { - cout << "Hello object #" << _id << " for session `" << _name << "' says:\n" - << "Hello " << _name << "!" << endl; + cout << "Hello object #" << _id << " for session `" << _name << "' says:\n" + << "Hello " << _name << "!" << endl; } private: @@ -55,7 +55,7 @@ SessionI::createHello(const Ice::Current& c) Lock sync(*this); if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } HelloPrx hello = HelloPrx::uncheckedCast(c.adapter->addWithUUID(new HelloI(_name, _nextId++))); @@ -69,7 +69,7 @@ SessionI::refresh(const Ice::Current& c) Lock sync(*this); if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } _timestamp = IceUtil::Time::now(); @@ -81,7 +81,7 @@ SessionI::getName(const Ice::Current&) const Lock sync(*this); if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } return _name; @@ -93,7 +93,7 @@ SessionI::destroy(const Ice::Current& c) Lock sync(*this); if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } _destroy = true; @@ -101,16 +101,16 @@ SessionI::destroy(const Ice::Current& c) cout << "The session " << _name << " is now destroyed." << endl; try { - c.adapter->remove(c.id); - for(list<HelloPrx>::const_iterator p = _objs.begin(); p != _objs.end(); ++p) - { - c.adapter->remove((*p)->ice_getIdentity()); - } + c.adapter->remove(c.id); + for(list<HelloPrx>::const_iterator p = _objs.begin(); p != _objs.end(); ++p) + { + c.adapter->remove((*p)->ice_getIdentity()); + } } catch(const Ice::ObjectAdapterDeactivatedException&) { - // This method is called on shutdown of the server, in which - // case this exception is expected. + // This method is called on shutdown of the server, in which + // case this exception is expected. } _objs.clear(); @@ -122,7 +122,7 @@ SessionI::timestamp() const Lock sync(*this); if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } return _timestamp; } diff --git a/cpp/demo/Ice/throughput/Client.cpp b/cpp/demo/Ice/throughput/Client.cpp index d019e951a19..112eb317177 100644 --- a/cpp/demo/Ice/throughput/Client.cpp +++ b/cpp/demo/Ice/throughput/Client.cpp @@ -47,8 +47,8 @@ ThroughputClient::run(int argc, char* argv[]) ThroughputPrx throughput = ThroughputPrx::checkedCast(base); if(!throughput) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } ThroughputPrx throughputOneway = ThroughputPrx::uncheckedCast(throughput->ice_oneway()); @@ -64,7 +64,7 @@ ThroughputClient::run(int argc, char* argv[]) for(i = 0; i < StringDoubleSeqSize; ++i) { structSeq[i].s = "hello"; - structSeq[i].d = 3.14; + structSeq[i].d = 3.14; } FixedSeq fixedSeq(FixedSeqSize); @@ -88,296 +88,296 @@ ThroughputClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - - IceUtil::Time tm = IceUtil::Time::now(); - const int repetitions = 1000; - - if(c == '1' || c == '2' || c == '3' || c == '4') - { - currentType = c; - switch(c) - { - case '1': - { - cout << "using byte sequences" << endl; - seqSize = ByteSeqSize; - break; - } - - case '2': - { - cout << "using string sequences" << endl; - seqSize = StringSeqSize; - break; - } - - case '3': - { - cout << "using variable-length struct sequences" << endl; - seqSize = StringDoubleSeqSize; - break; - } - - case '4': - { - cout << "using fixed-length struct sequences" << endl; - seqSize = FixedSeqSize; - break; - } - } - } - else if(c == 't' || c == 'o' || c == 'r' || c == 'e') - { - switch(c) - { - case 't': - case 'o': - { - cout << "sending"; - break; - } - - case 'r': - { - cout << "receiving"; - break; - } - - case 'e': - { - cout << "sending and receiving"; - break; - } - } - - cout << ' ' << repetitions; - switch(currentType) - { - case '1': - { - cout << " byte"; - break; - } - - case '2': - { - cout << " string"; - break; - } - - case '3': - { - cout << " variable-length struct"; - break; - } - - case '4': - { - cout << " fixed-length struct"; - break; - } - } - cout << " sequences of size " << seqSize; - - - if(c == 'o') - { - cout << " as oneway"; - } - - cout << "..." << endl; - - for(int i = 0; i < repetitions; ++i) - { - switch(currentType) - { - case '1': - { - switch(c) - { - case 't': - { - throughput->sendByteSeq(byteArr); - break; - } - - case 'o': - { - throughputOneway->sendByteSeq(byteArr); - break; - } - - case 'r': - { - throughput->recvByteSeq(); - break; - } - - case 'e': - { - throughput->echoByteSeq(byteSeq); - break; - } - } - break; - } - - case '2': - { - switch(c) - { - case 't': - { - throughput->sendStringSeq(stringSeq); - break; - } - - case 'o': - { - throughputOneway->sendStringSeq(stringSeq); - break; - } - - case 'r': - { - throughput->recvStringSeq(); - break; - } - - case 'e': - { - throughput->echoStringSeq(stringSeq); - break; - } - } - break; - } - - case '3': - { - switch(c) - { - case 't': - { - throughput->sendStructSeq(structSeq); - break; - } - - case 'o': - { - throughputOneway->sendStructSeq(structSeq); - break; - } - - case 'r': - { - throughput->recvStructSeq(); - break; - } - - case 'e': - { - throughput->echoStructSeq(structSeq); - break; - } - } - break; - } - - case '4': - { - switch(c) - { - case 't': - { - throughput->sendFixedSeq(fixedSeq); - break; - } - - case 'o': - { - throughputOneway->sendFixedSeq(fixedSeq); - break; - } - - case 'r': - { - throughput->recvFixedSeq(); - break; - } - - case 'e': - { - throughput->echoFixedSeq(fixedSeq); - break; - } - } - break; - } - } - } - - tm = IceUtil::Time::now() - tm; - cout << "time for " << repetitions << " sequences: " << tm * 1000 << "ms" << endl; - cout << "time per sequence: " << tm * 1000 / repetitions << "ms" << endl; - int wireSize = 0; - switch(currentType) - { - case '1': - { - wireSize = 1; - break; - } - case '2': - { - wireSize = static_cast<int>(stringSeq[0].size()); - break; - } - case '3': - { - wireSize = static_cast<int>(structSeq[0].s.size()); - wireSize += 8; // Size of double on the wire. - break; - } - case '4': - { - wireSize = 16; // Size of two ints and a double on the wire. - break; - } - } - double mbit = repetitions * seqSize * wireSize * 8.0 / tm.toMicroSeconds(); - if(c == 'e') - { - mbit *= 2; - } - cout << "throughput: " << setprecision(5) << mbit << "Mbps" << endl; - } - else if(c == 's') - { - throughput->shutdown(); - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + try + { + cout << "==> "; + cin >> c; + + IceUtil::Time tm = IceUtil::Time::now(); + const int repetitions = 1000; + + if(c == '1' || c == '2' || c == '3' || c == '4') + { + currentType = c; + switch(c) + { + case '1': + { + cout << "using byte sequences" << endl; + seqSize = ByteSeqSize; + break; + } + + case '2': + { + cout << "using string sequences" << endl; + seqSize = StringSeqSize; + break; + } + + case '3': + { + cout << "using variable-length struct sequences" << endl; + seqSize = StringDoubleSeqSize; + break; + } + + case '4': + { + cout << "using fixed-length struct sequences" << endl; + seqSize = FixedSeqSize; + break; + } + } + } + else if(c == 't' || c == 'o' || c == 'r' || c == 'e') + { + switch(c) + { + case 't': + case 'o': + { + cout << "sending"; + break; + } + + case 'r': + { + cout << "receiving"; + break; + } + + case 'e': + { + cout << "sending and receiving"; + break; + } + } + + cout << ' ' << repetitions; + switch(currentType) + { + case '1': + { + cout << " byte"; + break; + } + + case '2': + { + cout << " string"; + break; + } + + case '3': + { + cout << " variable-length struct"; + break; + } + + case '4': + { + cout << " fixed-length struct"; + break; + } + } + cout << " sequences of size " << seqSize; + + + if(c == 'o') + { + cout << " as oneway"; + } + + cout << "..." << endl; + + for(int i = 0; i < repetitions; ++i) + { + switch(currentType) + { + case '1': + { + switch(c) + { + case 't': + { + throughput->sendByteSeq(byteArr); + break; + } + + case 'o': + { + throughputOneway->sendByteSeq(byteArr); + break; + } + + case 'r': + { + throughput->recvByteSeq(); + break; + } + + case 'e': + { + throughput->echoByteSeq(byteSeq); + break; + } + } + break; + } + + case '2': + { + switch(c) + { + case 't': + { + throughput->sendStringSeq(stringSeq); + break; + } + + case 'o': + { + throughputOneway->sendStringSeq(stringSeq); + break; + } + + case 'r': + { + throughput->recvStringSeq(); + break; + } + + case 'e': + { + throughput->echoStringSeq(stringSeq); + break; + } + } + break; + } + + case '3': + { + switch(c) + { + case 't': + { + throughput->sendStructSeq(structSeq); + break; + } + + case 'o': + { + throughputOneway->sendStructSeq(structSeq); + break; + } + + case 'r': + { + throughput->recvStructSeq(); + break; + } + + case 'e': + { + throughput->echoStructSeq(structSeq); + break; + } + } + break; + } + + case '4': + { + switch(c) + { + case 't': + { + throughput->sendFixedSeq(fixedSeq); + break; + } + + case 'o': + { + throughputOneway->sendFixedSeq(fixedSeq); + break; + } + + case 'r': + { + throughput->recvFixedSeq(); + break; + } + + case 'e': + { + throughput->echoFixedSeq(fixedSeq); + break; + } + } + break; + } + } + } + + tm = IceUtil::Time::now() - tm; + cout << "time for " << repetitions << " sequences: " << tm * 1000 << "ms" << endl; + cout << "time per sequence: " << tm * 1000 / repetitions << "ms" << endl; + int wireSize = 0; + switch(currentType) + { + case '1': + { + wireSize = 1; + break; + } + case '2': + { + wireSize = static_cast<int>(stringSeq[0].size()); + break; + } + case '3': + { + wireSize = static_cast<int>(structSeq[0].s.size()); + wireSize += 8; // Size of double on the wire. + break; + } + case '4': + { + wireSize = 16; // Size of two ints and a double on the wire. + break; + } + } + double mbit = repetitions * seqSize * wireSize * 8.0 / tm.toMicroSeconds(); + if(c == 'e') + { + mbit *= 2; + } + cout << "throughput: " << setprecision(5) << mbit << "Mbps" << endl; + } + else if(c == 's') + { + throughput->shutdown(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && c != 'x'); @@ -389,15 +389,15 @@ ThroughputClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -406,22 +406,22 @@ void ThroughputClient::menu() { cout << - "usage:\n" - "\n" - "toggle type of data to send:\n" - "1: sequence of bytes (default)\n" - "2: sequence of strings (\"hello\")\n" - "3: sequence of structs with a string (\"hello\") and a double\n" - "4: sequence of structs with two ints and a double\n" - "\n" - "select test to run:\n" - "t: Send sequence as twoway\n" - "o: Send sequence as oneway\n" - "r: Receive sequence\n" - "e: Echo (send and receive) sequence\n" - "\n" - "other commands:\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "\n" + "toggle type of data to send:\n" + "1: sequence of bytes (default)\n" + "2: sequence of strings (\"hello\")\n" + "3: sequence of structs with a string (\"hello\") and a double\n" + "4: sequence of structs with two ints and a double\n" + "\n" + "select test to run:\n" + "t: Send sequence as twoway\n" + "o: Send sequence as oneway\n" + "r: Receive sequence\n" + "e: Echo (send and receive) sequence\n" + "\n" + "other commands:\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } diff --git a/cpp/demo/Ice/throughput/ThroughputI.cpp b/cpp/demo/Ice/throughput/ThroughputI.cpp index 68114a2b7bf..beb61966b0b 100644 --- a/cpp/demo/Ice/throughput/ThroughputI.cpp +++ b/cpp/demo/Ice/throughput/ThroughputI.cpp @@ -20,14 +20,14 @@ ThroughputI::ThroughputI() : int i; for(i = 0; i < Demo::StringDoubleSeqSize; ++i) { - _structSeq[i].s = "hello"; - _structSeq[i].d = 3.14; + _structSeq[i].s = "hello"; + _structSeq[i].d = 3.14; } for(i = 0; i < Demo::FixedSeqSize; ++i) { - _fixedSeq[i].i = 0; - _fixedSeq[i].j = 0; - _fixedSeq[i].d = 0; + _fixedSeq[i].i = 0; + _fixedSeq[i].j = 0; + _fixedSeq[i].d = 0; } } diff --git a/cpp/demo/Ice/value/Client.cpp b/cpp/demo/Ice/value/Client.cpp index b072355b87f..e37a48aa349 100644 --- a/cpp/demo/Ice/value/Client.cpp +++ b/cpp/demo/Ice/value/Client.cpp @@ -42,47 +42,47 @@ ValueClient::run(int argc, char* argv[]) InitialPrx initial = InitialPrx::checkedCast(base); if(!initial) { - cerr << argv[0] << ": invalid object reference" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid object reference" << endl; + return EXIT_FAILURE; } char c[2]; cout << '\n' - << "Let's first transfer a simple object, for a class without\n" - << "operations, and print its contents. No factory is required\n" - << "for this.\n" - << "[press enter]\n"; + << "Let's first transfer a simple object, for a class without\n" + << "operations, and print its contents. No factory is required\n" + << "for this.\n" + << "[press enter]\n"; cin.getline(c, 2); SimplePtr simple = initial->getSimple(); cout << "==> " << simple->message << endl; cout << '\n' - << "Yes, this worked. Now let's try to transfer an object for a class\n" - << "with operations as type ::Demo::Printer, without installing a factory first.\n" - << "This should give us a `no factory' exception.\n" - << "[press enter]\n"; + << "Yes, this worked. Now let's try to transfer an object for a class\n" + << "with operations as type ::Demo::Printer, without installing a factory first.\n" + << "This should give us a `no factory' exception.\n" + << "[press enter]\n"; cin.getline(c, 2); PrinterPtr printer; PrinterPrx printerProxy; try { - initial->getPrinter(printer, printerProxy); - cerr << argv[0] << "Did not get the expected NoObjectFactoryException!" << endl; - exit(EXIT_FAILURE); + initial->getPrinter(printer, printerProxy); + cerr << argv[0] << "Did not get the expected NoObjectFactoryException!" << endl; + exit(EXIT_FAILURE); } catch(const Ice::NoObjectFactoryException& ex) { - cout << "==> " << ex << endl; + cout << "==> " << ex << endl; } cout << '\n' - << "Yep, that's what we expected. Now let's try again, but with\n" - << "installing an appropriate factory first. If successful, we print\n" - << "the object's content.\n" - << "[press enter]\n"; + << "Yep, that's what we expected. Now let's try again, but with\n" + << "installing an appropriate factory first. If successful, we print\n" + << "the object's content.\n" + << "[press enter]\n"; cin.getline(c, 2); Ice::ObjectFactoryPtr factory = new ObjectFactory; @@ -92,28 +92,28 @@ ValueClient::run(int argc, char* argv[]) cout << "==> " << printer->message << endl; cout << '\n' - << "Cool, it worked! Let's try calling the printBackwards() method\n" - << "on the object we just received locally.\n" - << "[press enter]\n"; + << "Cool, it worked! Let's try calling the printBackwards() method\n" + << "on the object we just received locally.\n" + << "[press enter]\n"; cin.getline(c, 2); cout << "==> "; printer->printBackwards(); cout << '\n' - << "Now we call the same method, but on the remote object. Watch the\n" - << "server's output.\n" - << "[press enter]\n"; + << "Now we call the same method, but on the remote object. Watch the\n" + << "server's output.\n" + << "[press enter]\n"; cin.getline(c, 2); printerProxy->printBackwards(); cout << '\n' - << "Next, we transfer a derived object from the server as a base\n" - << "object. Since we haven't yet installed a factory for the derived\n" - << "class, the derived class (::Demo::DerivedPrinter) is sliced\n" - << "to its base class (::Demo::Printer).\n" - << "[press enter]\n"; + << "Next, we transfer a derived object from the server as a base\n" + << "object. Since we haven't yet installed a factory for the derived\n" + << "class, the derived class (::Demo::DerivedPrinter) is sliced\n" + << "to its base class (::Demo::Printer).\n" + << "[press enter]\n"; cin.getline(c, 2); PrinterPtr derivedAsBase; @@ -122,10 +122,10 @@ ValueClient::run(int argc, char* argv[]) assert(derivedAsBase->ice_id() == "::Demo::Printer"); cout << '\n' - << "Now we install a factory for the derived class, and try again.\n" - << "Because we receive the derived object as a base object, we\n" - << "we need to do a dynamic_cast<> to get from the base to the derived object.\n" - << "[press enter]\n"; + << "Now we install a factory for the derived class, and try again.\n" + << "Because we receive the derived object as a base object, we\n" + << "we need to do a dynamic_cast<> to get from the base to the derived object.\n" + << "[press enter]\n"; cin.getline(c, 2); communicator()->addObjectFactory(factory, "::Demo::DerivedPrinter"); @@ -137,10 +137,10 @@ ValueClient::run(int argc, char* argv[]) cout << "==> The type ID of the received object is \"" << derived->ice_id() << "\"" << endl; cout << '\n' - << "Let's print the message contained in the derived object, and\n" - << "call the operation printUppercase() on the derived object\n" - << "locally.\n" - << "[press enter]\n"; + << "Let's print the message contained in the derived object, and\n" + << "call the operation printUppercase() on the derived object\n" + << "locally.\n" + << "[press enter]\n"; cin.getline(c, 2); cout << "==> " << derived->derivedMessage << endl; @@ -148,26 +148,26 @@ ValueClient::run(int argc, char* argv[]) derived->printUppercase(); cout << '\n' - << "Finally, we try the same again, but instead of returning the\n" - << "derived object, we throw an exception containing the derived\n" - << "object.\n" - << "[press enter]\n"; + << "Finally, we try the same again, but instead of returning the\n" + << "derived object, we throw an exception containing the derived\n" + << "object.\n" + << "[press enter]\n"; cin.getline(c, 2); try { - initial->throwDerivedPrinter(); - cerr << argv[0] << ": Did not get the expected DerivedPrinterException!" << endl; - exit(EXIT_FAILURE); + initial->throwDerivedPrinter(); + cerr << argv[0] << ": Did not get the expected DerivedPrinterException!" << endl; + exit(EXIT_FAILURE); } catch(const DerivedPrinterException& ex) { - derived = ex.derived; - if(!derived) - { - cerr << argv[0] << "Unexpected null pointer for `derived'" << endl; - exit(EXIT_FAILURE); - } + derived = ex.derived; + if(!derived) + { + cerr << argv[0] << "Unexpected null pointer for `derived'" << endl; + exit(EXIT_FAILURE); + } } cout << "==> " << derived->derivedMessage << endl; @@ -175,7 +175,7 @@ ValueClient::run(int argc, char* argv[]) derived->printUppercase(); cout << '\n' - << "That's it for this demo. Have fun with Ice!\n"; + << "That's it for this demo. Have fun with Ice!\n"; initial->shutdown(); @@ -187,15 +187,15 @@ ValueClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/Ice/value/ObjectFactory.cpp b/cpp/demo/Ice/value/ObjectFactory.cpp index 2156f97448f..8c1ae1a5868 100644 --- a/cpp/demo/Ice/value/ObjectFactory.cpp +++ b/cpp/demo/Ice/value/ObjectFactory.cpp @@ -18,12 +18,12 @@ ObjectFactory::create(const string& type) { if(type == "::Demo::Printer") { - return new PrinterI; + return new PrinterI; } if(type == "::Demo::DerivedPrinter") { - return new DerivedPrinterI; + return new DerivedPrinterI; } assert(false); diff --git a/cpp/demo/IceBox/hello/Client.cpp b/cpp/demo/IceBox/hello/Client.cpp index 279fd041c47..70fc21e6389 100644 --- a/cpp/demo/IceBox/hello/Client.cpp +++ b/cpp/demo/IceBox/hello/Client.cpp @@ -36,16 +36,16 @@ void HelloClient::menu() { cout << - "usage:\n" - "t: send greeting as twoway\n" - "o: send greeting as oneway\n" - "O: send greeting as batch oneway\n" - "d: send greeting as datagram\n" - "D: send greeting as batch datagram\n" - "f: flush all batch requests\n" - "S: switch secure mode on/off\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send greeting as twoway\n" + "o: send greeting as oneway\n" + "O: send greeting as batch oneway\n" + "d: send greeting as datagram\n" + "D: send greeting as batch datagram\n" + "f: flush all batch requests\n" + "S: switch secure mode on/off\n" + "x: exit\n" + "?: help\n"; } int @@ -58,11 +58,11 @@ HelloClient::run(int argc, char* argv[]) callbackOnInterrupt(); HelloPrx twoway = HelloPrx::checkedCast( - communicator()->propertyToProxy("Hello.Proxy")->ice_twoway()->ice_timeout(-1)->ice_secure(false)); + communicator()->propertyToProxy("Hello.Proxy")->ice_twoway()->ice_timeout(-1)->ice_secure(false)); if(!twoway) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } HelloPrx oneway = HelloPrx::uncheckedCast(twoway->ice_oneway()); HelloPrx batchOneway = HelloPrx::uncheckedCast(twoway->ice_batchOneway()); @@ -76,85 +76,85 @@ HelloClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - twoway->sayHello(); - } - else if(c == 'o') - { - oneway->sayHello(); - } - else if(c == 'O') - { - batchOneway->sayHello(); - } - else if(c == 'd') - { - if(secure) - { - cout << "secure datagrams are not supported" << endl; - } - else - { - datagram->sayHello(); - } - } - else if(c == 'D') - { - if(secure) - { - cout << "secure datagrams are not supported" << endl; - } - else - { - batchDatagram->sayHello(); - } - } - else if(c == 'f') - { - communicator()->flushBatchRequests(); - } - else if(c == 'S') - { - secure = !secure; - - twoway = HelloPrx::uncheckedCast(twoway->ice_secure(secure)); - oneway = HelloPrx::uncheckedCast(oneway->ice_secure(secure)); - batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_secure(secure)); - datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure)); - batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure)); - - if(secure) - { - cout << "secure mode is now on" << endl; - } - else - { - cout << "secure mode is now off" << endl; - } - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + twoway->sayHello(); + } + else if(c == 'o') + { + oneway->sayHello(); + } + else if(c == 'O') + { + batchOneway->sayHello(); + } + else if(c == 'd') + { + if(secure) + { + cout << "secure datagrams are not supported" << endl; + } + else + { + datagram->sayHello(); + } + } + else if(c == 'D') + { + if(secure) + { + cout << "secure datagrams are not supported" << endl; + } + else + { + batchDatagram->sayHello(); + } + } + else if(c == 'f') + { + communicator()->flushBatchRequests(); + } + else if(c == 'S') + { + secure = !secure; + + twoway = HelloPrx::uncheckedCast(twoway->ice_secure(secure)); + oneway = HelloPrx::uncheckedCast(oneway->ice_secure(secure)); + batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_secure(secure)); + datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure)); + batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure)); + + if(secure) + { + cout << "secure mode is now on" << endl; + } + else + { + cout << "secure mode is now off" << endl; + } + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && c != 'x'); @@ -166,15 +166,15 @@ HelloClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/IceBox/hello/HelloServiceI.h b/cpp/demo/IceBox/hello/HelloServiceI.h index 15e95fe4b43..50aaaa24584 100644 --- a/cpp/demo/IceBox/hello/HelloServiceI.h +++ b/cpp/demo/IceBox/hello/HelloServiceI.h @@ -24,8 +24,8 @@ public: virtual ~HelloServiceI(); virtual void start(const ::std::string&, - const ::Ice::CommunicatorPtr&, - const ::Ice::StringSeq&); + const ::Ice::CommunicatorPtr&, + const ::Ice::StringSeq&); virtual void stop(); diff --git a/cpp/demo/IceGrid/allocate/Client.cpp b/cpp/demo/IceGrid/allocate/Client.cpp index 16774c94252..7dce0c6a6ae 100644 --- a/cpp/demo/IceGrid/allocate/Client.cpp +++ b/cpp/demo/IceGrid/allocate/Client.cpp @@ -20,7 +20,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::SessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -35,15 +35,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -102,7 +102,7 @@ HelloClient::run(int argc, char* argv[]) callbackOnInterrupt(); IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - communicator()->stringToProxy("DemoIceGrid/Registry")); + communicator()->stringToProxy("DemoIceGrid/Registry")); if(!registry) { cerr << argv[0] << ": could not contact registry" << endl; @@ -111,101 +111,101 @@ HelloClient::run(int argc, char* argv[]) while(true) { - cout << "This demo accepts any user-id / password combination.\n"; + cout << "This demo accepts any user-id / password combination.\n"; - string id; - cout << "user id: " << flush; - getline(cin, id); - id = trim(id); + string id; + cout << "user id: " << flush; + getline(cin, id); + id = trim(id); - string password; - cout << "password: " << flush; - getline(cin, password); - password = trim(password); + string password; + cout << "password: " << flush; + getline(cin, password); + password = trim(password); - try - { - IceUtil::Mutex::Lock sync(_mutex); - _session = registry->createSession(id, password); - break; - } - catch(const IceGrid::PermissionDeniedException& ex) - { - cout << "permission denied:\n" << ex.reason << endl; - } + try + { + IceUtil::Mutex::Lock sync(_mutex); + _session = registry->createSession(id, password); + break; + } + catch(const IceGrid::PermissionDeniedException& ex) + { + cout << "permission denied:\n" << ex.reason << endl; + } } { - IceUtil::Mutex::Lock sync(_mutex); - _keepAlive = new SessionKeepAliveThread(_session, registry->getSessionTimeout() / 2); - _keepAlive->start(); + IceUtil::Mutex::Lock sync(_mutex); + _keepAlive = new SessionKeepAliveThread(_session, registry->getSessionTimeout() / 2); + _keepAlive->start(); } try { - // - // First try to retrieve object by identity, which will work - // if the application-single.xml descriptor is used. Otherwise - // we retrieve object by type, which will succeed if the - // application-multiple.xml descriptor is used. - // - HelloPrx hello; - try - { - hello = HelloPrx::checkedCast(_session->allocateObjectById(communicator()->stringToIdentity("hello"))); - } - catch(const IceGrid::ObjectNotRegisteredException&) - { - hello = HelloPrx::checkedCast(_session->allocateObjectByType("::Demo::Hello")); - } - - menu(); - - char c; - do - { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - hello->sayHello(); - } - else if(c == 's') - { - hello->shutdown(); - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } - } - while(cin.good() && c != 'x'); + // + // First try to retrieve object by identity, which will work + // if the application-single.xml descriptor is used. Otherwise + // we retrieve object by type, which will succeed if the + // application-multiple.xml descriptor is used. + // + HelloPrx hello; + try + { + hello = HelloPrx::checkedCast(_session->allocateObjectById(communicator()->stringToIdentity("hello"))); + } + catch(const IceGrid::ObjectNotRegisteredException&) + { + hello = HelloPrx::checkedCast(_session->allocateObjectByType("::Demo::Hello")); + } + + menu(); + + char c; + do + { + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + hello->sayHello(); + } + else if(c == 's') + { + hello->shutdown(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } + } + while(cin.good() && c != 'x'); } catch(const IceGrid::AllocationException& ex) { - cerr << argv[0] << ": could not allocate object: " << ex.reason << endl; - status = EXIT_FAILURE; + cerr << argv[0] << ": could not allocate object: " << ex.reason << endl; + status = EXIT_FAILURE; } catch(...) { - cerr << "unexpected exception" << endl; - status = EXIT_FAILURE; + cerr << "unexpected exception" << endl; + status = EXIT_FAILURE; } cleanup(); @@ -219,15 +219,15 @@ HelloClient::interruptCallback(int) try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -243,14 +243,14 @@ HelloClient::cleanup() // if(_keepAlive) { - _keepAlive->destroy(); - _keepAlive->getThreadControl().join(); - _keepAlive = 0; + _keepAlive->destroy(); + _keepAlive->getThreadControl().join(); + _keepAlive = 0; } if(_session) { - _session->destroy(); - _session = 0; + _session->destroy(); + _session = 0; } } @@ -258,11 +258,11 @@ void HelloClient::menu() { cout << - "usage:\n" - "t: send greeting\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send greeting\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } string diff --git a/cpp/demo/IceGrid/replication/Client.cpp b/cpp/demo/IceGrid/replication/Client.cpp index 1fc5d816c5d..baabc33bef7 100644 --- a/cpp/demo/IceGrid/replication/Client.cpp +++ b/cpp/demo/IceGrid/replication/Client.cpp @@ -58,8 +58,8 @@ HelloClient::run(int argc, char* argv[]) HelloPrx hello = HelloPrx::checkedCast(obj); if(!hello) { - cerr << argv[0] << ": couldn't find a `::Demo::Hello' object." << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": couldn't find a `::Demo::Hello' object." << endl; + return EXIT_FAILURE; } string s; @@ -92,15 +92,15 @@ HelloClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/IceGrid/sessionActivation/Client.cpp b/cpp/demo/IceGrid/sessionActivation/Client.cpp index f01015892c8..8a120aef9ba 100644 --- a/cpp/demo/IceGrid/sessionActivation/Client.cpp +++ b/cpp/demo/IceGrid/sessionActivation/Client.cpp @@ -20,7 +20,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::SessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -35,15 +35,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -102,7 +102,7 @@ HelloClient::run(int argc, char* argv[]) callbackOnInterrupt(); IceGrid::RegistryPrx registry = - IceGrid::RegistryPrx::checkedCast(communicator()->stringToProxy("DemoIceGrid/Registry")); + IceGrid::RegistryPrx::checkedCast(communicator()->stringToProxy("DemoIceGrid/Registry")); if(!registry) { cerr << argv[0] << ": could not contact registry" << endl; @@ -111,93 +111,93 @@ HelloClient::run(int argc, char* argv[]) while(true) { - cout << "This demo accepts any user-id / password combination.\n"; - - string id; - cout << "user id: " << flush; - getline(cin, id); - id = trim(id); - - string password; - cout << "password: " << flush; - getline(cin, password); - password = trim(password); - - try - { - IceUtil::Mutex::Lock sync(_mutex); - _session = registry->createSession(id, password); - break; - } - catch(const IceGrid::PermissionDeniedException& ex) - { - cout << "permission denied:\n" << ex.reason << endl; - } + cout << "This demo accepts any user-id / password combination.\n"; + + string id; + cout << "user id: " << flush; + getline(cin, id); + id = trim(id); + + string password; + cout << "password: " << flush; + getline(cin, password); + password = trim(password); + + try + { + IceUtil::Mutex::Lock sync(_mutex); + _session = registry->createSession(id, password); + break; + } + catch(const IceGrid::PermissionDeniedException& ex) + { + cout << "permission denied:\n" << ex.reason << endl; + } } { - IceUtil::Mutex::Lock sync(_mutex); - _keepAlive = new SessionKeepAliveThread(_session, registry->getSessionTimeout() / 2); - _keepAlive->start(); + IceUtil::Mutex::Lock sync(_mutex); + _keepAlive = new SessionKeepAliveThread(_session, registry->getSessionTimeout() / 2); + _keepAlive->start(); } try { - HelloPrx hello = HelloPrx::checkedCast(_session->allocateObjectById(communicator()->stringToIdentity("hello"))); - - menu(); - - char c; - do - { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - hello->sayHello(); - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } - } - while(cin.good() && c != 'x'); + HelloPrx hello = HelloPrx::checkedCast(_session->allocateObjectById(communicator()->stringToIdentity("hello"))); + + menu(); + + char c; + do + { + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + hello->sayHello(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } + } + while(cin.good() && c != 'x'); } catch(const IceGrid::AllocationException& ex) { - cerr << argv[0] << ": could not allocate object: " << ex.reason << endl; - status = EXIT_FAILURE; + cerr << argv[0] << ": could not allocate object: " << ex.reason << endl; + status = EXIT_FAILURE; } catch(const IceGrid::ObjectNotRegisteredException&) { - cerr << argv[0] << ": object not registered with registry" << endl; - status = EXIT_FAILURE; + cerr << argv[0] << ": object not registered with registry" << endl; + status = EXIT_FAILURE; } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } catch(...) { - cerr << "unexpected exception" << endl; - status = EXIT_FAILURE; + cerr << "unexpected exception" << endl; + status = EXIT_FAILURE; } cleanup(); @@ -212,15 +212,15 @@ HelloClient::interruptCallback(int) try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -236,14 +236,14 @@ HelloClient::cleanup() // if(_keepAlive) { - _keepAlive->destroy(); - _keepAlive->getThreadControl().join(); - _keepAlive = 0; + _keepAlive->destroy(); + _keepAlive->getThreadControl().join(); + _keepAlive = 0; } if(_session) { - _session->destroy(); - _session = 0; + _session->destroy(); + _session = 0; } } @@ -251,10 +251,10 @@ void HelloClient::menu() { cout << - "usage:\n" - "t: send greeting\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send greeting\n" + "x: exit\n" + "?: help\n"; } string diff --git a/cpp/demo/IceGrid/simple/Client.cpp b/cpp/demo/IceGrid/simple/Client.cpp index 8f8d24029f8..5528bdad6b7 100644 --- a/cpp/demo/IceGrid/simple/Client.cpp +++ b/cpp/demo/IceGrid/simple/Client.cpp @@ -37,11 +37,11 @@ void HelloClient::menu() { cout << - "usage:\n" - "t: send greeting\n" - "s: shutdown server\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send greeting\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; } int @@ -61,17 +61,17 @@ HelloClient::run(int argc, char* argv[]) HelloPrx hello; try { - hello = HelloPrx::checkedCast(communicator()->stringToProxy("hello")); + hello = HelloPrx::checkedCast(communicator()->stringToProxy("hello")); } catch(const Ice::NotRegisteredException&) { - IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast(communicator()->stringToProxy("DemoIceGrid/Query")); - hello = HelloPrx::checkedCast(query->findObjectByType("::Demo::Hello")); + IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast(communicator()->stringToProxy("DemoIceGrid/Query")); + hello = HelloPrx::checkedCast(query->findObjectByType("::Demo::Hello")); } if(!hello) { - cerr << argv[0] << ": couldn't find a `::Demo::Hello' object." << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": couldn't find a `::Demo::Hello' object." << endl; + return EXIT_FAILURE; } menu(); @@ -79,36 +79,36 @@ HelloClient::run(int argc, char* argv[]) char c; do { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - hello->sayHello(); - } - else if(c == 's') - { - hello->shutdown(); - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + hello->sayHello(); + } + else if(c == 's') + { + hello->shutdown(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && c != 'x'); @@ -120,15 +120,15 @@ HelloClient::interruptCallback(int) { try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } diff --git a/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp b/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp index 5aaca0ee731..5f8d6f61acf 100755 --- a/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp +++ b/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp @@ -25,77 +25,77 @@ class DialogPatcherFeedback : public IcePatch2::PatcherFeedback public: DialogPatcherFeedback(CPatchDlg* dialog) : - _dialog(dialog), + _dialog(dialog), _filesPatched(0) { - assert(_dialog); + assert(_dialog); } virtual bool noFileSummary(const string& reason) { - return IDYES == AfxMessageBox(L"Cannot load file summary. Perform a thorough patch?", MB_YESNO|MB_ICONSTOP); + return IDYES == AfxMessageBox(L"Cannot load file summary. Perform a thorough patch?", MB_YESNO|MB_ICONSTOP); } virtual bool checksumStart() { - return _dialog->checksumStart(); + return _dialog->checksumStart(); } virtual bool checksumProgress(const string& path) { - return _dialog->checksumProgress(path); + return _dialog->checksumProgress(path); } virtual bool checksumEnd() { - return _dialog->checksumEnd(); + return _dialog->checksumEnd(); } virtual bool fileListStart() { - return _dialog->fileListStart(); + return _dialog->fileListStart(); } virtual bool fileListProgress(Ice::Int percent) { - return _dialog->fileListProgress(percent); + return _dialog->fileListProgress(percent); } virtual bool fileListEnd() { - return _dialog->fileListEnd(); + return _dialog->fileListEnd(); } virtual bool patchStart(const string& path, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize) { - return _dialog->patchStart(path, size, totalProgress, totalSize); + return _dialog->patchStart(path, size, totalProgress, totalSize); } virtual bool patchProgress(Ice::Long progress, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize) { - return _dialog->patchProgress(progress, size, totalProgress, totalSize); + return _dialog->patchProgress(progress, size, totalProgress, totalSize); } virtual bool patchEnd() { - ++_filesPatched; - return _dialog->patchEnd(); + ++_filesPatched; + return _dialog->patchEnd(); } virtual int filesPatched() const { - return _filesPatched; + return _filesPatched; } private: @@ -181,10 +181,10 @@ CPatchDlg::patchStart(const string& path, Ice::Long size, Ice::Long totalProgres { if(!_isPatch) { - _startTime = IceUtil::Time::now(); - _status->SetWindowText(CString(L" Patching...")); - _speed->SetWindowText(CString(L" 0.0 KB/s")); - _isPatch = true; + _startTime = IceUtil::Time::now(); + _status->SetWindowText(CString(L" Patching...")); + _speed->SetWindowText(CString(L" 0.0 KB/s")); + _isPatch = true; } CString file; @@ -200,15 +200,15 @@ CPatchDlg::patchProgress(Ice::Long, Ice::Long, Ice::Long totalProgress, Ice::Lon IceUtil::Time elapsed = IceUtil::Time::now() - _startTime; if(elapsed.toSeconds() > 0) { - CString speed; - speed.Format(L" %s/s", convertSize(totalProgress / elapsed.toSeconds())); - _speed->SetWindowText(speed); + CString speed; + speed.Format(L" %s/s", convertSize(totalProgress / elapsed.toSeconds())); + _speed->SetWindowText(speed); } int pcnt = 100; if(totalSize > 0) { - pcnt = static_cast<int>(totalProgress * 100 / totalSize); + pcnt = static_cast<int>(totalProgress * 100 / totalSize); } CString percent; percent.Format(L"%d%%", pcnt); @@ -339,18 +339,18 @@ CPatchDlg::OnSelectDir() LPITEMIDLIST pidl = SHBrowseForFolder(&info); if(pidl != 0) { - // + // // Get the name of the selected folder. - // + // TCHAR path[MAX_PATH]; if(SHGetPathFromIDList(pidl, path)) { - _path->SetWindowText(path); + _path->SetWindowText(path); } - // + // // Free up memory used. - // + // IMalloc * imalloc = 0; if(SUCCEEDED(SHGetMalloc(&imalloc))) { @@ -365,61 +365,61 @@ CPatchDlg::OnStartPatch() { try { - Ice::PropertiesPtr properties = _communicator->getProperties(); - - // - // Set the patch directory. - // - CString path; - _path->GetWindowText(path); - if(path.IsEmpty()) - { - AfxMessageBox(CString(L"Please select a patch directory."), MB_OK|MB_ICONEXCLAMATION); - return; - } - properties->setProperty("IcePatch2.Directory", IceUtil::wstringToString(wstring(path))); - - // - // Set the thorough patch flag. - // - string thorough = _thorough->GetCheck() == BST_CHECKED ? "1" : "0"; - properties->setProperty("IcePatch2.Thorough", thorough); - - // - // Set the remove orphan flag. - // - string remove = _remove->GetCheck() == BST_CHECKED ? "1" : "0"; - properties->setProperty("IcePatch2.Remove", remove); + Ice::PropertiesPtr properties = _communicator->getProperties(); + + // + // Set the patch directory. + // + CString path; + _path->GetWindowText(path); + if(path.IsEmpty()) + { + AfxMessageBox(CString(L"Please select a patch directory."), MB_OK|MB_ICONEXCLAMATION); + return; + } + properties->setProperty("IcePatch2.Directory", IceUtil::wstringToString(wstring(path))); + + // + // Set the thorough patch flag. + // + string thorough = _thorough->GetCheck() == BST_CHECKED ? "1" : "0"; + properties->setProperty("IcePatch2.Thorough", thorough); + + // + // Set the remove orphan flag. + // + string remove = _remove->GetCheck() == BST_CHECKED ? "1" : "0"; + properties->setProperty("IcePatch2.Remove", remove); DialogPatcherFeedbackPtr feedback = new DialogPatcherFeedback(this); - IcePatch2::PatcherPtr patcher = new IcePatch2::Patcher(_communicator, feedback); - - // - // Disable a few controls during the patch process. - // - _path->EnableWindow(false); - _select->EnableWindow(false); - _thorough->EnableWindow(false); - _remove->EnableWindow(false); - _start->EnableWindow(false); - - // - // Patch - // - bool aborted = !patcher->prepare(); - if(!aborted) - { - aborted = !patcher->patch(""); - } - if(!aborted) - { - patcher->finish(); - } - - // - // Reset and indicate the completion status. - // - reset(aborted ? L" Aborted" : L" Completed"); + IcePatch2::PatcherPtr patcher = new IcePatch2::Patcher(_communicator, feedback); + + // + // Disable a few controls during the patch process. + // + _path->EnableWindow(false); + _select->EnableWindow(false); + _thorough->EnableWindow(false); + _remove->EnableWindow(false); + _start->EnableWindow(false); + + // + // Patch + // + bool aborted = !patcher->prepare(); + if(!aborted) + { + aborted = !patcher->patch(""); + } + if(!aborted) + { + patcher->finish(); + } + + // + // Reset and indicate the completion status. + // + reset(aborted ? L" Aborted" : L" Completed"); } catch(const IceUtil::Exception& ex) { @@ -500,24 +500,24 @@ CPatchDlg::convertSize(Ice::Long size) const } else { - final = start / megabyte; - if(final >= 1) - { - units = L"MB"; - } - else - { - final = start / kilobyte; - if(final >= 1) - { - units = L"KB"; - } - else - { - final = start; - units = L"B"; - } - } + final = start / megabyte; + if(final >= 1) + { + units = L"MB"; + } + else + { + final = start / kilobyte; + if(final >= 1) + { + units = L"KB"; + } + else + { + final = start; + units = L"B"; + } + } } CString convert; diff --git a/cpp/demo/IcePatch2/MFC/stdafx.h b/cpp/demo/IcePatch2/MFC/stdafx.h index ea41685f994..b9072540cc6 100755 --- a/cpp/demo/IcePatch2/MFC/stdafx.h +++ b/cpp/demo/IcePatch2/MFC/stdafx.h @@ -21,30 +21,30 @@ #endif #ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. -#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. +#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. +#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif -#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. -#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. -#endif +#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. +#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. +#endif #if 0 -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. #endif -#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. -#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. +#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. +#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. #endif #endif -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit // turns off MFC's hiding of some common and often safely ignored warning messages #define _AFX_ALL_WARNINGS @@ -52,9 +52,9 @@ #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions -#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls +#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #ifndef _AFX_NO_AFXCMN_SUPPORT -#include <afxcmn.h> // MFC support for Windows Common Controls +#include <afxcmn.h> // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT #include <Ice/Ice.h> diff --git a/cpp/demo/IceStorm/clock/Publisher.cpp b/cpp/demo/IceStorm/clock/Publisher.cpp index c779a97e0c7..166a2c8c3fa 100644 --- a/cpp/demo/IceStorm/clock/Publisher.cpp +++ b/cpp/demo/IceStorm/clock/Publisher.cpp @@ -52,22 +52,22 @@ Publisher::run(int argc, char* argv[]) } catch(const IceUtil::BadOptException& e) { - cerr << argv[0] << ": " << e.reason << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": " << e.reason << endl; + return EXIT_FAILURE; } IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( - communicator()->propertyToProxy("IceStorm.TopicManager.Proxy")); + communicator()->propertyToProxy("IceStorm.TopicManager.Proxy")); if(!manager) { - cerr << appName() << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; } string topicName = "time"; if(!remaining.empty()) { - topicName = remaining.front(); + topicName = remaining.front(); } // @@ -76,19 +76,19 @@ Publisher::run(int argc, char* argv[]) IceStorm::TopicPrx topic; try { - topic = manager->retrieve(topicName); + topic = manager->retrieve(topicName); } catch(const IceStorm::NoSuchTopic&) { - try - { - topic = manager->create(topicName); - } - catch(const IceStorm::TopicExists&) - { - cerr << appName() << ": temporary failure. try again." << endl; - return EXIT_FAILURE; - } + try + { + topic = manager->create(topicName); + } + catch(const IceStorm::TopicExists&) + { + cerr << appName() << ": temporary failure. try again." << endl; + return EXIT_FAILURE; + } } // @@ -99,38 +99,38 @@ Publisher::run(int argc, char* argv[]) int optsSet = 0; if(opts.isSet("datagram")) { - publisher = publisher->ice_datagram(); - ++optsSet; + publisher = publisher->ice_datagram(); + ++optsSet; } else if(opts.isSet("twoway")) { - // Do nothing. - ++optsSet; + // Do nothing. + ++optsSet; } else if(opts.isSet("oneway") || optsSet == 0) { - publisher = publisher->ice_oneway(); - ++optsSet; + publisher = publisher->ice_oneway(); + ++optsSet; } if(optsSet != 1) { - usage(appName()); - return EXIT_FAILURE; + usage(appName()); + return EXIT_FAILURE; } ClockPrx clock = ClockPrx::uncheckedCast(publisher); cout << "publishing tick events. Press ^C to terminate the application." << endl; try { - while(true) - { - clock->tick(IceUtil::Time::now().toDateTime()); + while(true) + { + clock->tick(IceUtil::Time::now().toDateTime()); IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); - } + } } catch(const Ice::CommunicatorDestroyedException&) { - // Ignore + // Ignore } return EXIT_SUCCESS; diff --git a/cpp/demo/IceStorm/clock/Subscriber.cpp b/cpp/demo/IceStorm/clock/Subscriber.cpp index f6082fef192..abc593c8b0b 100644 --- a/cpp/demo/IceStorm/clock/Subscriber.cpp +++ b/cpp/demo/IceStorm/clock/Subscriber.cpp @@ -25,7 +25,7 @@ public: virtual void tick(const string& time, const Ice::Current&) { - cout << time << endl; + cout << time << endl; } }; @@ -66,41 +66,41 @@ Subscriber::run(int argc, char* argv[]) } catch(const IceUtil::BadOptException& e) { - cerr << argv[0] << ": " << e.reason << endl; - usage(appName()); - return EXIT_FAILURE; + cerr << argv[0] << ": " << e.reason << endl; + usage(appName()); + return EXIT_FAILURE; } IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( - communicator()->propertyToProxy("IceStorm.TopicManager.Proxy")); + communicator()->propertyToProxy("IceStorm.TopicManager.Proxy")); if(!manager) { - cerr << appName() << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; } string topicName = "time"; if(!remaining.empty()) { - topicName = remaining.front(); + topicName = remaining.front(); } IceStorm::TopicPrx topic; try { - topic = manager->retrieve(topicName); + topic = manager->retrieve(topicName); } catch(const IceStorm::NoSuchTopic&) { - try - { - topic = manager->create(topicName); - } - catch(const IceStorm::TopicExists&) - { - cerr << appName() << ": temporary failure. try again." << endl; - return EXIT_FAILURE; - } + try + { + topic = manager->create(topicName); + } + catch(const IceStorm::TopicExists&) + { + cerr << appName() << ": temporary failure. try again." << endl; + return EXIT_FAILURE; + } } Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Clock.Subscriber"); @@ -116,47 +116,47 @@ Subscriber::run(int argc, char* argv[]) int optsSet = 0; if(opts.isSet("datagram")) { - subscriber = subscriber->ice_datagram(); - ++optsSet; + subscriber = subscriber->ice_datagram(); + ++optsSet; } if(opts.isSet("twoway")) { - // Do nothing to the subscriber proxy. Its already twoway. - ++optsSet; + // Do nothing to the subscriber proxy. Its already twoway. + ++optsSet; } if(opts.isSet("ordered")) { - qos["reliability"] = "ordered"; - // Do nothing to the subscriber proxy. Its already twoway. - ++optsSet; + qos["reliability"] = "ordered"; + // Do nothing to the subscriber proxy. Its already twoway. + ++optsSet; } if(opts.isSet("oneway") || optsSet == 0) { - subscriber = subscriber->ice_oneway(); - ++optsSet; + subscriber = subscriber->ice_oneway(); + ++optsSet; } if(optsSet != 1) { - usage(appName()); - return EXIT_FAILURE; + usage(appName()); + return EXIT_FAILURE; } if(opts.isSet("batch")) { - if(opts.isSet("twoway") || opts.isSet("ordered")) - { - cerr << appName() << ": batch can only be set with oneway or datagram" << endl; - return EXIT_FAILURE; - } - if(opts.isSet("datagram")) - { - subscriber = subscriber->ice_batchDatagram(); - } - else - { - subscriber = subscriber->ice_batchOneway(); - } + if(opts.isSet("twoway") || opts.isSet("ordered")) + { + cerr << appName() << ": batch can only be set with oneway or datagram" << endl; + return EXIT_FAILURE; + } + if(opts.isSet("datagram")) + { + subscriber = subscriber->ice_batchDatagram(); + } + else + { + subscriber = subscriber->ice_batchOneway(); + } } topic->subscribeAndGetPublisher(qos, subscriber); diff --git a/cpp/demo/IceStorm/counter/Client.cpp b/cpp/demo/IceStorm/counter/Client.cpp index 82fa66270c0..863b90f9bcd 100644 --- a/cpp/demo/IceStorm/counter/Client.cpp +++ b/cpp/demo/IceStorm/counter/Client.cpp @@ -40,15 +40,15 @@ Client::run(int argc, char* argv[]) string proxy = properties->getProperty(proxyProperty); if(proxy.empty()) { - cerr << appName() << ": property `" << proxyProperty << "' not set" << endl; - return EXIT_FAILURE; + cerr << appName() << ": property `" << proxyProperty << "' not set" << endl; + return EXIT_FAILURE; } CounterPrx counter = CounterPrx::uncheckedCast(communicator()->stringToProxy(proxy)); if(!counter) { - cerr << appName() << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; } MTPrinterPtr printer = new MTPrinter(); @@ -65,36 +65,36 @@ Client::run(int argc, char* argv[]) char c; do { - try - { - printer->print("==> "); - cin >> c; - if(c == 'i') - { - counter->inc(1); - } - else if(c == 'd') - { - counter->inc(-1); - } - else if(c == 'x') - { - // Nothing to do - } - else if(c == '?') - { - menu(printer); - } - else - { - cout << "unknown command `" << c << "'" << endl; - menu(printer); - } - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - } + try + { + printer->print("==> "); + cin >> c; + if(c == 'i') + { + counter->inc(1); + } + else if(c == 'd') + { + counter->inc(-1); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(printer); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(printer); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } } while(cin.good() && c != 'x'); @@ -107,9 +107,9 @@ void Client::menu(const MTPrinterPtr& printer) { printer->print( - "usage:\n" - "i: increment the counter\n" - "d: decrement the counter\n" - "x: exit\n" - "?: help\n"); + "usage:\n" + "i: increment the counter\n" + "d: decrement the counter\n" + "x: exit\n" + "?: help\n"); } diff --git a/cpp/demo/IceStorm/counter/CounterI.cpp b/cpp/demo/IceStorm/counter/CounterI.cpp index 9391cec441f..ff9fad3d1f2 100644 --- a/cpp/demo/IceStorm/counter/CounterI.cpp +++ b/cpp/demo/IceStorm/counter/CounterI.cpp @@ -32,7 +32,7 @@ CounterI::subscribe(const CounterObserverPrx& observer, const Ice::Current&) // the given subscriber. // CounterObserverPrx o = CounterObserverPrx::uncheckedCast( - _topic->subscribeAndGetPublisher(IceStorm::QoS(), observer)); + _topic->subscribeAndGetPublisher(IceStorm::QoS(), observer)); o->init(_value); } diff --git a/cpp/demo/IceStorm/counter/Server.cpp b/cpp/demo/IceStorm/counter/Server.cpp index 33bbcb4c8aa..838b7d11efa 100644 --- a/cpp/demo/IceStorm/counter/Server.cpp +++ b/cpp/demo/IceStorm/counter/Server.cpp @@ -40,33 +40,33 @@ Server::run(int argc, char* argv[]) string proxy = properties->getProperty(proxyProperty); if(proxy.empty()) { - cerr << appName() << ": property `" << proxyProperty << "' not set" << endl; - return EXIT_FAILURE; + cerr << appName() << ": property `" << proxyProperty << "' not set" << endl; + return EXIT_FAILURE; } IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(communicator()->stringToProxy(proxy)); if(!manager) { - cerr << appName() << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << appName() << ": invalid proxy" << endl; + return EXIT_FAILURE; } IceStorm::TopicPrx topic; try { - topic = manager->retrieve("counter"); + topic = manager->retrieve("counter"); } catch(const IceStorm::NoSuchTopic&) { - try - { - topic = manager->create("counter"); - } - catch(const IceStorm::TopicExists&) - { - cerr << appName() << ": topic exists, please try again." << endl; - return EXIT_FAILURE; - } + try + { + topic = manager->create("counter"); + } + catch(const IceStorm::TopicExists&) + { + cerr << appName() << ": topic exists, please try again." << endl; + return EXIT_FAILURE; + } } // diff --git a/cpp/demo/IceStorm/replicated/Publisher.cpp b/cpp/demo/IceStorm/replicated/Publisher.cpp index c1d1d1ec52b..cf432841e02 100644 --- a/cpp/demo/IceStorm/replicated/Publisher.cpp +++ b/cpp/demo/IceStorm/replicated/Publisher.cpp @@ -54,7 +54,7 @@ Publisher::run(int argc, char* argv[]) catch(const IceStorm::NoSuchTopic&) { cerr << appName() << ": topics not created yet, run subscriber." << endl; - return EXIT_FAILURE; + return EXIT_FAILURE; } // diff --git a/cpp/demo/IceStorm/replicated/Subscriber.cpp b/cpp/demo/IceStorm/replicated/Subscriber.cpp index 8755650cf9f..a6fbc11e35d 100644 --- a/cpp/demo/IceStorm/replicated/Subscriber.cpp +++ b/cpp/demo/IceStorm/replicated/Subscriber.cpp @@ -72,34 +72,34 @@ Subscriber::run(int argc, char* argv[]) Ice::ObjectProxySeq::const_iterator p; for(p = managers.begin(); p != managers.end(); ++p) { - // - // Add a Servant for the Ice Object. - // - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(*p); + // + // Add a Servant for the Ice Object. + // + IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(*p); - try - { + try + { topic = manager->retrieve(topicName); - } - catch(const IceStorm::NoSuchTopic&) - { - try - { - topic = manager->create(topicName); - } - catch(const IceStorm::TopicExists&) - { - cerr << appName() << ": temporary failure. try again." << endl; - return EXIT_FAILURE; - } - } + } + catch(const IceStorm::NoSuchTopic&) + { + try + { + topic = manager->create(topicName); + } + catch(const IceStorm::TopicExists&) + { + cerr << appName() << ": temporary failure. try again." << endl; + return EXIT_FAILURE; + } + } } Ice::ObjectProxySeq topics = query->findAllReplicas(topic); for(p = topics.begin(); p != topics.end(); ++p) { topic = IceStorm::TopicPrx::uncheckedCast(*p); - topic->subscribeAndGetPublisher(IceStorm::QoS(), clock); + topic->subscribeAndGetPublisher(IceStorm::QoS(), clock); } adapter->activate(); diff --git a/cpp/demo/IceUtil/workqueue/WorkQueue.cpp b/cpp/demo/IceUtil/workqueue/WorkQueue.cpp index 2b7c081e1da..3e006040fae 100644 --- a/cpp/demo/IceUtil/workqueue/WorkQueue.cpp +++ b/cpp/demo/IceUtil/workqueue/WorkQueue.cpp @@ -36,28 +36,28 @@ public: virtual void run() { - while(1) - { - string item = nextItem(); - if(item == "destroy") - { - break; - } - - mtprint("work item: " + item + "\n"); - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); - } + while(1) + { + string item = nextItem(); + if(item == "destroy") + { + break; + } + + mtprint("work item: " + item + "\n"); + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); + } } void add(const string& item) { - IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor); - if(_queue.empty()) - { - _monitor.notify(); - } - _queue.push_back(item); + IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor); + if(_queue.empty()) + { + _monitor.notify(); + } + _queue.push_back(item); } private: @@ -65,15 +65,15 @@ private: string nextItem() { - IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor); - while(_queue.empty()) - { - _monitor.wait(); - } - - string item = _queue.front(); - _queue.pop_front(); - return item; + IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor); + while(_queue.empty()) + { + _monitor.wait(); + } + + string item = _queue.front(); + _queue.pop_front(); + return item; } @@ -88,31 +88,31 @@ main() { try { - WorkQueuePtr h = new WorkQueue(); - IceUtil::ThreadControl control = h->start(); - mtprint("Pushing work items"); - mtprint("."); - h->add("item1"); - mtprint("."); - h->add("item2"); - mtprint("."); - h->add("item3"); - mtprint("."); - h->add("item4"); - mtprint("."); - h->add("item5"); - mtprint("."); - h->add("destroy"); - mtprint("ok\n"); - mtprint("Waiting for WorkQueue to terminate\n"); - control.join(); + WorkQueuePtr h = new WorkQueue(); + IceUtil::ThreadControl control = h->start(); + mtprint("Pushing work items"); + mtprint("."); + h->add("item1"); + mtprint("."); + h->add("item2"); + mtprint("."); + h->add("item3"); + mtprint("."); + h->add("item4"); + mtprint("."); + h->add("item5"); + mtprint("."); + h->add("destroy"); + mtprint("ok\n"); + mtprint("Waiting for WorkQueue to terminate\n"); + control.join(); } catch(const IceUtil::Exception& ex) { - ostringstream os; - os << ex << "\n"; - mtprint(os.str()); - return EXIT_FAILURE; + ostringstream os; + os << ex << "\n"; + mtprint(os.str()); + return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/cpp/demo/book/evictor/EvictorBase.cpp b/cpp/demo/book/evictor/EvictorBase.cpp index 49edb2a3366..fbea9580212 100644 --- a/cpp/demo/book/evictor/EvictorBase.cpp +++ b/cpp/demo/book/evictor/EvictorBase.cpp @@ -28,26 +28,26 @@ EvictorBase::locate(const Ice::Current& c, Ice::LocalObjectPtr& cookie) bool newEntry = i == _map.end(); if(!newEntry) { - // - // Got an entry already, dequeue the entry from its current position. - // - ec->entry = i->second; - _queue.erase(ec->entry->pos); + // + // Got an entry already, dequeue the entry from its current position. + // + ec->entry = i->second; + _queue.erase(ec->entry->pos); } else { - // - // We do not have an entry. Ask the derived class to - // instantiate a servant and add a new entry to the map. - // - ec->entry = new EvictorEntry; - ec->entry->servant = add(c, ec->entry->userCookie); // Down-call - if(!ec->entry->servant) - { - return 0; - } - ec->entry->useCount = 0; - i = _map.insert(std::make_pair(c.id, ec->entry)).first; + // + // We do not have an entry. Ask the derived class to + // instantiate a servant and add a new entry to the map. + // + ec->entry = new EvictorEntry; + ec->entry->servant = add(c, ec->entry->userCookie); // Down-call + if(!ec->entry->servant) + { + return 0; + } + ec->entry->useCount = 0; + i = _map.insert(std::make_pair(c.id, ec->entry)).first; } // @@ -93,13 +93,13 @@ EvictorBase::evictServants() // for(int i = static_cast<int>(_map.size() - _size); i > 0; --i) { - EvictorQueue::reverse_iterator p = _queue.rbegin(); - if((*p)->second->useCount == 0) - { - evict((*p)->second->servant, (*p)->second->userCookie); // Down-call - EvictorMap::iterator pos = *p; - _queue.erase((*p)->second->pos); - _map.erase(pos); - } + EvictorQueue::reverse_iterator p = _queue.rbegin(); + if((*p)->second->useCount == 0) + { + evict((*p)->second->servant, (*p)->second->userCookie); // Down-call + EvictorMap::iterator pos = *p; + _queue.erase((*p)->second->pos); + _map.erase(pos); + } } } diff --git a/cpp/demo/book/evictor/EvictorBase.h b/cpp/demo/book/evictor/EvictorBase.h index 3677bffe4b6..030f3318394 100644 --- a/cpp/demo/book/evictor/EvictorBase.h +++ b/cpp/demo/book/evictor/EvictorBase.h @@ -30,15 +30,15 @@ private: struct EvictorEntry : public Ice::LocalObject { - Ice::ObjectPtr servant; - Ice::LocalObjectPtr userCookie; - EvictorQueue::iterator pos; - int useCount; + Ice::ObjectPtr servant; + Ice::LocalObjectPtr userCookie; + EvictorQueue::iterator pos; + int useCount; }; struct EvictorCookie : public Ice::LocalObject { - EvictorEntryPtr entry; + EvictorEntryPtr entry; }; typedef IceUtil::Handle<EvictorCookie> EvictorCookiePtr; diff --git a/cpp/demo/book/printer/Client.cpp b/cpp/demo/book/printer/Client.cpp index 71f6bb711b2..4928da9a903 100755 --- a/cpp/demo/book/printer/Client.cpp +++ b/cpp/demo/book/printer/Client.cpp @@ -19,28 +19,28 @@ main(int argc, char * argv[]) int status = 0; Ice::CommunicatorPtr ic; try { - ic = Ice::initialize(argc, argv); - Ice::ObjectPrx base = ic->stringToProxy( - "SimplePrinter:default -p 10000"); - PrinterPrx printer = PrinterPrx::checkedCast(base); - if (!printer) - throw "Invalid proxy"; + ic = Ice::initialize(argc, argv); + Ice::ObjectPrx base = ic->stringToProxy( + "SimplePrinter:default -p 10000"); + PrinterPrx printer = PrinterPrx::checkedCast(base); + if (!printer) + throw "Invalid proxy"; - printer->printString("Hello World!"); + printer->printString("Hello World!"); } catch (const Ice::Exception & ex) { - cerr << ex << endl; - status = 1; + cerr << ex << endl; + status = 1; } catch (const char * msg) { - cerr << msg << endl; - status = 1; + cerr << msg << endl; + status = 1; } if (ic) { - try { - ic->destroy(); - } catch (const Ice::Exception & ex) { - cerr << ex << endl; - status = 1; - } + try { + ic->destroy(); + } catch (const Ice::Exception & ex) { + cerr << ex << endl; + status = 1; + } } return status; } diff --git a/cpp/demo/book/printer/Printer.ice b/cpp/demo/book/printer/Printer.ice index 20e46cdf549..01a4d213aa0 100755 --- a/cpp/demo/book/printer/Printer.ice +++ b/cpp/demo/book/printer/Printer.ice @@ -15,7 +15,7 @@ module Demo interface Printer { - void printString(string s); + void printString(string s); }; }; diff --git a/cpp/demo/book/printer/Server.cpp b/cpp/demo/book/printer/Server.cpp index 2c9d22d4beb..1e619d76b16 100755 --- a/cpp/demo/book/printer/Server.cpp +++ b/cpp/demo/book/printer/Server.cpp @@ -16,7 +16,7 @@ using namespace Demo; class PrinterI : public Printer { public: virtual void printString(const string & s, - const Ice::Current &); + const Ice::Current &); }; void @@ -32,29 +32,29 @@ main(int argc, char* argv[]) int status = 0; Ice::CommunicatorPtr ic; try { - ic = Ice::initialize(argc, argv); - Ice::ObjectAdapterPtr adapter - = ic->createObjectAdapterWithEndpoints( - "SimplePrinterAdapter", "default -p 10000"); - Ice::ObjectPtr object = new PrinterI; - adapter->add(object, - ic->stringToIdentity("SimplePrinter")); - adapter->activate(); - ic->waitForShutdown(); + ic = Ice::initialize(argc, argv); + Ice::ObjectAdapterPtr adapter + = ic->createObjectAdapterWithEndpoints( + "SimplePrinterAdapter", "default -p 10000"); + Ice::ObjectPtr object = new PrinterI; + adapter->add(object, + ic->stringToIdentity("SimplePrinter")); + adapter->activate(); + ic->waitForShutdown(); } catch (const Ice::Exception & e) { - cerr << e << endl; - status = 1; + cerr << e << endl; + status = 1; } catch (const char * msg) { - cerr << msg << endl; - status = 1; + cerr << msg << endl; + status = 1; } if (ic) { try { - ic->destroy(); - } catch (const Ice::Exception & e) { - cerr << e << endl; - status = 1; - } + ic->destroy(); + } catch (const Ice::Exception & e) { + cerr << e << endl; + status = 1; + } } return status; } diff --git a/cpp/demo/book/simple_filesystem/Client.cpp b/cpp/demo/book/simple_filesystem/Client.cpp index 870b879e0d9..00cbc8a425e 100755 --- a/cpp/demo/book/simple_filesystem/Client.cpp +++ b/cpp/demo/book/simple_filesystem/Client.cpp @@ -27,16 +27,16 @@ listRecursive(const DirectoryPrx & dir, int depth = 0) NodeSeq contents = dir->list(); for (NodeSeq::const_iterator i = contents.begin(); i != contents.end(); ++i) { - DirectoryPrx dir = DirectoryPrx::checkedCast(*i); - FilePrx file = FilePrx::uncheckedCast(*i); - cout << indent << (*i)->name() << (dir ? " (directory):" : " (file):") << endl; - if (dir) { - listRecursive(dir, depth); - } else { - Lines text = file->read(); - for (Lines::const_iterator j = text.begin(); j != text.end(); ++j) - cout << indent << "\t" << *j << endl; - } + DirectoryPrx dir = DirectoryPrx::checkedCast(*i); + FilePrx file = FilePrx::uncheckedCast(*i); + cout << indent << (*i)->name() << (dir ? " (directory):" : " (file):") << endl; + if (dir) { + listRecursive(dir, depth); + } else { + Lines text = file->read(); + for (Lines::const_iterator j = text.begin(); j != text.end(); ++j) + cout << indent << "\t" << *j << endl; + } } } @@ -46,38 +46,38 @@ main(int argc, char * argv[]) int status = 0; Ice::CommunicatorPtr ic; try { - // Create a communicator - // - ic = Ice::initialize(argc, argv); + // Create a communicator + // + ic = Ice::initialize(argc, argv); - // Create a proxy for the root directory - // - Ice::ObjectPrx base = ic->stringToProxy("RootDir:default -p 10000"); - if (!base) - throw "Could not create proxy"; + // Create a proxy for the root directory + // + Ice::ObjectPrx base = ic->stringToProxy("RootDir:default -p 10000"); + if (!base) + throw "Could not create proxy"; - // Down-cast the proxy to a Directory proxy - // - DirectoryPrx rootDir = DirectoryPrx::checkedCast(base); - if (!rootDir) - throw "Invalid proxy"; + // Down-cast the proxy to a Directory proxy + // + DirectoryPrx rootDir = DirectoryPrx::checkedCast(base); + if (!rootDir) + throw "Invalid proxy"; - // Recursively list the contents of the root directory - // - cout << "Contents of root directory:" << endl; - listRecursive(rootDir); + // Recursively list the contents of the root directory + // + cout << "Contents of root directory:" << endl; + listRecursive(rootDir); } catch (const Ice::Exception & ex) { - cerr << ex << endl; - status = 1; + cerr << ex << endl; + status = 1; } catch (const char * msg) { - cerr << msg << endl; - status = 1; + cerr << msg << endl; + status = 1; } // Clean up // if (ic) - ic->destroy(); + ic->destroy(); return status; } diff --git a/cpp/demo/book/simple_filesystem/Filesystem.ice b/cpp/demo/book/simple_filesystem/Filesystem.ice index 8592c68381e..de701e15cee 100755 --- a/cpp/demo/book/simple_filesystem/Filesystem.ice +++ b/cpp/demo/book/simple_filesystem/Filesystem.ice @@ -9,23 +9,23 @@ module Filesystem { exception GenericError { - string reason; + string reason; }; interface Node { - ["cpp:const"] idempotent string name(); + ["cpp:const"] idempotent string name(); }; sequence<string> Lines; interface File extends Node { - ["cpp:const"] idempotent Lines read(); - idempotent void write(Lines text) throws GenericError; + ["cpp:const"] idempotent Lines read(); + idempotent void write(Lines text) throws GenericError; }; sequence<Node*> NodeSeq; interface Directory extends Node { - ["cpp:const"] idempotent NodeSeq list(); + ["cpp:const"] idempotent NodeSeq list(); }; }; diff --git a/cpp/demo/book/simple_filesystem/FilesystemI.cpp b/cpp/demo/book/simple_filesystem/FilesystemI.cpp index 8560075d36c..7367e89e3e8 100755 --- a/cpp/demo/book/simple_filesystem/FilesystemI.cpp +++ b/cpp/demo/book/simple_filesystem/FilesystemI.cpp @@ -12,7 +12,7 @@ using namespace std; -Ice::ObjectAdapterPtr Filesystem::NodeI::_adapter; // static member +Ice::ObjectAdapterPtr Filesystem::NodeI::_adapter; // static member // Slice Node::name() operation @@ -39,15 +39,15 @@ Filesystem::NodeI::NodeI(const Ice::CommunicatorPtr & ic, const string & name, c // Ice::Identity myID; if (parent) - myID = ic->stringToIdentity(IceUtil::generateUUID()); + myID = ic->stringToIdentity(IceUtil::generateUUID()); else - myID = ic->stringToIdentity("RootDir"); + myID = ic->stringToIdentity("RootDir"); // Create a proxy for the new node and add it as a child to the parent // NodePrx thisNode = NodePrx::uncheckedCast(_adapter->createProxy(myID)); if (parent) - parent->addChild(thisNode); + parent->addChild(thisNode); // Activate the servant // @@ -66,7 +66,7 @@ Filesystem::FileI::read(const Ice::Current &) const void Filesystem::FileI::write(const Filesystem::Lines & text, - const Ice::Current &) + const Ice::Current &) { _lines = text; } diff --git a/cpp/demo/book/simple_filesystem/FilesystemI.h b/cpp/demo/book/simple_filesystem/FilesystemI.h index fde910b3ac0..c627ce35116 100755 --- a/cpp/demo/book/simple_filesystem/FilesystemI.h +++ b/cpp/demo/book/simple_filesystem/FilesystemI.h @@ -19,33 +19,33 @@ namespace Filesystem { class NodeI : virtual public Node { public: - virtual std::string name(const Ice::Current &) const; - NodeI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr & parent); - static Ice::ObjectAdapterPtr _adapter; + virtual std::string name(const Ice::Current &) const; + NodeI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr & parent); + static Ice::ObjectAdapterPtr _adapter; private: - const std::string _name; - DirectoryIPtr _parent; + const std::string _name; + DirectoryIPtr _parent; }; class FileI : virtual public File, - virtual public NodeI { + virtual public NodeI { public: - virtual Lines read(const Ice::Current &) const; - virtual void write(const Lines &, - const Ice::Current &); - FileI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr &); + virtual Lines read(const Ice::Current &) const; + virtual void write(const Lines &, + const Ice::Current &); + FileI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr &); private: - Lines _lines; + Lines _lines; }; class DirectoryI : virtual public Directory, - virtual public NodeI { + virtual public NodeI { public: - virtual NodeSeq list(const Ice::Current &) const; + virtual NodeSeq list(const Ice::Current &) const; DirectoryI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr &); - void addChild(NodePrx child); + void addChild(NodePrx child); private: - NodeSeq _contents; + NodeSeq _contents; }; } diff --git a/cpp/demo/book/simple_filesystem/Server.cpp b/cpp/demo/book/simple_filesystem/Server.cpp index 84cd4fadbdd..59aa1f61e83 100755 --- a/cpp/demo/book/simple_filesystem/Server.cpp +++ b/cpp/demo/book/simple_filesystem/Server.cpp @@ -17,57 +17,57 @@ class FilesystemApp : virtual public Ice::Application { public: virtual int run(int, char * []) { // Terminate cleanly on receipt of a signal - // - shutdownOnInterrupt(); + // + shutdownOnInterrupt(); - // Create an object adapter (stored in the NodeI::_adapter - // static member) - // - NodeI::_adapter = - communicator()->createObjectAdapterWithEndpoints( - "SimpleFilesystem", "default -p 10000"); + // Create an object adapter (stored in the NodeI::_adapter + // static member) + // + NodeI::_adapter = + communicator()->createObjectAdapterWithEndpoints( + "SimpleFilesystem", "default -p 10000"); - // Create the root directory (with name "/" and no parent) - // - DirectoryIPtr root = new DirectoryI(communicator(), "/", 0); + // Create the root directory (with name "/" and no parent) + // + DirectoryIPtr root = new DirectoryI(communicator(), "/", 0); - // Create a file called "README" in the root directory - // - FilePtr file = new FileI(communicator(), "README", root); - Lines text; - text.push_back("This file system contains a collection of poetry."); - file->write(text); + // Create a file called "README" in the root directory + // + FilePtr file = new FileI(communicator(), "README", root); + Lines text; + text.push_back("This file system contains a collection of poetry."); + file->write(text); - // Create a directory called "Coleridge" in the root directory - // - DirectoryIPtr coleridge = new DirectoryI(communicator(), "Coleridge", root); + // Create a directory called "Coleridge" in the root directory + // + DirectoryIPtr coleridge = new DirectoryI(communicator(), "Coleridge", root); - // Create a file called "Kubla_Khan" in the Coleridge directory - // - file = new FileI(communicator(), "Kubla_Khan", coleridge); - text.erase(text.begin(), text.end()); - text.push_back("In Xanadu did Kubla Khan"); - text.push_back("A stately pleasure-dome decree:"); - text.push_back("Where Alph, the sacred river, ran"); - text.push_back("Through caverns measureless to man"); - text.push_back("Down to a sunless sea."); - file->write(text); + // Create a file called "Kubla_Khan" in the Coleridge directory + // + file = new FileI(communicator(), "Kubla_Khan", coleridge); + text.erase(text.begin(), text.end()); + text.push_back("In Xanadu did Kubla Khan"); + text.push_back("A stately pleasure-dome decree:"); + text.push_back("Where Alph, the sacred river, ran"); + text.push_back("Through caverns measureless to man"); + text.push_back("Down to a sunless sea."); + file->write(text); - // All objects are created, allow client requests now - // - NodeI::_adapter->activate(); + // All objects are created, allow client requests now + // + NodeI::_adapter->activate(); - // Wait until we are done - // - communicator()->waitForShutdown(); + // Wait until we are done + // + communicator()->waitForShutdown(); if (interrupted()) { cerr << appName() - << ": received signal, shutting down" << endl; - } + << ": received signal, shutting down" << endl; + } - NodeI::_adapter = 0; + NodeI::_adapter = 0; - return 0; + return 0; }; }; |