2727// -----------------------------------------------------------------------------
2828// Includes
2929// -----------------------------------------------------------------------------
30- #include " ticklisteners_wrap.h"
31- #include " utility/call_python.h"
30+ #include " modules/export_main.h"
31+ #include " tick_listeners_wrap.h"
32+ #include " networkid_validated_listeners_wrap.h"
3233
3334// -----------------------------------------------------------------------------
34- // Static singletons .
35+ // Functions that expose tick listener functionality to us .
3536// -----------------------------------------------------------------------------
36- static CTickListenerManager s_TickListenerManager;
37+ void export_tick_listener ();
38+ void export_networkid_validated_listener ();
3739
3840// -----------------------------------------------------------------------------
39- // TickListenerManager accessor .
41+ // Exposes the tick_c module .
4042// -----------------------------------------------------------------------------
41- CTickListenerManager* get_tick_listener_manager ( )
43+ DECLARE_SP_MODULE (listener_c )
4244{
43- return &s_TickListenerManager;
45+ export_tick_listener ();
46+ export_networkid_validated_listener ();
4447}
4548
4649// -----------------------------------------------------------------------------
47- // Adds a callable to the end of the CTickListenerManager vector.
50+ // Exposes CTickListenerManager
4851// -----------------------------------------------------------------------------
49- void CTickListenerManager::register_listener (PyObject* pCallable )
52+ void export_tick_listener ( )
5053{
51- // Get the object instance of the callable
52- object oCallable = object (handle<>(borrowed (pCallable)));
54+ BOOST_ABSTRACT_CLASS (CTickListenerManager)
5355
54- // Is the callable already in the vector?
55- if ( !m_vecCallables.HasElement (oCallable) )
56- {
57- // Add the callable to the vector
58- m_vecCallables.AddToTail (oCallable);
59- }
60- }
56+ CLASS_METHOD (CTickListenerManager,
57+ register_listener,
58+ " Adds the given callable to the end of the tick listener vector." ,
59+ args (" pCallable" )
60+ )
6161
62- // -----------------------------------------------------------------------------
63- // Removes all instances of a callable from the CTickListenerManager vector.
64- // -----------------------------------------------------------------------------
65- void CTickListenerManager::unregister_listener (PyObject* pCallable)
66- {
67- // Get the object instance of the callable
68- object oCallable = object (handle<>(borrowed (pCallable)));
62+ CLASS_METHOD (CTickListenerManager,
63+ unregister_listener,
64+ " Removes the given callable from the tick listener vector." ,
65+ args (" pCallable" )
66+ )
6967
70- // Remove the callback from the ServerCommandManager instance
71- m_vecCallables.FindAndRemove (oCallable);
68+ BOOST_END_CLASS ()
69+
70+ BOOST_FUNCTION (get_tick_listener_manager,
71+ " Returns the CTickListListenerManager instance" ,
72+ reference_existing_object_policy ()
73+ );
7274}
7375
7476// -----------------------------------------------------------------------------
75- // Calls all registered tick listeners.
77+ // Exposes CNetworkIDValidatedListenerManager
7678// -----------------------------------------------------------------------------
77- void CTickListenerManager::call_tick_listeners ()
79+ void export_networkid_validated_listener ()
7880{
79- for (int i = 0 ; i < m_vecCallables.Count (); i++)
80- {
81- BEGIN_BOOST_PY ()
81+ BOOST_ABSTRACT_CLASS (CNetworkIDValidatedListenerManager)
8282
83- // Get the PyObject instance of the callable
84- PyObject* pCallable = m_vecCallables[i].ptr ();
83+ CLASS_METHOD (CNetworkIDValidatedListenerManager,
84+ register_listener,
85+ " Adds the given callable to the end of the network ID validated listener vector." ,
86+ args (" pCallable" )
87+ )
8588
86- // Call the callable
87- CALL_PY_FUNC (pCallable);
89+ CLASS_METHOD (CNetworkIDValidatedListenerManager,
90+ unregister_listener,
91+ " Removes the given callable from the network ID validated listener vector." ,
92+ args (" pCallable" )
93+ )
8894
89- END_BOOST_PY_NORET ()
90- }
91- }
95+ BOOST_END_CLASS ()
96+
97+ BOOST_FUNCTION (get_networkid_validated_listener_manager,
98+ " Returns the CNetworkIDValidatedListenerManager instance" ,
99+ reference_existing_object_policy ()
100+ );
101+ }
0 commit comments