Fresco/Berlin/modules/Commands BoundedRangeImpl.cc,1.7,1.8 BoundedRangeImpl.hh,1.6,1.7 BoundedValueImpl.cc,1.7,1.8 BoundedValueImpl.hh,1.5,1.6 CommandKitImpl.cc,1.29,1.30 CommandKitImpl.hh,1.18,1.19 SelectionImpl.cc,1.7,1.8 SelectionImpl.hh,1.4,1.5 StreamBufferImpl.cc,1.6,1.7 StreamBufferImpl.hh,1.6,1.7 TelltaleImpl.cc,1.10,1.11 TelltaleImpl.hh,1.8,1.9 TextBufferImpl.cc,1.12,1.13 TextBufferImpl.hh,1.10,1.11
Tobias Hunger <[email protected]> Mon, 27 Oct 2003 17:09:13 +0000
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/Berlin/modules/Commands In directory purcel:/tmp/cvs-serv5328/Berlin/modules/Commands Modified Files: BoundedRangeImpl.cc BoundedRangeImpl.hh BoundedValueImpl.cc BoundedValueImpl.hh CommandKitImpl.cc CommandKitImpl.hh SelectionImpl.cc SelectionImpl.hh StreamBufferImpl.cc StreamBufferImpl.hh TelltaleImpl.cc TelltaleImpl.hh TextBufferImpl.cc TextBufferImpl.hh Log Message: Make sure all classes defined by Kits are in the Kit's namespace. Do some coding style fixups while touching the files anyway. Index: BoundedRangeImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/BoundedRangeImpl.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- BoundedRangeImpl.cc 29 May 2002 06:49:38 -0000 1.7 +++ BoundedRangeImpl.cc 27 Oct 2003 17:08:35 -0000 1.8 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -26,7 +26,9 @@ using namespace Prague; using namespace Fresco; -BoundedRangeImpl::BoundedRangeImpl(Coord l, Coord u, Coord lv, Coord uv, Coord s, Coord p) +Berlin::CommandKit::BoundedRangeImpl::BoundedRangeImpl(Coord l, Coord u, + Coord lv, Coord uv, + Coord s, Coord p) : _s(s), _p(p) { _settings.lower = l; @@ -35,29 +37,29 @@ _settings.uvalue = uv; }; -BoundedRangeImpl::~BoundedRangeImpl() +Berlin::CommandKit::BoundedRangeImpl::~BoundedRangeImpl() { }; -BoundedRange::Settings BoundedRangeImpl::state() +BoundedRange::Settings Berlin::CommandKit::BoundedRangeImpl::state() { Prague::Guard<Mutex> guard(_mutex); return _settings; } -void BoundedRangeImpl::state(const Fresco::BoundedRange::Settings &s) +void Berlin::CommandKit::BoundedRangeImpl::state(const Fresco::BoundedRange::Settings &s) { Prague::Guard<Mutex> guard(_mutex); _settings = s; } -Coord BoundedRangeImpl::lower() +Coord Berlin::CommandKit::BoundedRangeImpl::lower() { Prague::Guard<Mutex> guard(_mutex); return _settings.lower; } -void BoundedRangeImpl::lower(Coord l) +void Berlin::CommandKit::BoundedRangeImpl::lower(Coord l) { CORBA::Any any; { @@ -71,13 +73,13 @@ notify(any); } -Coord BoundedRangeImpl::upper() +Coord Berlin::CommandKit::BoundedRangeImpl::upper() { Prague::Guard<Mutex> guard(_mutex); return _settings.upper; } -void BoundedRangeImpl::upper(Coord u) +void Berlin::CommandKit::BoundedRangeImpl::upper(Coord u) { CORBA::Any any; { @@ -91,31 +93,31 @@ notify(any); } -Coord BoundedRangeImpl::step() +Coord Berlin::CommandKit::BoundedRangeImpl::step() { Prague::Guard<Mutex> guard(_mutex); return _s; } -void BoundedRangeImpl::step(Coord s) +void Berlin::CommandKit::BoundedRangeImpl::step(Coord s) { Prague::Guard<Mutex> guard(_mutex); _s = s; } -Coord BoundedRangeImpl::page() +Coord Berlin::CommandKit::BoundedRangeImpl::page() { Prague::Guard<Mutex> guard(_mutex); return _p; } -void BoundedRangeImpl::page(Coord p) +void Berlin::CommandKit::BoundedRangeImpl::page(Coord p) { Prague::Guard<Mutex> guard(_mutex); _p = p; } -void BoundedRangeImpl::forward() +void Berlin::CommandKit::BoundedRangeImpl::forward() { CORBA::Any any; { @@ -129,7 +131,7 @@ notify(any); } -void BoundedRangeImpl::backward() +void Berlin::CommandKit::BoundedRangeImpl::backward() { CORBA::Any any; { @@ -143,7 +145,7 @@ notify(any); } -void BoundedRangeImpl::fastforward() +void Berlin::CommandKit::BoundedRangeImpl::fastforward() { CORBA::Any any; { @@ -157,7 +159,7 @@ notify(any); } -void BoundedRangeImpl::fastbackward() +void Berlin::CommandKit::BoundedRangeImpl::fastbackward() { CORBA::Any any; { @@ -171,7 +173,7 @@ notify(any); } -void BoundedRangeImpl::begin() +void Berlin::CommandKit::BoundedRangeImpl::begin() { CORBA::Any any; { @@ -185,7 +187,7 @@ notify(any); } -void BoundedRangeImpl::end() +void Berlin::CommandKit::BoundedRangeImpl::end() { CORBA::Any any; { @@ -199,7 +201,7 @@ notify(any); } -void BoundedRangeImpl::lvalue(Coord lv) +void Berlin::CommandKit::BoundedRangeImpl::lvalue(Coord lv) { CORBA::Any any; { @@ -212,14 +214,14 @@ notify(any); } -Coord BoundedRangeImpl::lvalue() +Coord Berlin::CommandKit::BoundedRangeImpl::lvalue() { Prague::Guard<Mutex> guard(_mutex); return _settings.lvalue; } -void BoundedRangeImpl::uvalue(Coord uv) +void Berlin::CommandKit::BoundedRangeImpl::uvalue(Coord uv) { CORBA::Any any; { @@ -231,19 +233,20 @@ notify(any); } -Coord BoundedRangeImpl::uvalue() +Coord Berlin::CommandKit::BoundedRangeImpl::uvalue() { Prague::Guard<Mutex> guard(_mutex); return _settings.uvalue; } -void BoundedRangeImpl::adjust(Coord d) +void Berlin::CommandKit::BoundedRangeImpl::adjust(Coord d) { CORBA::Any any; { Prague::Guard<Mutex> guard(_mutex); - Coord t = std::min(std::max(d, _settings.lower - _settings.lvalue), _settings.upper - _settings.uvalue); + Coord t = std::min(std::max(d, _settings.lower - _settings.lvalue), + _settings.upper - _settings.uvalue); if (t == 0.) return; _settings.lvalue += t; _settings.uvalue += t; Index: BoundedRangeImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/BoundedRangeImpl.hh,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- BoundedRangeImpl.hh 29 May 2002 06:49:38 -0000 1.6 +++ BoundedRangeImpl.hh 27 Oct 2003 17:08:35 -0000 1.7 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -28,39 +28,47 @@ #include <Berlin/SubjectImpl.hh> #include <vector> -class BoundedRangeImpl : public virtual POA_Fresco::BoundedRange, - public SubjectImpl +namespace Berlin { - public: - BoundedRangeImpl(Fresco::Coord, Fresco::Coord, Fresco::Coord, Fresco::Coord, Fresco::Coord, Fresco::Coord); - virtual ~BoundedRangeImpl(); - virtual Fresco::BoundedRange::Settings state(); - virtual void state(const Fresco::BoundedRange::Settings &); - virtual Fresco::Coord lower(); - virtual void lower(Fresco::Coord); - virtual Fresco::Coord upper(); - virtual void upper(Fresco::Coord); - virtual Fresco::Coord step(); - virtual void step(Fresco::Coord); - virtual Fresco::Coord page(); - virtual void page(Fresco::Coord); - virtual Fresco::Coord lvalue(); - virtual void lvalue(Fresco::Coord); - virtual Fresco::Coord uvalue(); - virtual void uvalue(Fresco::Coord); + namespace CommandKit + { + class BoundedRangeImpl : public virtual POA_Fresco::BoundedRange, + public SubjectImpl + { + public: + BoundedRangeImpl(Fresco::Coord, Fresco::Coord, Fresco::Coord, + Fresco::Coord, Fresco::Coord, Fresco::Coord); + virtual ~BoundedRangeImpl(); + virtual Fresco::BoundedRange::Settings state(); + virtual void state(const Fresco::BoundedRange::Settings &); + virtual Fresco::Coord lower(); + virtual void lower(Fresco::Coord); + virtual Fresco::Coord upper(); + virtual void upper(Fresco::Coord); + virtual Fresco::Coord step(); + virtual void step(Fresco::Coord); + virtual Fresco::Coord page(); + virtual void page(Fresco::Coord); + virtual Fresco::Coord lvalue(); + virtual void lvalue(Fresco::Coord); + virtual Fresco::Coord uvalue(); + virtual void uvalue(Fresco::Coord); - virtual void forward(); - virtual void backward(); - virtual void fastforward(); - virtual void fastbackward(); - virtual void begin(); - virtual void end(); - virtual void adjust(Fresco::Coord); -private: - Fresco::BoundedRange::Settings _settings; - Fresco::Coord _s; - Fresco::Coord _p; - Prague::Mutex _mutex; -}; + virtual void forward(); + virtual void backward(); + virtual void fastforward(); + virtual void fastbackward(); + virtual void begin(); + virtual void end(); + virtual void adjust(Fresco::Coord); + private: + Fresco::BoundedRange::Settings _settings; + Fresco::Coord _s; + Fresco::Coord _p; + Prague::Mutex _mutex; + }; + + } // namespace +} // namespace #endif Index: BoundedValueImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/BoundedValueImpl.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- BoundedValueImpl.cc 29 May 2002 06:49:38 -0000 1.7 +++ BoundedValueImpl.cc 27 Oct 2003 17:08:35 -0000 1.8 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -25,22 +25,21 @@ using namespace Prague; using namespace Fresco; -BoundedValueImpl::BoundedValueImpl(Coord l, Coord u, Coord v, Coord s, Coord p) - : _l(l), _u(u), _v(v), _s(s), _p(p) -{ -}; +Berlin::CommandKit::BoundedValueImpl::BoundedValueImpl(Coord l, Coord u, Coord v, + Coord s, Coord p) : + _l(l), _u(u), _v(v), _s(s), _p(p) +{ } -BoundedValueImpl::~BoundedValueImpl() -{ -}; +Berlin::CommandKit::BoundedValueImpl::~BoundedValueImpl() +{ } -Coord BoundedValueImpl::lower() +Coord Berlin::CommandKit::BoundedValueImpl::lower() { Prague::Guard<Mutex> guard(_mutex); return _l; } -void BoundedValueImpl::lower(Coord l) +void Berlin::CommandKit::BoundedValueImpl::lower(Coord l) { { Prague::Guard<Mutex> guard(_mutex); @@ -52,13 +51,13 @@ notify(any); } -Coord BoundedValueImpl::upper() +Coord Berlin::CommandKit::BoundedValueImpl::upper() { Prague::Guard<Mutex> guard(_mutex); return _u; } -void BoundedValueImpl::upper(Coord u) +void Berlin::CommandKit::BoundedValueImpl::upper(Coord u) { { Prague::Guard<Mutex> guard(_mutex); @@ -70,31 +69,31 @@ notify(any); } -Coord BoundedValueImpl::step() -{ +Coord Berlin::CommandKit::BoundedValueImpl::step() +{ Prague::Guard<Mutex> guard(_mutex); return _s; } -void BoundedValueImpl::step(Coord s) +void Berlin::CommandKit::BoundedValueImpl::step(Coord s) { Prague::Guard<Mutex> guard(_mutex); _s = s; } -Coord BoundedValueImpl::page() +Coord Berlin::CommandKit::BoundedValueImpl::page() { Prague::Guard<Mutex> guard(_mutex); return _p; } -void BoundedValueImpl::page(Coord p) +void Berlin::CommandKit::BoundedValueImpl::page(Coord p) { Prague::Guard<Mutex> guard(_mutex); _p = p; } -void BoundedValueImpl::forward() +void Berlin::CommandKit::BoundedValueImpl::forward() { { Prague::Guard<Mutex> guard(_mutex); @@ -108,7 +107,7 @@ notify(any); } -void BoundedValueImpl::backward() +void Berlin::CommandKit::BoundedValueImpl::backward() { { Prague::Guard<Mutex> guard(_mutex); @@ -122,7 +121,7 @@ notify(any); } -void BoundedValueImpl::fastforward() +void Berlin::CommandKit::BoundedValueImpl::fastforward() { { Prague::Guard<Mutex> guard(_mutex); @@ -136,7 +135,7 @@ notify(any); } -void BoundedValueImpl::fastbackward() +void Berlin::CommandKit::BoundedValueImpl::fastbackward() { { Prague::Guard<Mutex> guard(_mutex); @@ -150,7 +149,7 @@ notify(any); } -void BoundedValueImpl::begin() +void Berlin::CommandKit::BoundedValueImpl::begin() { { Prague::Guard<Mutex> guard(_mutex); @@ -164,7 +163,7 @@ } -void BoundedValueImpl::end() +void Berlin::CommandKit::BoundedValueImpl::end() { { Prague::Guard<Mutex> guard(_mutex); @@ -177,7 +176,7 @@ notify(any); } -void BoundedValueImpl::value(Coord v) +void Berlin::CommandKit::BoundedValueImpl::value(Coord v) { { Prague::Guard<Mutex> guard(_mutex); @@ -191,14 +190,14 @@ notify(any); } -Coord BoundedValueImpl::value() +Coord Berlin::CommandKit::BoundedValueImpl::value() { Prague::Guard<Mutex> guard(_mutex); return _v; } -void BoundedValueImpl::adjust(Coord d) +void Berlin::CommandKit::BoundedValueImpl::adjust(Coord d) { { Prague::Guard<Mutex> guard(_mutex); Index: BoundedValueImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/BoundedValueImpl.hh,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- BoundedValueImpl.hh 29 May 2002 06:49:38 -0000 1.5 +++ BoundedValueImpl.hh 27 Oct 2003 17:08:35 -0000 1.6 @@ -1,8 +1,8 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> - * Copyright (C) 1999 Graydon Hoare <[email protected]> + * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Graydon Hoare <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -29,37 +29,46 @@ #include <Berlin/SubjectImpl.hh> #include <vector> -class BoundedValueImpl : public virtual POA_Fresco::BoundedValue, - public SubjectImpl +namespace Berlin { - public: - BoundedValueImpl(Fresco::Coord, Fresco::Coord, Fresco::Coord, Fresco::Coord, Fresco::Coord); - virtual ~BoundedValueImpl(); - virtual Fresco::Coord lower(); - virtual void lower(Fresco::Coord); - virtual Fresco::Coord upper(); - virtual void upper(Fresco::Coord); - virtual Fresco::Coord step(); - virtual void step(Fresco::Coord); - virtual Fresco::Coord page(); - virtual void page(Fresco::Coord); - virtual Fresco::Coord value(); - virtual void value(Fresco::Coord); + namespace CommandKit + { - virtual void forward(); - virtual void backward(); - virtual void fastforward(); - virtual void fastbackward(); - virtual void begin(); - virtual void end(); - virtual void adjust(Fresco::Coord); -private: - Fresco::Coord _l; - Fresco::Coord _u; - Fresco::Coord _v; - Fresco::Coord _s; - Fresco::Coord _p; - Prague::Mutex _mutex; -}; + class BoundedValueImpl : public virtual POA_Fresco::BoundedValue, + public SubjectImpl + { + public: + BoundedValueImpl(Fresco::Coord, Fresco::Coord, + Fresco::Coord, Fresco::Coord, Fresco::Coord); + virtual ~BoundedValueImpl(); + virtual Fresco::Coord lower(); + virtual void lower(Fresco::Coord); + virtual Fresco::Coord upper(); + virtual void upper(Fresco::Coord); + virtual Fresco::Coord step(); + virtual void step(Fresco::Coord); + virtual Fresco::Coord page(); + virtual void page(Fresco::Coord); + virtual Fresco::Coord value(); + virtual void value(Fresco::Coord); + + virtual void forward(); + virtual void backward(); + virtual void fastforward(); + virtual void fastbackward(); + virtual void begin(); + virtual void end(); + virtual void adjust(Fresco::Coord); + private: + Fresco::Coord _l; + Fresco::Coord _u; + Fresco::Coord _v; + Fresco::Coord _s; + Fresco::Coord _p; + Prague::Mutex _mutex; + }; + + } // namespace +} // namespace #endif Index: CommandKitImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/CommandKitImpl.cc,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- CommandKitImpl.cc 18 Feb 2003 07:26:24 -0000 1.29 +++ CommandKitImpl.cc 27 Oct 2003 17:08:35 -0000 1.30 @@ -1,8 +1,8 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Graydon Hoare <[email protected]> - * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Graydon Hoare <[email protected]> + * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -42,119 +42,132 @@ using namespace Fresco; -class DebugCommand : public CommandImpl +namespace Berlin { -public: - DebugCommand(Command_ptr c, std::ostream &os, const char *t) : _command(Fresco::Command::_duplicate(c)), _os(os), _text(t) {} - virtual void execute(const CORBA::Any &any) + namespace CommandKit { - _os << _text << " : entering execute" << std::endl; - _command->execute(any); - _os << _text << " : leaving execute" << std::endl; - } - private: - Command_var _command; - std::ostream &_os; - std::string _text; -}; -class LogCommand : public CommandImpl -{ -public: - LogCommand(std::ostream &os, const char *text) : _os(os), _text(text) {} - virtual void execute(const CORBA::Any &) { _os << _text << std::endl;} - private: - std::ostream &_os; - std::string _text; -}; + class DebugCommand : public CommandImpl + { + public: + DebugCommand(Command_ptr c, std::ostream &os, const char *t) : + _command(Fresco::Command::_duplicate(c)), _os(os), _text(t) { } + virtual void execute(const CORBA::Any &any) + { + _os << _text << " : entering execute" << std::endl; + _command->execute(any); + _os << _text << " : leaving execute" << std::endl; + } + private: + Command_var _command; + std::ostream &_os; + std::string _text; + }; -class PrintCommand : public CommandImpl -{ -public: - PrintCommand(Graphic_ptr graphic, ServerContext_ptr server) - : _graphic(Graphic::_duplicate(graphic)), - _server(ServerContext::_duplicate(server)) - {} - virtual void execute(const CORBA::Any &) - { - Fresco::Kit::PropertySeq props; - props.length(1); - props[0].name = CORBA::string_dup("implementation"); - props[0].value = CORBA::string_dup("PSDrawingKit"); - RefCount_var<DrawingKit> print = resolve_kit<DrawingKit>(_server, "IDL:fresco.org/Fresco/DrawingKit:1.0", props); - Fresco::Graphic::Requisition r; - GraphicImpl::init_requisition(r); - _graphic->request(r); - Lease_var<RegionImpl> allocation(Provider<RegionImpl>::provide()); - allocation->valid = true; - allocation->lower.x = allocation->lower.y = allocation->lower.z = 0; - allocation->upper.x = r.x.natural; - allocation->upper.y = r.y.natural; - allocation->upper.z = 0; - allocation->xalign = r.x.align; - allocation->yalign = r.y.align; - allocation->zalign = r.z.align; + class LogCommand : public CommandImpl + { + public: + LogCommand(std::ostream &os, const char *text) : _os(os), _text(text) {} + virtual void execute(const CORBA::Any &) { _os << _text << std::endl;} + private: + std::ostream &_os; + std::string _text; + }; - DrawTraversalImpl *traversal = new DrawTraversalImpl(_graphic, - allocation->_this(), - Transform::_nil(), - print); - print->start_traversal(Traversal_var(traversal->_this())); - traversal->init(); - try { _graphic->traverse(Traversal_var(traversal->_this()));} - catch (const CORBA::OBJECT_NOT_EXIST &) { std::cerr << "PrintCommand: warning: corrupt scene graph!" << std::endl;} - catch (const CORBA::BAD_PARAM &) { std::cerr << "PrintCommand: caught bad parameter" << std::endl;} - traversal->finish(); - traversal->_remove_ref(); - print->finish_traversal(); - } - private: - Graphic_var _graphic; - ServerContext_var _server; -}; + class PrintCommand : public CommandImpl + { + public: + PrintCommand(Graphic_ptr graphic, ServerContext_ptr server) : + _graphic(Graphic::_duplicate(graphic)), + _server(ServerContext::_duplicate(server)) + { } + virtual void execute(const CORBA::Any &) + { + Fresco::Kit::PropertySeq props; + props.length(1); + props[0].name = CORBA::string_dup("implementation"); + props[0].value = CORBA::string_dup("PSDrawingKit"); + RefCount_var<DrawingKit> print = + resolve_kit<DrawingKit>(_server, "IDL:fresco.org/Fresco/DrawingKit:1.0", props); + Fresco::Graphic::Requisition r; + GraphicImpl::init_requisition(r); + _graphic->request(r); + Lease_var<RegionImpl> allocation(Provider<RegionImpl>::provide()); + allocation->valid = true; + allocation->lower.x = allocation->lower.y = allocation->lower.z = 0; + allocation->upper.x = r.x.natural; + allocation->upper.y = r.y.natural; + allocation->upper.z = 0; + allocation->xalign = r.x.align; + allocation->yalign = r.y.align; + allocation->zalign = r.z.align; -class MacroCommandImpl : public virtual POA_Fresco::MacroCommand, - public CommandImpl -{ - typedef std::vector<Fresco::Command_var> clist_t; -public: - virtual ~MacroCommandImpl() - { - for (clist_t::iterator i = _commands.begin(); i != _commands.end(); ++i) - (*i)->destroy(); - } - virtual void append(Fresco::Command_ptr c) - { - _commands.push_back(Fresco::Command::_duplicate(c)); - } - virtual void prepend(Fresco::Command_ptr c) - { - _commands.insert(_commands.begin(), Fresco::Command::_duplicate(c)); - } - virtual void execute(const CORBA::Any &any) + DrawTraversalImpl *traversal = + new DrawTraversalImpl(_graphic, allocation->_this(), + Transform::_nil(), print); + print->start_traversal(Traversal_var(traversal->_this())); + traversal->init(); + try { _graphic->traverse(Traversal_var(traversal->_this())); } + catch (const CORBA::OBJECT_NOT_EXIST &) + { + std::cerr << "PrintCommand: warning: corrupt scene graph!" << std::endl; + } + catch (const CORBA::BAD_PARAM &) + { + std::cerr << "PrintCommand: caught bad parameter" << std::endl; + } + traversal->finish(); + traversal->_remove_ref(); + print->finish_traversal(); + } + private: + Graphic_var _graphic; + ServerContext_var _server; + }; + + class MacroCommandImpl : public virtual POA_Fresco::MacroCommand, public CommandImpl { - for (clist_t::iterator i = _commands.begin(); i != _commands.end(); ++i) - (*i)->execute(any); - } - private: - clist_t _commands; -}; + typedef std::vector<Fresco::Command_var> clist_t; + public: + virtual ~MacroCommandImpl() + { + for (clist_t::iterator i = _commands.begin(); i != _commands.end(); ++i) + (*i)->destroy(); + } + virtual void append(Fresco::Command_ptr c) + { + _commands.push_back(Fresco::Command::_duplicate(c)); + } + virtual void prepend(Fresco::Command_ptr c) + { + _commands.insert(_commands.begin(), Fresco::Command::_duplicate(c)); + } + virtual void execute(const CORBA::Any &any) + { + for (clist_t::iterator i = _commands.begin(); i != _commands.end(); ++i) + (*i)->execute(any); + } + private: + clist_t _commands; + }; + } // namespace +} // namespace -CommandKitImpl::CommandKitImpl(const std::string &id, - const Fresco::Kit::PropertySeq &p, - ServerContextImpl *c) - : KitImpl(id, p, c) { } +Berlin::CommandKit::CommandKitImpl::CommandKitImpl(const std::string &id, + const Fresco::Kit::PropertySeq &p, + ServerContextImpl *c) : + KitImpl(id, p, c) { } -CommandKitImpl::~CommandKitImpl() { } +Berlin::CommandKit::CommandKitImpl::~CommandKitImpl() { } -void CommandKitImpl::bind(ServerContext_ptr server) +void Berlin::CommandKit::CommandKitImpl::bind(ServerContext_ptr server) { - _server = ServerContext::_duplicate(server); + _server = ServerContext::_duplicate(server); } -Command_ptr CommandKitImpl::debugger(Fresco::Command_ptr c, const char *text) +Command_ptr Berlin::CommandKit::CommandKitImpl::debugger(Fresco::Command_ptr c, const char *text) { // FIXME: Shouldn't this be std::cerr? -- tobias DebugCommand *command = new DebugCommand(c, std::cout, text); @@ -162,7 +175,7 @@ return command->_this(); } -Command_ptr CommandKitImpl::log(const char *text) +Command_ptr Berlin::CommandKit::CommandKitImpl::log(const char *text) { // FIXME: Shouldn't this be std::cerr? -- tobias LogCommand *command = new LogCommand(std::cout, text); @@ -170,42 +183,42 @@ return command->_this(); } -Command_ptr CommandKitImpl::print(Graphic_ptr graphic) +Command_ptr Berlin::CommandKit::CommandKitImpl::print(Graphic_ptr graphic) { PrintCommand *command = new PrintCommand(graphic, _server); activate(command); return command->_this(); } -MacroCommand_ptr CommandKitImpl::composite() +MacroCommand_ptr Berlin::CommandKit::CommandKitImpl::composite() { MacroCommandImpl *command = new MacroCommandImpl(); activate(command); return command->_this(); } -TelltaleConstraint_ptr CommandKitImpl::exclusive(Telltale::Mask m) +TelltaleConstraint_ptr Berlin::CommandKit::CommandKitImpl::exclusive(Telltale::Mask m) { ExclusiveChoice *constraint = new ExclusiveChoice(m); activate(constraint); return constraint->_this(); } -TelltaleConstraint_ptr CommandKitImpl::selection_required() +TelltaleConstraint_ptr Berlin::CommandKit::CommandKitImpl::selection_required() { SelectionRequired *constraint = new SelectionRequired(Controller::toggled); activate(constraint); return constraint->_this(); } -Telltale_ptr CommandKitImpl::normal_telltale() +Telltale_ptr Berlin::CommandKit::CommandKitImpl::normal_telltale() { TelltaleImpl *telltale = new TelltaleImpl(TelltaleConstraint::_nil()); activate(telltale); return telltale->_this(); } -Telltale_ptr CommandKitImpl::constrained_telltale(TelltaleConstraint_ptr constraint) +Telltale_ptr Berlin::CommandKit::CommandKitImpl::constrained_telltale(TelltaleConstraint_ptr constraint) { TelltaleImpl *telltale = new TelltaleImpl(constraint); activate(telltale); @@ -213,7 +226,7 @@ return telltale->_this(); } -Selection_ptr CommandKitImpl::group(Selection::Policy policy) +Selection_ptr Berlin::CommandKit::CommandKitImpl::group(Selection::Policy policy) { TelltaleConstraintImpl *constraint = 0; switch (policy) @@ -240,36 +253,37 @@ return selection->_this(); } -BoundedValue_ptr CommandKitImpl::bvalue(Coord l, Coord u, Coord v, Coord s, Coord p) +BoundedValue_ptr Berlin::CommandKit::CommandKitImpl::bvalue(Coord l, Coord u, Coord v, Coord s, Coord p) { BoundedValueImpl *bounded = new BoundedValueImpl(l, u, v, s, p); activate(bounded); return bounded->_this(); } -BoundedRange_ptr CommandKitImpl::brange(Coord l, Coord u, Coord lv, Coord uv, Coord s, Coord p) +BoundedRange_ptr Berlin::CommandKit::CommandKitImpl::brange(Coord l, Coord u, Coord lv, Coord uv, Coord s, Coord p) { BoundedRangeImpl *bounded = new BoundedRangeImpl(l, u, lv, uv, s, p); activate(bounded); return bounded->_this(); } -TextBuffer_ptr CommandKitImpl::text() +TextBuffer_ptr Berlin::CommandKit::CommandKitImpl::text() { TextBufferImpl *buffer = new TextBufferImpl(); activate(buffer); - return buffer->_this(); + return buffer->_this(); } -StreamBuffer_ptr CommandKitImpl::stream(CORBA::Long b) +StreamBuffer_ptr Berlin::CommandKit::CommandKitImpl::stream(CORBA::Long b) { StreamBufferImpl *buffer = new StreamBufferImpl(b); activate(buffer); - return buffer->_this(); + return buffer->_this(); } extern "C" KitImpl *load() { static std::string properties[] = {"implementation", "CommandKitImpl"}; - return create_prototype<CommandKitImpl>("IDL:fresco.org/Fresco/CommandKit:1.0", properties, 2); + return create_prototype<Berlin::CommandKit::CommandKitImpl> + ("IDL:fresco.org/Fresco/CommandKit:1.0", properties, 2); } Index: CommandKitImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/CommandKitImpl.hh,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- CommandKitImpl.hh 18 Feb 2003 07:26:24 -0000 1.18 +++ CommandKitImpl.hh 27 Oct 2003 17:08:35 -0000 1.19 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Graydon Hoare <[email protected]> + * Copyright (C) 1999 Graydon Hoare <[email protected]> * Copyright (C) 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * @@ -32,33 +32,45 @@ class CommandImpl; class SubjectImpl; -class CommandKitImpl : public virtual POA_Fresco::CommandKit, - public KitImpl +namespace Berlin { - public: - CommandKitImpl(const std::string &, - const Fresco::Kit::PropertySeq &, - ServerContextImpl *); - virtual ~CommandKitImpl(); - virtual KitImpl *clone(const Fresco::Kit::PropertySeq &p, ServerContextImpl *c) - { return new CommandKitImpl(repo_id(), p, c);} - virtual void bind(Fresco::ServerContext_ptr); + namespace CommandKit + { - virtual Fresco::Command_ptr debugger(Fresco::Command_ptr, const char *); - virtual Fresco::Command_ptr log(const char *); - virtual Fresco::Command_ptr print(Fresco::Graphic_ptr); - virtual Fresco::MacroCommand_ptr composite(); - virtual Fresco::TelltaleConstraint_ptr exclusive(Fresco::Telltale::Mask); - virtual Fresco::TelltaleConstraint_ptr selection_required(); - virtual Fresco::Telltale_ptr constrained_telltale(Fresco::TelltaleConstraint_ptr); - virtual Fresco::Telltale_ptr normal_telltale(); - virtual Fresco::Selection_ptr group(Fresco::Selection::Policy); - virtual Fresco::BoundedValue_ptr bvalue(Fresco::Coord, Fresco::Coord, Fresco::Coord, Fresco::Coord, Fresco::Coord); - virtual Fresco::BoundedRange_ptr brange(Fresco::Coord, Fresco::Coord, Fresco::Coord, Fresco::Coord, Fresco::Coord, Fresco::Coord); - virtual Fresco::TextBuffer_ptr text(); - virtual Fresco::StreamBuffer_ptr stream(CORBA::Long); - private: - Fresco::ServerContext_var _server; -}; + class CommandKitImpl : public virtual POA_Fresco::CommandKit, public KitImpl + { + public: + CommandKitImpl(const std::string &, + const Fresco::Kit::PropertySeq &, + ServerContextImpl *); + virtual ~CommandKitImpl(); + virtual KitImpl *clone(const Fresco::Kit::PropertySeq &p, ServerContextImpl *c) + { + return new CommandKitImpl(repo_id(), p, c); + } + virtual void bind(Fresco::ServerContext_ptr); + + virtual Fresco::Command_ptr debugger(Fresco::Command_ptr, const char *); + virtual Fresco::Command_ptr log(const char *); + virtual Fresco::Command_ptr print(Fresco::Graphic_ptr); + virtual Fresco::MacroCommand_ptr composite(); + virtual Fresco::TelltaleConstraint_ptr exclusive(Fresco::Telltale::Mask); + virtual Fresco::TelltaleConstraint_ptr selection_required(); + virtual Fresco::Telltale_ptr constrained_telltale(Fresco::TelltaleConstraint_ptr); + virtual Fresco::Telltale_ptr normal_telltale(); + virtual Fresco::Selection_ptr group(Fresco::Selection::Policy); + virtual Fresco::BoundedValue_ptr bvalue(Fresco::Coord, Fresco::Coord, + Fresco::Coord, Fresco::Coord, Fresco::Coord); + virtual Fresco::BoundedRange_ptr brange(Fresco::Coord, Fresco::Coord, + Fresco::Coord, Fresco::Coord, + Fresco::Coord, Fresco::Coord); + virtual Fresco::TextBuffer_ptr text(); + virtual Fresco::StreamBuffer_ptr stream(CORBA::Long); + private: + Fresco::ServerContext_var _server; + }; + + } // namespace +} // namespace #endif Index: SelectionImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/SelectionImpl.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- SelectionImpl.cc 29 May 2002 06:49:38 -0000 1.7 +++ SelectionImpl.cc 27 Oct 2003 17:08:35 -0000 1.8 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -32,7 +32,7 @@ * a little glue class to notify the Selection if the 'toggled' * flag in the Telltale changed state. */ -class SelectionImpl::Observer : public ObserverImpl +class Berlin::CommandKit::SelectionImpl::Observer : public ObserverImpl { public: Observer(SelectionImpl *, Telltale_ptr, Tag); @@ -47,121 +47,125 @@ Tag t; }; -bool SelectionImpl::Id_eq::operator()(const SelectionImpl::Observer *o) const { return o->id() == id;} +bool Berlin::CommandKit::SelectionImpl::Id_eq::operator()(const SelectionImpl::Observer *o) const +{ return o->id() == id; } -SelectionImpl::Observer::Observer(SelectionImpl *s, Telltale_ptr i, Tag tt) - : selection(s), - item(RefCount_var<Fresco::Telltale>::increment(i)), - cached(item->test(Fresco::Controller::toggled)), - t(tt) -{ -} +Berlin::CommandKit::SelectionImpl::Observer::Observer(SelectionImpl *s, Telltale_ptr i, + Tag tt) : + selection(s), + item(RefCount_var<Fresco::Telltale>::increment(i)), + cached(item->test(Fresco::Controller::toggled)), + t(tt) +{ } -SelectionImpl::Observer::~Observer() +Berlin::CommandKit::SelectionImpl::Observer::~Observer() { - Trace trace("SelectionImpl::Observer::~Observer"); - item->detach(Observer_var(_this())); - selection->remove_observer(t); + Trace trace("SelectionImpl::Observer::~Observer"); + item->detach(Observer_var(_this())); + selection->remove_observer(t); } -void SelectionImpl::Observer::update(const CORBA::Any &any) +void Berlin::CommandKit::SelectionImpl::Observer::update(const CORBA::Any &any) { - bool toggled = item->test(Fresco::Controller::toggled); - if (toggled == cached) return; // not for us... - cached = toggled; - selection->update(t, toggled); + bool toggled = item->test(Fresco::Controller::toggled); + if (toggled == cached) return; // not for us... + cached = toggled; + selection->update(t, toggled); } -SelectionImpl::SelectionImpl(Fresco::Selection::Policy p, TelltaleConstraint_ptr c) - : policy(p), constraint(RefCount_var<TelltaleConstraint>::increment(c)) +Berlin::CommandKit::SelectionImpl::SelectionImpl(Fresco::Selection::Policy p, + TelltaleConstraint_ptr c) : + policy(p), + constraint(RefCount_var<TelltaleConstraint>::increment(c)) { - Trace trace("SelectionImpl::SelectionImpl"); + Trace trace("SelectionImpl::SelectionImpl"); } -SelectionImpl::~SelectionImpl() +Berlin::CommandKit::SelectionImpl::~SelectionImpl() { - Trace trace("SelectionImpl::~SelectionImpl"); -// for (list_t::iterator i = items.begin(); i != items.end(); i++) -// try { (*i)->deactivate();} -// catch (CORBA::OBJECT_NOT_EXIST &) {} + Trace trace("SelectionImpl::~SelectionImpl"); + // for (list_t::iterator i = items.begin(); i != items.end(); i++) + // try { (*i)->deactivate();} + // catch (CORBA::OBJECT_NOT_EXIST &) {} } -Fresco::Selection::Policy SelectionImpl::type() { return policy;} -void SelectionImpl::type(Fresco::Selection::Policy p) { +Fresco::Selection::Policy Berlin::CommandKit::SelectionImpl::type() { return policy; } +void Berlin::CommandKit::SelectionImpl::type(Fresco::Selection::Policy p) +{ Prague::Guard<Mutex> guard(mutex); policy = p; } -Tag SelectionImpl::add(Telltale_ptr t) +Tag Berlin::CommandKit::SelectionImpl::add(Telltale_ptr t) { - Trace trace("SelectionImpl::add"); - Prague::Guard<Mutex> guard(mutex); - Tag id = uniqueId(); - Observer *observer = new Observer(this, t, id); -// activate(observer); - t->attach(Observer_var(observer->_this())); - if (!CORBA::is_nil(constraint)) constraint->add(t); - items.push_back(observer); - return id; + Trace trace("SelectionImpl::add"); + Prague::Guard<Mutex> guard(mutex); + Tag id = uniqueId(); + Observer *observer = new Observer(this, t, id); + // activate(observer); + t->attach(Observer_var(observer->_this())); + if (!CORBA::is_nil(constraint)) constraint->add(t); + items.push_back(observer); + return id; } -void SelectionImpl::remove(Tag t) +void Berlin::CommandKit::SelectionImpl::remove(Tag t) { - Trace trace("SelectionImpl::remove"); - Prague::Guard<Mutex> guard(mutex); - size_t i = id_to_index(t); - if (i < items.size()) + Trace trace("SelectionImpl::remove"); + Prague::Guard<Mutex> guard(mutex); + size_t i = id_to_index(t); + if (i < items.size()) { - // if (!CORBA::is_nil(constraint)) constraint->remove(t); - items[i]->destroy(); - items.erase(items.begin() + i); + // if (!CORBA::is_nil(constraint)) constraint->remove(t); + items[i]->destroy(); + items.erase(items.begin() + i); } } -Selection::Items *SelectionImpl::toggled() +Selection::Items * Berlin::CommandKit::SelectionImpl::toggled() { - Trace trace("SelectionImpl::toggled"); - Prague::Guard<Mutex> guard(mutex); - Fresco::Selection::Items_var ret = new Fresco::Selection::Items; - for (list_t::iterator i = items.begin(); i != items.end(); i++) - if ((*i)->toggled()) - { - // FIXME: Use push_back() once we finally switch to gcc 3 -- tobias - ret->length(ret->length() + 1); - ret[ret->length() - 1] = (*i)->id(); - } - return ret._retn(); + Trace trace("SelectionImpl::toggled"); + Prague::Guard<Mutex> guard(mutex); + Fresco::Selection::Items_var ret = new Fresco::Selection::Items; + for (list_t::iterator i = items.begin(); i != items.end(); i++) + if ((*i)->toggled()) + { + // FIXME: Use push_back() once we finally switch to gcc 3 -- tobias + ret->length(ret->length() + 1); + ret[ret->length() - 1] = (*i)->id(); + } + return ret._retn(); } -void SelectionImpl::update(Tag t, bool toggled) +void Berlin::CommandKit::SelectionImpl::update(Tag t, bool toggled) { - Trace trace("SelectionImpl::update"); - CORBA::Any any; - Fresco::Selection::Item item; - item.id = t; - item.toggled = toggled; - any <<= item; - notify(any); + Trace trace("SelectionImpl::update"); + CORBA::Any any; + Fresco::Selection::Item item; + item.id = t; + item.toggled = toggled; + any <<= item; + notify(any); } -void SelectionImpl::remove_observer(Tag t) +void Berlin::CommandKit::SelectionImpl::remove_observer(Tag t) { - Trace trace("SelectionImpl::remove_observer"); - Prague::Guard<Mutex> guard(mutex); - size_t i = id_to_index(t); - if (i < items.size()) items.erase(items.begin() + i); + Trace trace("SelectionImpl::remove_observer"); + Prague::Guard<Mutex> guard(mutex); + size_t i = id_to_index(t); + if (i < items.size()) items.erase(items.begin() + i); } -Tag SelectionImpl::uniqueId() +Tag Berlin::CommandKit::SelectionImpl::uniqueId() { - Tag id; - for (id = 0; - std::find_if(items.begin(), items.end(), Id_eq(id)) != items.end(); - id++); - return id; + Tag id; + for (id = 0; + std::find_if(items.begin(), items.end(), Id_eq(id)) != items.end(); + id++); + return id; } -CORBA::Long SelectionImpl::id_to_index(Tag id) +CORBA::Long Berlin::CommandKit::SelectionImpl::id_to_index(Tag id) { - return std::find_if(items.begin(), items.end(), Id_eq(id)) - items.begin(); + return std::find_if(items.begin(), items.end(), Id_eq(id)) - items.begin(); } Index: SelectionImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/SelectionImpl.hh,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- SelectionImpl.hh 29 May 2002 06:49:38 -0000 1.4 +++ SelectionImpl.hh 27 Oct 2003 17:08:35 -0000 1.5 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -31,35 +31,42 @@ #include <algorithm> #include <functional> -class SelectionImpl : public virtual POA_Fresco::Selection, - public SubjectImpl +namespace Berlin { - class Observer; - friend class Observer; - typedef std::vector<Observer *> list_t; - struct Id_eq : public std::unary_function<Observer *, bool> + namespace CommandKit { - Id_eq(Fresco::Tag t) : id(t) {} - bool operator()(const Observer *) const; - Fresco::Tag id; - }; - public: - SelectionImpl(Fresco::Selection::Policy, Fresco::TelltaleConstraint_ptr); - virtual ~SelectionImpl(); - virtual Fresco::Selection::Policy type(); - virtual void type(Fresco::Selection::Policy); - virtual Fresco::Tag add(Fresco::Telltale_ptr); - virtual void remove(Fresco::Tag); - virtual Fresco::Selection::Items *toggled(); - private: - void update(Fresco::Tag, bool); - void remove_observer(Fresco::Tag); - Fresco::Tag uniqueId(); - CORBA::Long id_to_index(Fresco::Tag); - Prague::Mutex mutex; - Fresco::Selection::Policy policy; - RefCount_var<Fresco::TelltaleConstraint> constraint; - list_t items; -}; + class SelectionImpl : public virtual POA_Fresco::Selection, + public SubjectImpl + { + class Observer; + friend class Observer; + typedef std::vector<Observer *> list_t; + struct Id_eq : public std::unary_function<Observer *, bool> + { + Id_eq(Fresco::Tag t) : id(t) { } + bool operator()(const Observer *) const; + Fresco::Tag id; + }; + public: + SelectionImpl(Fresco::Selection::Policy, Fresco::TelltaleConstraint_ptr); + virtual ~SelectionImpl(); + virtual Fresco::Selection::Policy type(); + virtual void type(Fresco::Selection::Policy); + virtual Fresco::Tag add(Fresco::Telltale_ptr); + virtual void remove(Fresco::Tag); + virtual Fresco::Selection::Items *toggled(); + private: + void update(Fresco::Tag, bool); + void remove_observer(Fresco::Tag); + Fresco::Tag uniqueId(); + CORBA::Long id_to_index(Fresco::Tag); + Prague::Mutex mutex; + Fresco::Selection::Policy policy; + RefCount_var<Fresco::TelltaleConstraint> constraint; + list_t items; + }; + + } // namespace +} // namespace #endif Index: StreamBufferImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/StreamBufferImpl.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- StreamBufferImpl.cc 6 Nov 2002 21:02:43 -0000 1.6 +++ StreamBufferImpl.cc 27 Oct 2003 17:08:35 -0000 1.7 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -25,19 +25,19 @@ using namespace Prague; using namespace Fresco; -CORBA::Long StreamBufferImpl::size() +CORBA::Long Berlin::CommandKit::StreamBufferImpl::size() { Prague::Guard<Mutex> guard(mutex); return length; } -CORBA::Long StreamBufferImpl::available() +CORBA::Long Berlin::CommandKit::StreamBufferImpl::available() { Prague::Guard<Mutex> guard(mutex); return buffer.size(); } -void StreamBufferImpl::write(const Fresco::StreamBuffer::Data &data) +void Berlin::CommandKit::StreamBufferImpl::write(const Fresco::StreamBuffer::Data &data) { bool overflow = false; { @@ -55,21 +55,21 @@ } } -void StreamBufferImpl::flush() +void Berlin::CommandKit::StreamBufferImpl::flush() { bool overflow = false; { - Prague::Guard<Mutex> guard(mutex); + Prague::Guard<Mutex> guard(mutex); if (buffer.size()) overflow = true; } if (overflow) { CORBA::Any any; notify(any); - } + } } -Fresco::StreamBuffer::Data *StreamBufferImpl::read() +Fresco::StreamBuffer::Data * Berlin::CommandKit::StreamBufferImpl::read() { Guard<Mutex> guard(mutex); Fresco::StreamBuffer::Data_var data = new Fresco::StreamBuffer::Data; @@ -79,4 +79,3 @@ buffer.reserve(length); return data._retn(); } - Index: StreamBufferImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/StreamBufferImpl.hh,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- StreamBufferImpl.hh 29 May 2002 06:49:38 -0000 1.6 +++ StreamBufferImpl.hh 27 Oct 2003 17:08:35 -0000 1.7 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -28,21 +28,28 @@ #include <Berlin/SubjectImpl.hh> #include <vector> -class StreamBufferImpl : public virtual POA_Fresco::StreamBuffer, - public SubjectImpl +namespace Berlin { - public: - StreamBufferImpl(long l) : length(l) { buffer.reserve(length);} - virtual ~StreamBufferImpl() {} - virtual CORBA::Long size(); - virtual CORBA::Long available(); - virtual Fresco::StreamBuffer::Data *read(); - virtual void write(const Fresco::StreamBuffer::Data &); - virtual void flush(); - private: - size_t length; - std::vector<CORBA::Octet> buffer; - Prague::Mutex mutex; -}; + namespace CommandKit + { + class StreamBufferImpl : public virtual POA_Fresco::StreamBuffer, + public SubjectImpl + { + public: + StreamBufferImpl(long l) : length(l) { buffer.reserve(length);} + virtual ~StreamBufferImpl() { } + virtual CORBA::Long size(); + virtual CORBA::Long available(); + virtual Fresco::StreamBuffer::Data *read(); + virtual void write(const Fresco::StreamBuffer::Data &); + virtual void flush(); + private: + size_t length; + std::vector<CORBA::Octet> buffer; + Prague::Mutex mutex; + }; + + } // namespace +} // namespace #endif Index: TelltaleImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/TelltaleImpl.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- TelltaleImpl.cc 29 May 2002 06:49:38 -0000 1.10 +++ TelltaleImpl.cc 27 Oct 2003 17:08:35 -0000 1.11 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -25,124 +25,133 @@ using namespace Prague; using namespace Fresco; -TelltaleImpl::TelltaleImpl(TelltaleConstraint_ptr c, CORBA::ULong m) - : _mask(m), _constraint(c) -{} +Berlin::CommandKit::TelltaleImpl::TelltaleImpl(TelltaleConstraint_ptr c, + CORBA::ULong m) : + _mask(m), + _constraint(c) +{ } -TelltaleImpl::~TelltaleImpl() -{} +Berlin::CommandKit::TelltaleImpl::~TelltaleImpl() +{ } -void TelltaleImpl::set(Fresco::Telltale::Mask m) +void Berlin::CommandKit::TelltaleImpl::set(Fresco::Telltale::Mask m) { - Trace trace("TelltaleImpl::set"); - if (!CORBA::is_nil(_constraint)) _constraint->trymodify(Telltale_var(_this()), m, true); - else modify(m, true); + Trace trace("TelltaleImpl::set"); + if (!CORBA::is_nil(_constraint)) + _constraint->trymodify(Telltale_var(_this()), m, true); + else modify(m, true); } -void TelltaleImpl::clear(Fresco::Telltale::Mask m) +void Berlin::CommandKit::TelltaleImpl::clear(Fresco::Telltale::Mask m) { - Trace trace("TelltaleImpl::clear"); - if (!CORBA::is_nil(_constraint)) _constraint->trymodify(Telltale_var(_this()), m, false); - else modify(m, false); + Trace trace("TelltaleImpl::clear"); + if (!CORBA::is_nil(_constraint)) + _constraint->trymodify(Telltale_var(_this()), m, false); + else modify(m, false); } -CORBA::Boolean TelltaleImpl::test(Fresco::Telltale::Mask m) +CORBA::Boolean Berlin::CommandKit::TelltaleImpl::test(Fresco::Telltale::Mask m) { - Prague::Guard<Mutex> guard(_mutex); - return (_mask & m) == m; + Prague::Guard<Mutex> guard(_mutex); + return (_mask & m) == m; } -void TelltaleImpl::modify(Fresco::Telltale::Mask m, CORBA::Boolean on) +void Berlin::CommandKit::TelltaleImpl::modify(Fresco::Telltale::Mask m, + CORBA::Boolean on) { - CORBA::ULong nf = on ? _mask | m : _mask & ~m; - { - Prague::Guard<Mutex> guard(_mutex); - if (nf == _mask) return; - else _mask = nf; - } - CORBA::Any any; - any <<= nf; - notify(any); + CORBA::ULong nf = on ? _mask | m : _mask & ~m; + { + Prague::Guard<Mutex> guard(_mutex); + if (nf == _mask) return; + else _mask = nf; + } + CORBA::Any any; + any <<= nf; + notify(any); } -void TelltaleImpl::constraint(TelltaleConstraint_ptr constraint) +void Berlin::CommandKit::TelltaleImpl::constraint(TelltaleConstraint_ptr constraint) { - Prague::Guard<Mutex> guard(_mutex); - _constraint = constraint; + Prague::Guard<Mutex> guard(_mutex); + _constraint = constraint; } -TelltaleConstraint_ptr TelltaleImpl::constraint() +TelltaleConstraint_ptr Berlin::CommandKit::TelltaleImpl::constraint() { - Prague::Guard<Mutex> guard(_mutex); - return TelltaleConstraint::_duplicate(_constraint); + Prague::Guard<Mutex> guard(_mutex); + return TelltaleConstraint::_duplicate(_constraint); } -void TelltaleConstraintImpl::add(Telltale_ptr t) +void Berlin::CommandKit::TelltaleConstraintImpl::add(Telltale_ptr t) { - Prague::Guard<Mutex> guard(_mutex); - _telltales.push_back(Telltale::_duplicate(t)); - t->constraint(TelltaleConstraint_var(_this())); + Prague::Guard<Mutex> guard(_mutex); + _telltales.push_back(Telltale::_duplicate(t)); + t->constraint(TelltaleConstraint_var(_this())); } -void TelltaleConstraintImpl::remove(Telltale_ptr t) +void Berlin::CommandKit::TelltaleConstraintImpl::remove(Telltale_ptr t) { - Prague::Guard<Mutex> guard(_mutex); - for (tlist_t::iterator i = _telltales.begin(); i != _telltales.end(); ++i) - if ((*i) == t) - { - _telltales.erase(i); - break; - } + Prague::Guard<Mutex> guard(_mutex); + for (tlist_t::iterator i = _telltales.begin(); i != _telltales.end(); ++i) + if ((*i) == t) + { + _telltales.erase(i); + break; + } } -ExclusiveChoice::ExclusiveChoice(Fresco::Telltale::Mask m) - : _mask(m) -{} +Berlin::CommandKit::ExclusiveChoice::ExclusiveChoice(Fresco::Telltale::Mask m) : + _mask(m) +{ } -void ExclusiveChoice::trymodify(Telltale_ptr t, Fresco::Telltale::Mask m, CORBA::Boolean b) +void Berlin::CommandKit::ExclusiveChoice::trymodify(Telltale_ptr t, + Fresco::Telltale::Mask m, + CORBA::Boolean b) { - Prague::Guard<Mutex> guard(_mutex); - if (b) - for (tlist_t::iterator i = _telltales.begin(); i != _telltales.end(); ++i) - if ((*i)->test(m)) (*i)->modify(m, false); - t->modify(m, b); + Prague::Guard<Mutex> guard(_mutex); + if (b) + for (tlist_t::iterator i = _telltales.begin(); i != _telltales.end(); ++i) + if ((*i)->test(m)) (*i)->modify(m, false); + t->modify(m, b); } -SelectionRequired::SelectionRequired(Fresco::Telltale::Mask m) - : _mask(m) -{ -} +Berlin::CommandKit::SelectionRequired::SelectionRequired(Fresco::Telltale::Mask m) : + _mask(m) +{ } -void SelectionRequired::trymodify(Telltale_ptr t, Fresco::Telltale::Mask m, CORBA::Boolean b) +void Berlin::CommandKit::SelectionRequired::trymodify(Telltale_ptr t, + Fresco::Telltale::Mask m, + CORBA::Boolean b) { - Prague::Guard<Mutex> guard(_mutex); - size_t selected = 0; - if (!b) - for (tlist_t::iterator i = _telltales.begin(); i != _telltales.end(); ++i) - if ((*i)->test(m)) selected++; - if (b || selected > 1) t->modify(m, b); + Prague::Guard<Mutex> guard(_mutex); + size_t selected = 0; + if (!b) + for (tlist_t::iterator i = _telltales.begin(); i != _telltales.end(); ++i) + if ((*i)->test(m)) selected++; + if (b || selected > 1) t->modify(m, b); } -ExclusiveRequired::ExclusiveRequired(Fresco::Telltale::Mask m) - : _mask(m) -{} +Berlin::CommandKit::ExclusiveRequired::ExclusiveRequired(Fresco::Telltale::Mask m) : + _mask(m) +{ } -void ExclusiveRequired::trymodify(Telltale_ptr t, Fresco::Telltale::Mask m, CORBA::Boolean b) +void Berlin::CommandKit::ExclusiveRequired::trymodify(Telltale_ptr t, + Fresco::Telltale::Mask m, + CORBA::Boolean b) { - Prague::Guard<Mutex> guard(_mutex); - if (b) + Prague::Guard<Mutex> guard(_mutex); + if (b) { - for (tlist_t::iterator i = _telltales.begin(); i != _telltales.end(); ++i) - if ((*i)->test(m)) (*i)->modify(m, false); - t->modify(m, true); + for (tlist_t::iterator i = _telltales.begin(); i != _telltales.end(); ++i) + if ((*i)->test(m)) (*i)->modify(m, false); + t->modify(m, true); } - else + else { - size_t selected = 0; - for (tlist_t::iterator i = _telltales.begin(); i != _telltales.end(); ++i) - if ((*i)->test(m)) selected++; - if (selected > 1) t->modify(m, false); + size_t selected = 0; + for (tlist_t::iterator i = _telltales.begin(); i != _telltales.end(); ++i) + if ((*i)->test(m)) selected++; + if (selected > 1) t->modify(m, false); } } - Index: TelltaleImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/TelltaleImpl.hh,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- TelltaleImpl.hh 29 May 2002 06:49:38 -0000 1.8 +++ TelltaleImpl.hh 27 Oct 2003 17:08:35 -0000 1.9 @@ -1,8 +1,8 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> - * Copyright (C) 1999 Graydon Hoare <[email protected]> + * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Graydon Hoare <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -29,67 +29,78 @@ #include <Berlin/SubjectImpl.hh> #include <vector> -class TelltaleImpl : public virtual POA_Fresco::Telltale, - public SubjectImpl +namespace Berlin { - public: - TelltaleImpl(Fresco::TelltaleConstraint_ptr, CORBA::ULong m = 0); - virtual ~TelltaleImpl(); - virtual void set(Fresco::Telltale::Mask); - virtual void clear(Fresco::Telltale::Mask); - virtual CORBA::Boolean test(Fresco::Telltale::Mask); - virtual void modify(Fresco::Telltale::Mask, CORBA::Boolean); - CORBA::ULong state() { return _mask;} + namespace CommandKit + { + class TelltaleImpl : public virtual POA_Fresco::Telltale, + public SubjectImpl + { + public: + TelltaleImpl(Fresco::TelltaleConstraint_ptr, CORBA::ULong m = 0); + virtual ~TelltaleImpl(); + virtual void set(Fresco::Telltale::Mask); + virtual void clear(Fresco::Telltale::Mask); + virtual CORBA::Boolean test(Fresco::Telltale::Mask); + virtual void modify(Fresco::Telltale::Mask, CORBA::Boolean); + CORBA::ULong state() { return _mask;} - virtual void constraint(Fresco::TelltaleConstraint_ptr); - virtual Fresco::TelltaleConstraint_ptr constraint(); + virtual void constraint(Fresco::TelltaleConstraint_ptr); + virtual Fresco::TelltaleConstraint_ptr constraint(); - protected: - Prague::Mutex _mutex; - CORBA::ULong _mask; - Fresco::TelltaleConstraint_var _constraint; -}; + protected: + Prague::Mutex _mutex; + CORBA::ULong _mask; + Fresco::TelltaleConstraint_var _constraint; + }; -class TelltaleConstraintImpl : public virtual POA_Fresco::TelltaleConstraint, - public virtual RefCountBaseImpl -{ - typedef std::vector<Fresco::Telltale_var> tlist_t; - public: - TelltaleConstraintImpl() {} - virtual ~TelltaleConstraintImpl() {} - void add(Fresco::Telltale_ptr); - void remove(Fresco::Telltale_ptr); - virtual void trymodify(Fresco::Telltale_ptr, Fresco::Telltale::Mask, CORBA::Boolean) = 0; - protected: - Prague::Mutex _mutex; - tlist_t _telltales; -}; + class TelltaleConstraintImpl : public virtual POA_Fresco::TelltaleConstraint, + public virtual RefCountBaseImpl + { + typedef std::vector<Fresco::Telltale_var> tlist_t; + public: + TelltaleConstraintImpl() {} + virtual ~TelltaleConstraintImpl() {} + void add(Fresco::Telltale_ptr); + void remove(Fresco::Telltale_ptr); + virtual void trymodify(Fresco::Telltale_ptr, Fresco::Telltale::Mask, + CORBA::Boolean) = 0; + protected: + Prague::Mutex _mutex; + tlist_t _telltales; + }; -class ExclusiveChoice : public TelltaleConstraintImpl -{ -public: - ExclusiveChoice(Fresco::Telltale::Mask); - virtual void trymodify(Fresco::Telltale_ptr, Fresco::Telltale::Mask, CORBA::Boolean); -private: - Fresco::Telltale::Mask _mask; -}; + class ExclusiveChoice : public TelltaleConstraintImpl + { + public: + ExclusiveChoice(Fresco::Telltale::Mask); + virtual void trymodify(Fresco::Telltale_ptr, Fresco::Telltale::Mask, + CORBA::Boolean); + private: + Fresco::Telltale::Mask _mask; + }; -class SelectionRequired : public TelltaleConstraintImpl -{ -public: - SelectionRequired(Fresco::Telltale::Mask); - virtual void trymodify(Fresco::Telltale_ptr, Fresco::Telltale::Mask, CORBA::Boolean); -private: - Fresco::Telltale::Mask _mask; -}; + class SelectionRequired : public TelltaleConstraintImpl + { + public: + SelectionRequired(Fresco::Telltale::Mask); + virtual void trymodify(Fresco::Telltale_ptr, Fresco::Telltale::Mask, + CORBA::Boolean); + private: + Fresco::Telltale::Mask _mask; + }; -class ExclusiveRequired : public TelltaleConstraintImpl -{ -public: - ExclusiveRequired(Fresco::Telltale::Mask); - virtual void trymodify(Fresco::Telltale_ptr, Fresco::Telltale::Mask, CORBA::Boolean); -private: - Fresco::Telltale::Mask _mask; -}; + class ExclusiveRequired : public TelltaleConstraintImpl + { + public: + ExclusiveRequired(Fresco::Telltale::Mask); + virtual void trymodify(Fresco::Telltale_ptr, Fresco::Telltale::Mask, + CORBA::Boolean); + private: + Fresco::Telltale::Mask _mask; + }; + + } // namespace +} // namespace #endif Index: TextBufferImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/TextBufferImpl.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- TextBufferImpl.cc 13 Aug 2003 18:56:53 -0000 1.12 +++ TextBufferImpl.cc 27 Oct 2003 17:08:35 -0000 1.13 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -26,204 +26,206 @@ using namespace Prague; using namespace Fresco; -TextBufferImpl::TextBufferImpl() { } -TextBufferImpl::~TextBufferImpl() { } +Berlin::CommandKit::TextBufferImpl::TextBufferImpl() { } +Berlin::CommandKit::TextBufferImpl::~TextBufferImpl() { } -CORBA::ULong TextBufferImpl::size() +CORBA::ULong Berlin::CommandKit::TextBufferImpl::size() { - Prague::Trace trace("TextBufferImpl::size()"); - Prague::Guard<Mutex> guard(_mutex); - return _buffer.size(); + Prague::Trace trace("TextBufferImpl::size()"); + Prague::Guard<Mutex> guard(_mutex); + return _buffer.size(); } -Unistring *TextBufferImpl::value() +Unistring * Berlin::CommandKit::TextBufferImpl::value() { - Prague::Trace trace("TextBufferImpl::value()"); - Prague::Guard<Mutex> guard(_mutex); - Unistring *us = new Unistring(_buffer.size(), _buffer.size(), const_cast<Unichar *>(_buffer.get()), false); - return us; + Prague::Trace trace("TextBufferImpl::value()"); + Prague::Guard<Mutex> guard(_mutex); + Unistring *us = new Unistring(_buffer.size(), _buffer.size(), + const_cast<Unichar *>(_buffer.get()), false); + return us; } -Unistring *TextBufferImpl::get_chars(CORBA::ULong pos, CORBA::ULong len) +Unistring * Berlin::CommandKit::TextBufferImpl::get_chars(CORBA::ULong pos, CORBA::ULong len) { - Prague::Trace trace("TextBufferImpl::get_chars(...)"); - Prague::Guard<Mutex> guard(_mutex); - CORBA::ULong fin = _buffer.size(); - CORBA::ULong start = pos > fin ? fin : pos; - CORBA::ULong end = start + len > fin ? fin : start + len; - Unistring *us = new Unistring(end-start, end-start, const_cast<Unichar *>(_buffer.get() + start), false); - return us; + Prague::Trace trace("TextBufferImpl::get_chars(...)"); + Prague::Guard<Mutex> guard(_mutex); + CORBA::ULong fin = _buffer.size(); + CORBA::ULong start = pos > fin ? fin : pos; + CORBA::ULong end = start + len > fin ? fin : start + len; + Unistring *us = new Unistring(end-start, end-start, + const_cast<Unichar *>(_buffer.get() + start), false); + return us; } - -CORBA::ULong TextBufferImpl::position() +CORBA::ULong Berlin::CommandKit::TextBufferImpl::position() { - Prague::Trace trace("TextBufferImpl::position()"); - Prague::Guard<Mutex> guard(_mutex); - return _buffer.position(); + Prague::Trace trace("TextBufferImpl::position()"); + Prague::Guard<Mutex> guard(_mutex); + return _buffer.position(); } -void TextBufferImpl::position(CORBA::ULong p) +void Berlin::CommandKit::TextBufferImpl::position(CORBA::ULong p) { - Prague::Trace trace("TextBufferImpl::position(...)"); - Fresco::TextBuffer::Change ch; - { - Prague::Guard<Mutex> guard(_mutex); - if (p < 0 || p > _buffer.size()) return; - _buffer.position(p); - ch.pos = _buffer.position(); - } - ch.len = 0; - ch.type = Fresco::TextBuffer::cursor; + Prague::Trace trace("TextBufferImpl::position(...)"); + Fresco::TextBuffer::Change ch; + { + Prague::Guard<Mutex> guard(_mutex); + if (p < 0 || p > _buffer.size()) return; + _buffer.position(p); + ch.pos = _buffer.position(); + } + ch.len = 0; + ch.type = Fresco::TextBuffer::cursor; - CORBA::Any any; - any <<= ch; - notify(any); + CORBA::Any any; + any <<= ch; + notify(any); } -void TextBufferImpl::forward() +void Berlin::CommandKit::TextBufferImpl::forward() { - Prague::Trace trace("TextBufferImpl::forward()"); - Fresco::TextBuffer::Change ch; - { - Prague::Guard<Mutex> guard(_mutex); - if (_buffer.position() >= _buffer.size()) return; - _buffer.forward(); - ch.pos = _buffer.position(); - } - ch.len = 0; - ch.type = Fresco::TextBuffer::cursor; + Prague::Trace trace("TextBufferImpl::forward()"); + Fresco::TextBuffer::Change ch; + { + Prague::Guard<Mutex> guard(_mutex); + if (_buffer.position() >= _buffer.size()) return; + _buffer.forward(); + ch.pos = _buffer.position(); + } + ch.len = 0; + ch.type = Fresco::TextBuffer::cursor; - CORBA::Any any; - any <<= ch; - notify(any); + CORBA::Any any; + any <<= ch; + notify(any); } -void TextBufferImpl::backward() +void Berlin::CommandKit::TextBufferImpl::backward() { - Prague::Trace trace("TextBufferImpl::backward()"); - Fresco::TextBuffer::Change ch; - { - Prague::Guard<Mutex> guard(_mutex); - if (_buffer.position() <= 0) return; - _buffer.backward(); - ch.pos = _buffer.position(); - } - ch.len = 0; - ch.type = Fresco::TextBuffer::cursor; + Prague::Trace trace("TextBufferImpl::backward()"); + Fresco::TextBuffer::Change ch; + { + Prague::Guard<Mutex> guard(_mutex); + if (_buffer.position() <= 0) return; + _buffer.backward(); + ch.pos = _buffer.position(); + } + ch.len = 0; + ch.type = Fresco::TextBuffer::cursor; - CORBA::Any any; - any <<= ch; - notify(any); + CORBA::Any any; + any <<= ch; + notify(any); } -void TextBufferImpl::shift(CORBA::Long d) +void Berlin::CommandKit::TextBufferImpl::shift(CORBA::Long d) { - Prague::Trace trace("TextBufferImpl::size()"); - Fresco::TextBuffer::Change ch; - { - Prague::Guard<Mutex> guard(_mutex); - _buffer.shift(d); - ch.pos = _buffer.position(); - } - ch.len = 0; - ch.type = Fresco::TextBuffer::cursor; + Prague::Trace trace("TextBufferImpl::size()"); + Fresco::TextBuffer::Change ch; + { + Prague::Guard<Mutex> guard(_mutex); + _buffer.shift(d); + ch.pos = _buffer.position(); + } + ch.len = 0; + ch.type = Fresco::TextBuffer::cursor; - CORBA::Any any; - any <<= ch; - notify(any); + CORBA::Any any; + any <<= ch; + notify(any); } -void TextBufferImpl::insert_char(Unichar u) +void Berlin::CommandKit::TextBufferImpl::insert_char(Unichar u) { - Prague::Trace trace("TextBufferImpl::insert_char(...)"); - Fresco::TextBuffer::Change ch; - { - Prague::Guard<Mutex> guard(_mutex); - ch.pos = _buffer.position(); - _buffer.insert(u); - } - ch.len = 1; - ch.type = Fresco::TextBuffer::insert; + Prague::Trace trace("TextBufferImpl::insert_char(...)"); + Fresco::TextBuffer::Change ch; + { + Prague::Guard<Mutex> guard(_mutex); + ch.pos = _buffer.position(); + _buffer.insert(u); + } + ch.len = 1; + ch.type = Fresco::TextBuffer::insert; - CORBA::Any any; - any <<= ch; - notify(any); + CORBA::Any any; + any <<= ch; + notify(any); } -void TextBufferImpl::insert_string(const Unistring &s) +void Berlin::CommandKit::TextBufferImpl::insert_string(const Unistring &s) { - Prague::Trace trace("TextBufferImpl::insert_string(...)"); - if (s.length() == 0) return; + Prague::Trace trace("TextBufferImpl::insert_string(...)"); + if (s.length() == 0) return; - Fresco::TextBuffer::Change ch; - ch.len = s.length(); - Unichar u[ch.len]; - for (long i = 0; i < ch.len; i++) u[i] = s[i]; + Fresco::TextBuffer::Change ch; + ch.len = s.length(); + Unichar u[ch.len]; + for (long i = 0; i < ch.len; i++) + u[i] = s[i]; - { - Prague::Guard<Mutex> guard(_mutex); - ch.pos = _buffer.position(); - _buffer.insert(u,ch.len); - } + { + Prague::Guard<Mutex> guard(_mutex); + ch.pos = _buffer.position(); + _buffer.insert(u,ch.len); + } - ch.type = Fresco::TextBuffer::insert; + ch.type = Fresco::TextBuffer::insert; - CORBA::Any any; - any <<= ch; - notify(any); + CORBA::Any any; + any <<= ch; + notify(any); } -void TextBufferImpl::remove_backward(CORBA::ULong n) +void Berlin::CommandKit::TextBufferImpl::remove_backward(CORBA::ULong n) { - Prague::Trace trace("TextBufferImpl::remove_backward(...)"); - Fresco::TextBuffer::Change ch; - { - Prague::Guard<Mutex> guard(_mutex); - ch.pos = _buffer.position(); - n = std::min(n, ch.pos); - if (n == 0) return; - _buffer.remove_backward(n); - } - ch.len = -n; - ch.type = Fresco::TextBuffer::remove; + Prague::Trace trace("TextBufferImpl::remove_backward(...)"); + Fresco::TextBuffer::Change ch; + { + Prague::Guard<Mutex> guard(_mutex); + ch.pos = _buffer.position(); + n = std::min(n, ch.pos); + if (n == 0) return; + _buffer.remove_backward(n); + } + ch.len = -n; + ch.type = Fresco::TextBuffer::remove; - CORBA::Any any; - any <<= ch; - notify(any); + CORBA::Any any; + any <<= ch; + notify(any); } -void TextBufferImpl::remove_forward(CORBA::ULong n) +void Berlin::CommandKit::TextBufferImpl::remove_forward(CORBA::ULong n) { - Prague::Trace trace("TextBufferImpl::remove_forward(...)"); - Fresco::TextBuffer::Change ch; - { - Prague::Guard<Mutex> guard(_mutex); - ch.pos = _buffer.position(); - n = std::min(n, _buffer.size() - ch.pos); - if (n == 0) return; - _buffer.remove_forward(n); - } - ch.len = n; - ch.type = Fresco::TextBuffer::remove; + Prague::Trace trace("TextBufferImpl::remove_forward(...)"); + Fresco::TextBuffer::Change ch; + { + Prague::Guard<Mutex> guard(_mutex); + ch.pos = _buffer.position(); + n = std::min(n, _buffer.size() - ch.pos); + if (n == 0) return; + _buffer.remove_forward(n); + } + ch.len = n; + ch.type = Fresco::TextBuffer::remove; - CORBA::Any any; - any <<= ch; - notify(any); + CORBA::Any any; + any <<= ch; + notify(any); } -void TextBufferImpl::clear() { - Prague::Trace trace("TextBufferImpl::clear()"); - Fresco::TextBuffer::Change ch; - ch.type = Fresco::TextBuffer::remove; - { - Prague::Guard<Mutex> guard(_mutex); - ch.len = _buffer.size(); - ch.pos = 0; - _buffer.clear_buffer(); - } +void Berlin::CommandKit::TextBufferImpl::clear() { + Prague::Trace trace("TextBufferImpl::clear()"); + Fresco::TextBuffer::Change ch; + ch.type = Fresco::TextBuffer::remove; + { + Prague::Guard<Mutex> guard(_mutex); + ch.len = _buffer.size(); + ch.pos = 0; + _buffer.clear_buffer(); + } - CORBA::Any any; - any <<= ch; - notify(any); + CORBA::Any any; + any <<= ch; + notify(any); } Index: TextBufferImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Commands/TextBufferImpl.hh,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- TextBufferImpl.hh 1 Aug 2003 16:47:18 -0000 1.10 +++ TextBufferImpl.hh 27 Oct 2003 17:08:35 -0000 1.11 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Stefan Seefeld <[email protected]> * 2001 Tobias Hunger <[email protected]> * http://www.fresco.org * @@ -29,28 +29,35 @@ #include <Berlin/SubjectImpl.hh> #include <Berlin/GapBuffer.hh> -class TextBufferImpl : public virtual POA_Fresco::TextBuffer, - public SubjectImpl +namespace Berlin { - public: - TextBufferImpl(); - virtual ~TextBufferImpl(); - virtual CORBA::ULong size(); - virtual Fresco::Unistring *value(); - virtual Fresco::Unistring *get_chars(CORBA::ULong, CORBA::ULong); - virtual CORBA::ULong position(); - virtual void position(CORBA::ULong); - virtual void forward(); - virtual void backward(); - virtual void shift(CORBA::Long d); - virtual void insert_char(Fresco::Unichar); - virtual void insert_string(const Fresco::Unistring &); - virtual void remove_backward(CORBA::ULong); - virtual void remove_forward(CORBA::ULong); - virtual void clear(); - private: - GapBuffer<Fresco::Unichar, 32> _buffer; - Prague::Mutex _mutex; -}; + namespace CommandKit + { + class TextBufferImpl : public virtual POA_Fresco::TextBuffer, + public SubjectImpl + { + public: + TextBufferImpl(); + virtual ~TextBufferImpl(); + virtual CORBA::ULong size(); + virtual Fresco::Unistring *value(); + virtual Fresco::Unistring *get_chars(CORBA::ULong, CORBA::ULong); + virtual CORBA::ULong position(); + virtual void position(CORBA::ULong); + virtual void forward(); + virtual void backward(); + virtual void shift(CORBA::Long d); + virtual void insert_char(Fresco::Unichar); + virtual void insert_string(const Fresco::Unistring &); + virtual void remove_backward(CORBA::ULong); + virtual void remove_forward(CORBA::ULong); + virtual void clear(); + private: + GapBuffer<Fresco::Unichar, 32> _buffer; + Prague::Mutex _mutex; + }; + + } // namespace +} // namespace #endif