"""Support for simplified access to data on nodes of type omni.graph.nodes.GetTimeline

Get the main timeline properties
"""


import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn



class OgnTimelineGetDatabase(og.Database):
    """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetTimeline

    Class Members:
        node: Node being evaluated

    Attribute Value Properties:
        Outputs:
            outputs.endFrame
            outputs.endTime
            outputs.frame
            outputs.framesPerSecond
            outputs.isLooping
            outputs.isPlaying
            outputs.startFrame
            outputs.startTime
            outputs.time
    """

    # Imprint the generator and target ABI versions in the file for JIT generation
    GENERATOR_VERSION = (1, 41, 3)
    TARGET_VERSION = (2, 139, 12)

    # This is an internal object that provides per-class storage of a per-node data dictionary
    PER_NODE_DATA = {}

    # This is an internal object that describes unchanging attributes in a generic way
    # The values in this list are in no particular order, as a per-attribute tuple
    #     Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
    #     Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
    # You should not need to access any of this data directly, use the defined database interfaces
    INTERFACE = og.Database._get_interface([
        ('outputs:endFrame', 'double', 0, 'End Frame', "The end frame of the main timeline's play range.", {}, True, None, False, ''),
        ('outputs:endTime', 'double', 0, 'End Time', "The end time (in seconds) of the main timeline's play range.", {}, True, None, False, ''),
        ('outputs:frame', 'double', 0, 'Current Frame', "The current frame number of the main timeline's playhead.", {}, True, None, False, ''),
        ('outputs:framesPerSecond', 'double', 0, 'Frames Per Second', 'The number of frames per second of the main timeline.', {}, True, None, False, ''),
        ('outputs:isLooping', 'bool', 0, 'Is Looping', 'Is the main timeline currently looping?', {}, True, None, False, ''),
        ('outputs:isPlaying', 'bool', 0, 'Is Playing', 'Is the main timeline currently playing?', {}, True, None, False, ''),
        ('outputs:startFrame', 'double', 0, 'Start Frame', "The start frame of the main timeline's play range.", {}, True, None, False, ''),
        ('outputs:startTime', 'double', 0, 'Start Time', "The start time (in seconds) of the main timeline's play range.", {}, True, None, False, ''),
        ('outputs:time', 'double', 0, 'Current Time', "The current time (in seconds) of the main timeline's playhead.", {}, True, None, False, ''),
    ])

    class ValuesForInputs(og.DynamicAttributeAccess):
        LOCAL_PROPERTY_NAMES = { }
        """Helper class that creates natural hierarchical access to input attributes"""
        def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
            """Initialize simplified access for the attribute data"""
            context = node.get_graph().get_default_graph_context()
            super().__init__(context, node, attributes, dynamic_attributes)
            self._batchedReadAttributes = []
            self._batchedReadValues = []

        def _prefetch(self):
            readAttributes = self._batchedReadAttributes
            newValues = _og._prefetch_input_attributes_data(readAttributes)
            if len(readAttributes) == len(newValues):
                self._batchedReadValues = newValues

    class ValuesForOutputs(og.DynamicAttributeAccess):
        LOCAL_PROPERTY_NAMES = { }
        """Helper class that creates natural hierarchical access to output attributes"""
        def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
            """Initialize simplified access for the attribute data"""
            context = node.get_graph().get_default_graph_context()
            super().__init__(context, node, attributes, dynamic_attributes)
            self._batchedWriteValues = { }

        @property
        def endFrame(self):
            data_view = og.AttributeValueHelper(self._attributes.endFrame)
            return data_view.get()

        @endFrame.setter
        def endFrame(self, value):
            data_view = og.AttributeValueHelper(self._attributes.endFrame)
            data_view.set(value)

        @property
        def endTime(self):
            data_view = og.AttributeValueHelper(self._attributes.endTime)
            return data_view.get()

        @endTime.setter
        def endTime(self, value):
            data_view = og.AttributeValueHelper(self._attributes.endTime)
            data_view.set(value)

        @property
        def frame(self):
            data_view = og.AttributeValueHelper(self._attributes.frame)
            return data_view.get()

        @frame.setter
        def frame(self, value):
            data_view = og.AttributeValueHelper(self._attributes.frame)
            data_view.set(value)

        @property
        def framesPerSecond(self):
            data_view = og.AttributeValueHelper(self._attributes.framesPerSecond)
            return data_view.get()

        @framesPerSecond.setter
        def framesPerSecond(self, value):
            data_view = og.AttributeValueHelper(self._attributes.framesPerSecond)
            data_view.set(value)

        @property
        def isLooping(self):
            data_view = og.AttributeValueHelper(self._attributes.isLooping)
            return data_view.get()

        @isLooping.setter
        def isLooping(self, value):
            data_view = og.AttributeValueHelper(self._attributes.isLooping)
            data_view.set(value)

        @property
        def isPlaying(self):
            data_view = og.AttributeValueHelper(self._attributes.isPlaying)
            return data_view.get()

        @isPlaying.setter
        def isPlaying(self, value):
            data_view = og.AttributeValueHelper(self._attributes.isPlaying)
            data_view.set(value)

        @property
        def startFrame(self):
            data_view = og.AttributeValueHelper(self._attributes.startFrame)
            return data_view.get()

        @startFrame.setter
        def startFrame(self, value):
            data_view = og.AttributeValueHelper(self._attributes.startFrame)
            data_view.set(value)

        @property
        def startTime(self):
            data_view = og.AttributeValueHelper(self._attributes.startTime)
            return data_view.get()

        @startTime.setter
        def startTime(self, value):
            data_view = og.AttributeValueHelper(self._attributes.startTime)
            data_view.set(value)

        @property
        def time(self):
            data_view = og.AttributeValueHelper(self._attributes.time)
            return data_view.get()

        @time.setter
        def time(self, value):
            data_view = og.AttributeValueHelper(self._attributes.time)
            data_view.set(value)

        def _commit(self):
            _og._commit_output_attributes_data(self._batchedWriteValues)
            self._batchedWriteValues = { }

    class ValuesForState(og.DynamicAttributeAccess):
        """Helper class that creates natural hierarchical access to state attributes"""
        def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
            """Initialize simplified access for the attribute data"""
            context = node.get_graph().get_default_graph_context()
            super().__init__(context, node, attributes, dynamic_attributes)

    def __init__(self, node):
        super().__init__(node)
        dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
        self.inputs = OgnTimelineGetDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
        dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
        self.outputs = OgnTimelineGetDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
        dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
        self.state = OgnTimelineGetDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
