From ca5411f913b77fbcec30f2b35b8a0d0a65fa5649 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 29 Sep 2006 22:06:28 +0000 Subject: [PATCH] This commit introduces Application_pimpl and cleanup the header includes of the affected .C files. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15182 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/scons/scons_manifest.py | 1 + src/BufferView.C | 1 + src/LaTeX.C | 1 + src/buffer.C | 1 + src/buffer_funcs.C | 1 + src/format.C | 1 + src/frontends/Application.C | 30 +++++++++--------- src/frontends/Application.h | 35 ++++++++------------- src/frontends/Application_pimpl.h | 40 ++++++++++++++++++++++++ src/frontends/LyXView.C | 1 - src/frontends/LyXView.h | 1 + src/frontends/Makefile.am | 1 + src/frontends/controllers/ControlPrefs.C | 1 + src/frontends/controllers/ControlRef.C | 2 ++ src/frontends/gtk/GuiApplication.C | 6 +++- src/frontends/lyx_gui.h | 2 -- src/frontends/qt3/GuiApplication.C | 6 +++- src/frontends/qt4/GuiApplication.C | 6 +++- src/insets/insetinclude.C | 1 + src/insets/insetref.C | 1 + src/lyx_cb.C | 1 + src/lyx_main.C | 2 ++ src/lyxfunc.C | 2 ++ src/mathed/InsetMathNest.C | 5 +++ src/text2.C | 4 +++ 25 files changed, 111 insertions(+), 42 deletions(-) create mode 100644 src/frontends/Application_pimpl.h diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index be61a3ff07..c898cc9a17 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -429,6 +429,7 @@ src_insets_files = Split(''' src_frontends_header_files = Split(''' Alert.h Alert_pimpl.h + Application_pimpl.h Application.h Clipboard.h Dialogs.h diff --git a/src/BufferView.C b/src/BufferView.C index 1ea67ce9df..d3a09a53df 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -18,6 +18,7 @@ #include "buffer.h" #include "buffer_funcs.h" +#include "bufferlist.h" #include "bufferparams.h" #include "coordcache.h" #include "CutAndPaste.h" diff --git a/src/LaTeX.C b/src/LaTeX.C index 112e577876..17854a217a 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -14,6 +14,7 @@ #include +#include "bufferlist.h" #include "LaTeX.h" #include "gettext.h" #include "lyxrc.h" diff --git a/src/buffer.C b/src/buffer.C index 1cd063a26a..2ce60e9dfc 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -15,6 +15,7 @@ #include "author.h" #include "BranchList.h" #include "buffer_funcs.h" +#include "bufferlist.h" #include "bufferparams.h" #include "counters.h" #include "Bullet.h" diff --git a/src/buffer_funcs.C b/src/buffer_funcs.C index 782ae4c68f..f4d7726555 100644 --- a/src/buffer_funcs.C +++ b/src/buffer_funcs.C @@ -14,6 +14,7 @@ #include "buffer_funcs.h" #include "buffer.h" +#include "bufferlist.h" #include "bufferparams.h" #include "dociterator.h" #include "counters.h" diff --git a/src/format.C b/src/format.C index 7de79556ff..147ba7e6fb 100644 --- a/src/format.C +++ b/src/format.C @@ -16,6 +16,7 @@ #include "lyxrc.h" #include "debug.h" #include "gettext.h" +#include "lyxsocket.h" #include "frontends/Application.h" #include "frontends/Alert.h" //to be removed? diff --git a/src/frontends/Application.C b/src/frontends/Application.C index 22417f7ed6..9e95d81b38 100644 --- a/src/frontends/Application.C +++ b/src/frontends/Application.C @@ -12,8 +12,11 @@ #include "Application.h" -#include "funcrequest.h" +#include "Application_pimpl.h" +#include "Gui.h" + #include "LyXAction.h" +#include "lyxfunc.h" #include "lyxrc.h" #include "LyXView.h" @@ -21,64 +24,63 @@ #include "support/os.h" #include "support/package.h" -#include using lyx::support::package; namespace lyx { namespace frontend { - Application::Application(int &, char **) { + pimpl_ = new Application_pimpl; } LyXFunc & Application::lyxFunc() { - return *lyxfunc_.get(); + return *pimpl_->lyxfunc_.get(); } LyXFunc const & Application::lyxFunc() const { - return *lyxfunc_.get(); + return *pimpl_->lyxfunc_.get(); } LyXServer & Application::server() { - return *lyx_server_.get(); + return *pimpl_->lyx_server_.get(); } LyXServer const & Application::server() const { - return *lyx_server_.get(); + return *pimpl_->lyx_server_.get(); } LyXServerSocket & Application::socket() { - return *lyx_socket_.get(); + return *pimpl_->lyx_socket_.get(); } LyXServerSocket const & Application::socket() const { - return *lyx_socket_.get(); + return *pimpl_->lyx_socket_.get(); } BufferList & Application::bufferList() { - return buffer_list_; + return pimpl_->buffer_list_; } BufferList const & Application::bufferList() const { - return buffer_list_; + return pimpl_->buffer_list_; } @@ -90,13 +92,13 @@ void Application::setBufferView(BufferView * buffer_view) int Application::start(std::string const & batch) { - lyx_server_.reset(new LyXServer(lyxfunc_.get(), lyxrc.lyxpipes)); - lyx_socket_.reset(new LyXServerSocket(lyxfunc_.get(), + pimpl_->lyx_server_.reset(new LyXServer(pimpl_->lyxfunc_.get(), lyxrc.lyxpipes)); + pimpl_->lyx_socket_.reset(new LyXServerSocket(pimpl_->lyxfunc_.get(), lyx::support::os::internal_path(package().temp_dir() + "/lyxsocket"))); // handle the batch commands the user asked for if (!batch.empty()) { - lyxfunc_->dispatch(lyxaction.lookupFunc(batch)); + pimpl_->lyxfunc_->dispatch(lyxaction.lookupFunc(batch)); } return exec(); diff --git a/src/frontends/Application.h b/src/frontends/Application.h index 1ee5c13840..d8cee6ca4b 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -11,26 +11,24 @@ #ifndef LYX_APPLICATION_H #define LYX_APPLICATION_H -#include "bufferlist.h" -#include "lyxfunc.h" -#include "lyxserver.h" -#include "lyxsocket.h" - #include #include +class BufferList; class BufferView; -class LyXView; - +class LyXFunc; +class LyXServer; +class LyXServerSocket; + namespace lyx { namespace frontend { +struct Application_pimpl; class Clipboard; class Gui; class Selection; - /// The main application class /** There should be only one instance of this class. No Qt object @@ -76,22 +74,15 @@ public: void setBufferView(BufferView * buffer_view); protected: - /// + /// This BufferView is the one receiving Clipboard and Selection + /// Events + /// FIXME: \todo use Gui::currentView() in the future BufferView * buffer_view_; - // FIXME: lyxfunc_ should be private. But the actual construction is done in - // GuiApplication for now. - - /// our function handler - boost::scoped_ptr lyxfunc_; - -private: - /// - boost::scoped_ptr lyx_server_; - /// - boost::scoped_ptr lyx_socket_; - /// - BufferList buffer_list_; + /// Application private implementation. + /// FIXME: this should be private but LyXFunc construction + /// is still done in GuiApplication. + Application_pimpl * pimpl_; }; // Application diff --git a/src/frontends/Application_pimpl.h b/src/frontends/Application_pimpl.h new file mode 100644 index 0000000000..127707b2ee --- /dev/null +++ b/src/frontends/Application_pimpl.h @@ -0,0 +1,40 @@ +/** + * \file frontend/Application_pimpl.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Abdelrazak Younes + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef LYX_APPLICATION_PIMPL_H +#define LYX_APPLICATION_PIMPL_H + +#include "bufferlist.h" +#include "funcrequest.h" +#include "lyxserver.h" +#include "lyxsocket.h" + +#include + +namespace lyx { +namespace frontend { + +/// The main application class private implementation. +struct Application_pimpl +{ + /// + BufferList buffer_list_; + /// our function handler + boost::scoped_ptr lyxfunc_; + /// + boost::scoped_ptr lyx_server_; + /// + boost::scoped_ptr lyx_socket_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // LYX_APPLICATION_PIMPL_H diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index 2333f8d888..a7eb12bbb1 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -68,7 +68,6 @@ LyXView::LyXView() : work_area_(0), toolbars_(new Toolbars(*this)), autosave_timeout_(new Timeout(5000)), - lyxfunc_(new LyXFunc(this)), dialogs_(new Dialogs(*this)), controlcommand_(new ControlCommandBuffer(*this)) { diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index 309e4af1f0..a36178a7e1 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -16,6 +16,7 @@ #include "frontends/Application.h" #include "frontends/Toolbars.h" +#include "lyxfunc.h" #include #include #include diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index fd9d691e93..30daea585f 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -16,6 +16,7 @@ libfrontends_la_SOURCES = \ Alert.C \ Alert.h \ Alert_pimpl.h \ + Application_pimpl.h \ Application.C \ Application.h \ Dialogs.C \ diff --git a/src/frontends/controllers/ControlPrefs.C b/src/frontends/controllers/ControlPrefs.C index 221fe03a91..dfe5f1e6a6 100644 --- a/src/frontends/controllers/ControlPrefs.C +++ b/src/frontends/controllers/ControlPrefs.C @@ -15,6 +15,7 @@ #include "helper_funcs.h" #include "Kernel.h" +#include "bufferlist.h" #include "gettext.h" #include "funcrequest.h" #include "paper.h" diff --git a/src/frontends/controllers/ControlRef.C b/src/frontends/controllers/ControlRef.C index ff91fcb361..69b705306b 100644 --- a/src/frontends/controllers/ControlRef.C +++ b/src/frontends/controllers/ControlRef.C @@ -12,7 +12,9 @@ #include "ControlRef.h" + #include "buffer.h" +#include "bufferlist.h" #include "funcrequest.h" #include "frontends/Application.h" diff --git a/src/frontends/gtk/GuiApplication.C b/src/frontends/gtk/GuiApplication.C index 9b3db09851..3e0dc71482 100644 --- a/src/frontends/gtk/GuiApplication.C +++ b/src/frontends/gtk/GuiApplication.C @@ -28,6 +28,10 @@ #include "BufferView.h" +// FIXME: this is needed for now because LyXFunc is still constructed +// there. +#include "frontends/Application_pimpl.h" + #include "graphics/LoaderQueue.h" #include "support/lstrings.h" @@ -119,7 +123,7 @@ LyXView & GuiApplication::createView(unsigned int width, int view_id = gui().newView(width, height); GView & view = static_cast(gui().view(view_id)); - lyxfunc_.reset(new LyXFunc(&view)); + pimpl_->lyxfunc_.reset(new LyXFunc(&view)); LyX::ref().addLyXView(&view); diff --git a/src/frontends/lyx_gui.h b/src/frontends/lyx_gui.h index 4fd080f3a2..5469aee8ad 100644 --- a/src/frontends/lyx_gui.h +++ b/src/frontends/lyx_gui.h @@ -24,8 +24,6 @@ class Dialogs; class LColor_color; class LyXFont; class LyXComm; -class LyXDataSocket; -class LyXServerSocket; class FuncRequest; class LyXView; namespace lyx { diff --git a/src/frontends/qt3/GuiApplication.C b/src/frontends/qt3/GuiApplication.C index 894db2adb4..ccc4a51387 100644 --- a/src/frontends/qt3/GuiApplication.C +++ b/src/frontends/qt3/GuiApplication.C @@ -24,6 +24,10 @@ #include "BufferView.h" +// FIXME: this is needed for now because LyXFunc is still constructed +// there. +#include "frontends/Application_pimpl.h" + #include "graphics/LoaderQueue.h" #include "support/lstrings.h" @@ -176,7 +180,7 @@ LyXView & GuiApplication::createView(unsigned int width, int view_id = gui().newView(width, height); QtView & view = static_cast (gui().view(view_id)); - lyxfunc_.reset(new LyXFunc(&view)); + pimpl_->lyxfunc_.reset(new LyXFunc(&view)); // FIXME: for now we assume that there is only one LyXView with id = 0. /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0); diff --git a/src/frontends/qt4/GuiApplication.C b/src/frontends/qt4/GuiApplication.C index 75dcddfeb4..a18fb3c388 100644 --- a/src/frontends/qt4/GuiApplication.C +++ b/src/frontends/qt4/GuiApplication.C @@ -21,6 +21,10 @@ #include "BufferView.h" +// FIXME: this is needed for now because LyXFunc is still constructed +// there. +#include "frontends/Application_pimpl.h" + #include "graphics/LoaderQueue.h" #include "support/lstrings.h" @@ -173,7 +177,7 @@ LyXView & GuiApplication::createView(unsigned int width, int view_id = gui().newView(width, height); GuiView & view = static_cast (gui().view(view_id)); - lyxfunc_.reset(new LyXFunc(&view)); + pimpl_->lyxfunc_.reset(new LyXFunc(&view)); // FIXME: for now we assume that there is only one LyXView with id = 0. /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0); diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 1db1caf42b..6a964f97df 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -14,6 +14,7 @@ #include "buffer.h" #include "buffer_funcs.h" +#include "bufferlist.h" #include "bufferparams.h" #include "BufferView.h" #include "cursor.h" diff --git a/src/insets/insetref.C b/src/insets/insetref.C index 700961eee5..3ca4803bda 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -17,6 +17,7 @@ #include "funcrequest.h" #include "gettext.h" #include "LaTeXFeatures.h" +#include "lyxfunc.h" #include "outputparams.h" #include "sgml.h" diff --git a/src/lyx_cb.C b/src/lyx_cb.C index ab444b148b..aeaee83489 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -17,6 +17,7 @@ #include "lyx_cb.h" #include "buffer.h" +#include "bufferlist.h" #include "BufferView.h" #include "buffer_funcs.h" #include "cursor.h" diff --git a/src/lyx_main.C b/src/lyx_main.C index 100d845f53..1e328ac1d9 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -19,6 +19,7 @@ #include "buffer.h" #include "buffer_funcs.h" +#include "bufferlist.h" #include "converter.h" #include "debug.h" #include "encoding.h" @@ -33,6 +34,7 @@ #include "lyxfunc.h" #include "lyxlex.h" #include "lyxrc.h" +#include "lyxserver.h" #include "lyxtextclasslist.h" #include "MenuBackend.h" #include "mover.h" diff --git a/src/lyxfunc.C b/src/lyxfunc.C index a3625c5510..ea80d9fc8d 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -24,6 +24,7 @@ #include "BranchList.h" #include "buffer.h" #include "buffer_funcs.h" +#include "bufferlist.h" #include "bufferparams.h" #include "BufferView.h" #include "cursor.h" @@ -50,6 +51,7 @@ #include "lyxlex.h" #include "lyxrc.h" #include "lyxrow.h" +#include "lyxserver.h" #include "lyxtextclasslist.h" #include "lyxvc.h" #include "paragraph.h" diff --git a/src/mathed/InsetMathNest.C b/src/mathed/InsetMathNest.C index 87a41f628a..c357c94a7a 100644 --- a/src/mathed/InsetMathNest.C +++ b/src/mathed/InsetMathNest.C @@ -54,6 +54,11 @@ #include "frontends/Selection.h" #include "frontends/nullpainter.h" +//#include "bufferlist.h" +#include "funcrequest.h" +#include "lyxserver.h" +#include "lyxsocket.h" + #include using lyx::cap::copySelection; diff --git a/src/text2.C b/src/text2.C index be19942464..403300a987 100644 --- a/src/text2.C +++ b/src/text2.C @@ -23,6 +23,7 @@ #include "buffer.h" #include "buffer_funcs.h" +#include "bufferlist.h" #include "bufferparams.h" #include "BufferView.h" #include "Bullet.h" @@ -36,6 +37,7 @@ #include "gettext.h" #include "language.h" #include "LColor.h" +#include "lyxfunc.h" #include "lyxrc.h" #include "lyxrow.h" #include "lyxrow_funcs.h" @@ -43,6 +45,8 @@ #include "paragraph_funcs.h" #include "ParagraphParameters.h" #include "pariterator.h" +#include "lyxserver.h" +#include "lyxsocket.h" #include "undo.h" #include "vspace.h" -- 2.39.2