def register(cls):
    ''' Decorator to add a Message (and its revision) to the Protocol index.

    Example:

        .. code-block:: python

            @register
            class some_msg_1(Message):

                msgtype  = 'SOME-MSG'
                revision = 1

                @classmethod
                def create(cls, **metadata):
                    header = cls.create_header()
                    content = {}
                    return cls(header, metadata, content)

    '''
    key = (cls.msgtype, cls.revision)
    if key in index:
        raise ProtocolError("Duplicate message specification encountered: %r" % key)
    index[key] = cls
    return cls
def register ( cls ) : key = ( cls . msgtype , cls . revision ) if key in index : raise ProtocolError ( "Duplicate message specification encountered: %r" % key ) index [ key ] = cls return cls
Decorator to add a Message (and its revision) to the Protocol index.

    Example:

        .. code-block:: python

            @register
            class some_msg_1(Message):

                msgtype  = 'SOME-MSG'
                revision = 1

                @classmethod
                def create(cls, **metadata):
                    header = cls.create_header()
                    content = {}
                    return cls(header, metadata, content)