Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.network.multiplayer

Class EM_NET_OBJECT_FACTORY



Creation

Features

Invariants

indexing

description

Generates EM_NET_OBJECTs based on their type ID.

Object types need to be registered using add first. This can only be done
through EM_NET_OBJECT_TYPES or a descendant. See EM_NET_OBJECT_TYPES for
further details.

By default, there is one object factory per instance of a subclass of
EM_NET_BASE. You can access this factory through net_object_factory.

date

$Date: 2005/10/23 10:04:13 $

revision

$Revision: 1.15 $

class

EM_NET_OBJECT_FACTORY

create

make

-- Create a new object factory.

feature {EM_NET_OBJECT_TYPES} -- Element change

mark_initialized

-- Mark the factory as initialized with system objects.

feature {EM_NET_OBJECT_TYPES} -- Registration

add (a_type_id: INTEGER; creation_function: FUNCTION [ANY, TUPLE[], EM_NET_OBJECT])

-- Register a type_id to an object that is created by a creation_function.
-- a_type_id must not conflict with predefined system IDs.

require
system_id_valid: not is_initialized implies (a_type_id >= lowest_system_id and a_type_id <= highest_system_id)
user_id_valid: is_initialized implies (a_type_id > highest_system_id)
type_id_free: not type_map.has (a_type_id)

feature -- Application IDs

create_object_by_type_id (a_type_id: INTEGER): EM_NET_OBJECT

-- Create instance of an EM_NET_OBJECT that corresponds to a_type_id.

require
type_exists: has_object_type (a_type_id)

feature -- Information

has_object_type (a_type_id: INTEGER) : BOOLEAN

-- Do we have a creation agent for a given type id?

frozen highest_system_id: INTEGER

-- Highest type ID of a system objects

is_initialized: BOOLEAN

-- Has the factory been initialized with system objects?

frozen lowest_system_id: INTEGER

-- Lowest type ID of a system object

feature {EM_NET_OBJECT_TYPES} -- Implementation

type_map: DS_HASH_TABLE[FUNCTION[ANY, TUPLE, EM_NET_OBJECT], INTEGER]

-- Type map

invariant

type_map_created: type_map /= Void

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end