#
# Init file for osg package.
#

# Hack to bring in all symbols OpenSG is linked against and loads from plugins
# Search for : setdlopenflags and RTLD_GLOBAL on google to see why
original_dlopen_flags = None
try:
   import dl, sys
   original_dlopen_flags = sys.getdlopenflags()
   sys.setdlopenflags(original_dlopen_flags | dl.RTLD_GLOBAL)
except:
   pass

# Import everything from the opensg module
from _osg2 import *

if original_dlopen_flags:
   sys.setdlopenflags(original_dlopen_flags)

# Constants
#import const

# Import other things.
from fcd_reflector import FcdReflector, FieldReflector
import helpers

#base_fc_types = [_osg2.AttachementContainer, _osg2.StateChunkBase]
# Add comparison operator to all field containers
def _fc_cmp(self, other):
   """ Comparison operator for field containers. """
   id_self = None
   id_other = None
   if not self is None:
      id_self = _osg2.getContainerId(self)
   if not other is None:
      id_other = _osg2.getContainerId(other)
      
   return cmp(id_self, id_other)

def _fc_hash(self):
   if self is None:
      return -1
   else:
      return _osg2.getContainerId(self)


for (n,c) in _osg2.__dict__.iteritems():
   if isinstance(c,type) and ((_osg2.AttachmentContainer in c.__mro__) or \
                              (_osg2.StateChunkBase in c.__mro__)):
      c.__cmp__ = _fc_cmp
      c.__hash__ = _fc_hash

# Add cored node types
import cored_node
cored_node.addNodeCoreTypes()


