Boost logo

Boost :

From: Ullrich Koethe (koethe_at_[hidden])
Date: 2000-12-07 12:59:53

I strongly agree that this is a very important extension. Here is an
example that might be a little easier to explain:

Given two modules:

- contains wrapped C++ user interface widgets
  including, say, "Window"
- contains application logic and a new widget
  derived from "Window"

Now the problem is: how can we use "ResultsWindow" like any window
defined in the UI module, *without* merging the two modules into one?

I think it can already be done with BPL. (At least, the following worked
in my tests.)

1. wrap the UI classes into uimodule.cpp as usual.

2. in uimodule.cpp: define functions to retrieve the class object for
   any class needed in another module:

    boost::python::detail::extension_class<Window> * get_window_class()
        dynamic_cast<boost::python::detail::extension_class<Window> *>

   Declare these functions in a header "uicommon.hpp"

3. Wrap the application logic and "ResultWindow" into logicmodule.cpp
   as usual:

              reswindow_class(logicmodule, "ResultWindow");

4. in logicmodule.cpp:
   - Include "uicommon.hpp"
   - declare the wrapped "Window" as base of the wrapped

5. *Dynamically* link against

     g++ -shared -o logicmodule.o \

6. Then in Python

>>> import ui
>>> import logic
>>> result_window = logic.ResultWindow()

Function show() from module ui can be applied to an object from module

[Note: to make this work, line 33 in module_builder.cpp must be
commented out:
     // assert(name_holder.get() == 0);

David, is there anything inherently wrong with this? It certainly works
in a simple test setting.


|                                                                |
| Ullrich Koethe  Universität Hamburg / University of Hamburg    |
|                 FB Informatik / Dept. of Computer Science      |
|                 AB Kognitive Systeme / Cognitive Systems Group |
|                                                                |
| Phone: +49 (0)40 42883-2573                Vogt-Koelln-Str. 30 |
| Fax:   +49 (0)40 42883-2572                D - 22527 Hamburg   |
| Email: u.koethe_at_[hidden]               Germany             |
|        koethe_at_[hidden]                        |
| WWW:      |

Boost list run by bdawes at, gregod at, cpdaniel at, john at