# Path: pyoptix/context.py
# def current_context():
#     return _context_stack[-1]
# 
# Path: pyoptix/mixins/destroyable.py
# class DestroyableObject(object):
#     def __init__(self, native):
#         self._native = native
# 
#     @property
#     def _safe_native(self):
#         if not self._native.is_destroyed:
#             return self._native
#         else:
#             raise RuntimeError('Underlying OptiX object was destroyed before.')
# 
# Path: pyoptix/mixins/graphnode.py
# class GraphNodeMixin(object):
#     def __init__(self):
#         self._parents = []
# 
#     def _add_parent(self, parent):
#         self._parents.append(parent)
# 
#     def _remove_parent(self, parent):
#         self._parents.remove(parent)
# 
# Path: pyoptix/mixins/hascontext.py
# class HasContextMixin(object):
#     def __init__(self, context):
#         self._context_ref = weakref.ref(context)
# 
#     @property
#     def _safe_context(self):
#         ctx = self._context_ref()
#         if ctx is not None:
#             return ctx
#         else:
#             raise RuntimeError('Context of this object is no longer valid')


import six
from pyoptix.context import current_context
from pyoptix.mixins.destroyable import DestroyableObject
from pyoptix.mixins.graphnode import GraphNodeMixin
from pyoptix.mixins.hascontext import HasContextMixin


class Acceleration(GraphNodeMixin, HasContextMixin, DestroyableObject):
    def __init__(self, builder="NoAccel", traverser="NoAccel", **kwargs):
        HasContextMixin.__init__(self, current_context())

# Path: pyoptix/context.py
# def current_context():
#     return _context_stack[-1]
# 
# Path: pyoptix/mixins/destroyable.py
# class DestroyableObject(object):
#     def __init__(self, native):
#         self._native = native
# 
#     @property
#     def _safe_native(self):
#         if not self._native.is_destroyed:
#             return self._native
#         else:
#             raise RuntimeError('Underlying OptiX object was destroyed before.')
# 
# Path: pyoptix/mixins/graphnode.py
# class GraphNodeMixin(object):
#     def __init__(self):
#         self._parents = []
# 
#     def _add_parent(self, parent):
#         self._parents.append(parent)
# 
#     def _remove_parent(self, parent):
#         self._parents.remove(parent)
# 
# Path: pyoptix/mixins/hascontext.py
# class HasContextMixin(object):
#     def __init__(self, context):
#         self._context_ref = weakref.ref(context)
# 
#     @property
#     def _safe_context(self):
#         ctx = self._context_ref()
#         if ctx is not None:
#             return ctx
#         else:
#             raise RuntimeError('Context of this object is no longer valid')


# Path: pyoptix/acceleration.py
import six
from pyoptix.context import current_context
from pyoptix.mixins.destroyable import DestroyableObject
from pyoptix.mixins.graphnode import GraphNodeMixin
from pyoptix.mixins.hascontext import HasContextMixin



class Acceleration(GraphNodeMixin, HasContextMixin, DestroyableObject):
    def __init__(self, builder="NoAccel", traverser="NoAccel", **kwargs):
        HasContextMixin.__init__(self, current_context())

        DestroyableObject.__init__(self, self._safe_context._create_accelerator(builder, traverser))