Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
metaclass issue
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post will appear after it is approved by moderators
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Aleh Arol  
View profile  
 More options May 21 2012, 6:20 am
From: Aleh Arol <aleh.a...@gmail.com>
Date: Mon, 21 May 2012 13:20:06 +0300
Local: Mon, May 21 2012 6:20 am
Subject: metaclass issue

Hi,

I faced an issue I have no idea how to solve.I hope someone in the group
already saw that.
I have an Application class which is ogre.WindowEventListener
descendant, this means it's metaclass is 'Boost.Python.class' - the
metaclass derived from it's base. And the following program just works.

I want to provide my own metaclass which does conditional mixing of
mixins into derived application (e.g. if __debug__ bases =
(debug_mixin,) + bases ).

However if only I use my metaclass it stops working with:
Boost.Python.ArgumentError: Python argument types in
WindowEventUtilities.addWindowEventListener(RenderWindow, Application)
did not match C++ signature:
addWindowEventListener(Ogre::RenderWindow* window,
Ogre::WindowEventListener* listener)
File "/home/workfiles/devel/bc/src/bc/application/application.py", line
120, in <module>
  app.run()
File "/home/workfiles/devel/bc/src/bc/application/application.py", line
73, in run
  self)

See the program below(simplified minimal version):
import ogre.renderer.OGRE as ogre

class MyMetaclass(ogre.WindowEventListener.__class__):
    pass

class Application(ogre.WindowEventListener):
    '''BlackCloud base application class. Works as window events listener as
    well.
    '''

    __metaclass__ = MyMetaclass

    #overridables
    app_title = 'BlackCloud Demo'
    rendersystem_plugins = ('RenderSystem_GL', )
    scenemanager_plugins = ('Plugin_OctreeSceneManager', )
    rendersystem = 'OpenGL Rendering Subsystem'

    window_width = 1120
    window_height = 630
    camera_aspect_ratio = 16.0 / 10.0
    fullscreen = False

    main_log_filename = 'ogre3d.log'
    log_level = ogre.LL_NORMAL

    def __init__(self):
        ogre.WindowEventListener.__init__(self)

    def initialize(self):
        self.exit = False
        self.active = True

        #setup logging
        self.log_manager = ogre.LogManager()
        self.log = self.log_manager.createLog(self.main_log_filename,
                                                                    True,
                                                                    True,
                                                                    False)
        self.log_manager.setLogDetail(self.log_level)

        self.root = ogre.Root('', '')

        #loading plugins
        for plugin in self.rendersystem_plugins + self.scenemanager_plugins:
            self.root.loadPlugin(plugin)

        self.root.setRenderSystem(self.root.getRenderSystemByName(

self.rendersystem))

        self.render_system = self.root.getRenderSystem()

        self.initializeResources()
        self.root.initialise(False)

        self.render_window = self.root.createRenderWindow(self.app_title,
                                                          self.window_width,

self.window_height,
                                                          self.fullscreen)

        #have to be after render window creation because of material manager
        #initialization
        self.preloadResources()

        self.setupScene()

    def run(self):
        ogre.WindowEventUtilities.addWindowEventListener(self.render_window,
                                                         self)

        self.root.clearEventTimes()
        while not self.exit:
            if self.active:
                self.preUpdateWorld()
                self.updateWorld()
                self.postUpdateWorld()
                self.exit = self.exit or not self.root.renderOneFrame()
            ogre.WindowEventUtilities.messagePump()

    def preUpdateWorld(self):
        pass

    def updateWorld(self):
        pass

    def postUpdateWorld(self):
        pass

    def initializeResources(self):
        pass

    def preloadResources(self):
        pass

    def setupScene(self):
        pass

    def windowClosed(self, render_window):
        self.exit = True

    def windowFocusChange(self, render_window):
        self.active = render_window.isVisible() and render_window.isActive()

    def cleanup(self):

ogre.WindowEventUtilities.removeWindowEventListener(self.render_window,
                                                         self)

        del self.render_window
        del self.root

if __name__ == '__main__':
    try:
        app = Application()
        app.initialize()
        app.run()
        app.cleanup()
    except ogre.OgreException, e:
        print e

Attaching file just in case. So just commenting out __metaclass__ line
makes it work again - with __metaclass__ it says about wrong C++
signature. Why?
Thanks in advance.

--
Best regards,
Aleh Arol

  app.py
3K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »