Hello,

As discussed in the list this patch introduce Application_pimpl and cleanup the header includes of the affected .C files. Will commit soon.

The BufferList is still there. If you want me to remove that please speak up. FWIW, I still think that it should remain in Application. It is stays I will handle also the Buffers close on exit.

I can feel that there is a misunderstanding on what is the frontend. If you feel that this is cleaner (I don't) I guess we could split Application in two classes: The first one will retain the pure virtual methods (Clipboard and Selection); the second one will handle the rest.

Abdel.



Index: buffer.C
===================================================================
--- buffer.C    (revision 15180)
+++ buffer.C    (working copy)
@@ -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"
Index: buffer_funcs.C
===================================================================
--- buffer_funcs.C      (revision 15180)
+++ buffer_funcs.C      (working copy)
@@ -14,6 +14,7 @@
 
 #include "buffer_funcs.h"
 #include "buffer.h"
+#include "bufferlist.h"
 #include "bufferparams.h"
 #include "dociterator.h"
 #include "counters.h"
Index: BufferView.C
===================================================================
--- BufferView.C        (revision 15180)
+++ BufferView.C        (working copy)
@@ -18,6 +18,7 @@
 
 #include "buffer.h"
 #include "buffer_funcs.h"
+#include "bufferlist.h"
 #include "bufferparams.h"
 #include "coordcache.h"
 #include "CutAndPaste.h"
Index: format.C
===================================================================
--- format.C    (revision 15180)
+++ format.C    (working copy)
@@ -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?
Index: frontends/Application.C
===================================================================
--- frontends/Application.C     (revision 15180)
+++ frontends/Application.C     (working copy)
@@ -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 <boost/scoped_ptr.hpp>
 
 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,14 @@
 
 int Application::start(std::string const & batch)
 {
-       lyx_server_.reset(new LyXServer(lyxfunc_.get(), lyxrc.lyxpipes));
-       lyx_socket_.reset(new LyXServerSocket(lyxfunc_.get(), 
+       pimpl_->lyxfunc_.reset(new LyXFunc(&gui().view(0)));
+       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();
Index: frontends/Application.h
===================================================================
--- frontends/Application.h     (revision 15180)
+++ frontends/Application.h     (working copy)
@@ -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 <boost/scoped_ptr.hpp>
 
 #include <string>
 
+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,23 +74,16 @@
        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.
+       /// Application private implementation.
+       /// FIXME: this should be private but LyXFunc construction
+       /// is still done in GuiApplication.
+       Application_pimpl * pimpl_;
 
-       /// our function handler
-       boost::scoped_ptr<LyXFunc> lyxfunc_;
-
-private:
-       ///
-       boost::scoped_ptr<LyXServer> lyx_server_;
-       ///
-       boost::scoped_ptr<LyXServerSocket> lyx_socket_;
-       ///
-       BufferList buffer_list_;
-
 }; // Application
 
 } // namespace frontend
Index: frontends/Application_pimpl.h
===================================================================
--- frontends/Application_pimpl.h       (revision 0)
+++ frontends/Application_pimpl.h       (revision 0)
@@ -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 <boost/scoped_ptr.hpp>
+
+namespace lyx {
+namespace frontend {
+
+/// The main application class private implementation.
+struct Application_pimpl 
+{
+       ///
+       BufferList buffer_list_;
+       /// our function handler
+       boost::scoped_ptr<LyXFunc> lyxfunc_;
+       ///
+       boost::scoped_ptr<LyXServer> lyx_server_;
+       ///
+       boost::scoped_ptr<LyXServerSocket> lyx_socket_;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // LYX_APPLICATION_PIMPL_H

Property changes on: frontends\Application_pimpl.h
___________________________________________________________________
Name: svn:eol-style
   + native

Index: frontends/controllers/ControlPrefs.C
===================================================================
--- frontends/controllers/ControlPrefs.C        (revision 15180)
+++ frontends/controllers/ControlPrefs.C        (working copy)
@@ -15,6 +15,7 @@
 #include "helper_funcs.h"
 #include "Kernel.h"
 
+#include "bufferlist.h"
 #include "gettext.h"
 #include "funcrequest.h"
 #include "paper.h"
Index: frontends/controllers/ControlRef.C
===================================================================
--- frontends/controllers/ControlRef.C  (revision 15180)
+++ frontends/controllers/ControlRef.C  (working copy)
@@ -12,7 +12,9 @@
 
 
 #include "ControlRef.h"
+
 #include "buffer.h"
+#include "bufferlist.h"
 #include "funcrequest.h"
 
 #include "frontends/Application.h"
Index: frontends/gtk/GuiApplication.C
===================================================================
--- frontends/gtk/GuiApplication.C      (revision 15180)
+++ frontends/gtk/GuiApplication.C      (working copy)
@@ -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 @@
        int view_id = gui().newView(width, height);
        GView & view = static_cast<GView &>(gui().view(view_id));
 
-       lyxfunc_.reset(new LyXFunc(&view));
+       pimpl_->lyxfunc_.reset(new LyXFunc(&view));
 
        LyX::ref().addLyXView(&view);
 
Index: frontends/lyx_gui.h
===================================================================
--- frontends/lyx_gui.h (revision 15180)
+++ frontends/lyx_gui.h (working copy)
@@ -24,8 +24,6 @@
 class LColor_color;
 class LyXFont;
 class LyXComm;
-class LyXDataSocket;
-class LyXServerSocket;
 class FuncRequest;
 class LyXView;
 namespace lyx {
Index: frontends/LyXView.C
===================================================================
--- frontends/LyXView.C (revision 15180)
+++ frontends/LyXView.C (working copy)
@@ -68,7 +68,6 @@
        : work_area_(0),
          toolbars_(new Toolbars(*this)),
          autosave_timeout_(new Timeout(5000)),
-         lyxfunc_(new LyXFunc(this)),
          dialogs_(new Dialogs(*this)),
          controlcommand_(new ControlCommandBuffer(*this))
 {
Index: frontends/LyXView.h
===================================================================
--- frontends/LyXView.h (revision 15180)
+++ frontends/LyXView.h (working copy)
@@ -16,6 +16,7 @@
 #include "frontends/Application.h"
 #include "frontends/Toolbars.h"
 
+#include "lyxfunc.h"
 #include <boost/scoped_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/signal.hpp>
Index: frontends/qt3/GuiApplication.C
===================================================================
--- frontends/qt3/GuiApplication.C      (revision 15180)
+++ frontends/qt3/GuiApplication.C      (working copy)
@@ -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 @@
        int view_id = gui().newView(width, height);
        QtView & view = static_cast<QtView &> (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);
Index: frontends/qt4/GuiApplication.C
===================================================================
--- frontends/qt4/GuiApplication.C      (revision 15180)
+++ frontends/qt4/GuiApplication.C      (working copy)
@@ -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 @@
        int view_id = gui().newView(width, height);
        GuiView & view = static_cast<GuiView &> (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);
Index: insets/insetinclude.C
===================================================================
--- insets/insetinclude.C       (revision 15180)
+++ insets/insetinclude.C       (working copy)
@@ -14,6 +14,7 @@
 
 #include "buffer.h"
 #include "buffer_funcs.h"
+#include "bufferlist.h"
 #include "bufferparams.h"
 #include "BufferView.h"
 #include "cursor.h"
Index: insets/insetref.C
===================================================================
--- insets/insetref.C   (revision 15180)
+++ insets/insetref.C   (working copy)
@@ -17,6 +17,7 @@
 #include "funcrequest.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
+#include "lyxfunc.h"
 #include "outputparams.h"
 #include "sgml.h"
 
Index: LaTeX.C
===================================================================
--- LaTeX.C     (revision 15180)
+++ LaTeX.C     (working copy)
@@ -14,6 +14,7 @@
 
 #include <config.h>
 
+#include "bufferlist.h"
 #include "LaTeX.h"
 #include "gettext.h"
 #include "lyxrc.h"
Index: lyx_cb.C
===================================================================
--- lyx_cb.C    (revision 15180)
+++ lyx_cb.C    (working copy)
@@ -17,6 +17,7 @@
 #include "lyx_cb.h"
 
 #include "buffer.h"
+#include "bufferlist.h"
 #include "BufferView.h"
 #include "buffer_funcs.h"
 #include "cursor.h"
Index: lyx_main.C
===================================================================
--- lyx_main.C  (revision 15180)
+++ lyx_main.C  (working copy)
@@ -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"
Index: lyxfunc.C
===================================================================
--- lyxfunc.C   (revision 15180)
+++ lyxfunc.C   (working copy)
@@ -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"
Index: mathed/InsetMathNest.C
===================================================================
--- mathed/InsetMathNest.C      (revision 15180)
+++ mathed/InsetMathNest.C      (working copy)
@@ -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 <sstream>
 
 using lyx::cap::copySelection;
Index: text2.C
===================================================================
--- text2.C     (revision 15180)
+++ text2.C     (working copy)
@@ -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"
 

Reply via email to