jp.go.aist.rtm.RTC
Class FactoryGlobal<ABSTRACTCLASS,IDENTIFIER>

java.lang.Object
  extended by jp.go.aist.rtm.RTC.FactoryGlobal<ABSTRACTCLASS,IDENTIFIER>
Direct Known Subclasses:
BufferFactory, ExecutionContextFactory, InPortConsumerFactory, InPortProviderFactory, LocalServiceFactory, OutPortConsumerFactory, OutPortProviderFactory, PeriodicTaskFactory, PublisherBaseFactory, SdoServiceConsumerFactory, SdoServiceProviderFactory

public class FactoryGlobal<ABSTRACTCLASS,IDENTIFIER>
extends java.lang.Object

Factory Management class


Nested Class Summary
(package private)  class FactoryGlobal.FactoryEntry
           Class for creation/destruction interface management
static class FactoryGlobal.ReturnCode
           Return code
 
Field Summary
protected  java.util.HashMap<IDENTIFIER,FactoryGlobal.FactoryEntry> m_creators
           Map of FactoryEntry
protected  RtcDeleteFunc m_Delete
           Interface for component destruction variable
protected  RtcNewFunc m_New
           Interface for component creation variable
protected  NumberingPolicy m_policy
           Class for numbering policy (naming policy) management.
 
Constructor Summary
protected FactoryGlobal()
           FactoryGlobal constructor
 
Method Summary
 FactoryGlobal.ReturnCode addFactory(IDENTIFIER id, ObjectCreator creator, ObjectDestructor destructor)
           Resters Factory to the map.
 java.util.ArrayList<ABSTRACTCLASS> createdObjects()
           Getting created objects
 ABSTRACTCLASS createObject(IDENTIFIER id)
           Object generation processing
 FactoryGlobal.ReturnCode deleteObject(ABSTRACTCLASS obj)
           Deletes the object. This method deletes specified Object. with identifier.}
 FactoryGlobal.ReturnCode deleteObject(IDENTIFIER id, ABSTRACTCLASS obj)
           Deletes the object.
 java.util.Set<IDENTIFIER> getIdentifiers()
           Returns Identifiers of the map.
 boolean hasFactory(IDENTIFIER id)
           Checks whether Identifier exists in the map.
static FactoryGlobal instance()
           Creates FactoryGlobal.
static java.lang.Object instance(java.lang.String clazz)
           Creates FactoryGlobal.
 boolean isProducerOf(ABSTRACTCLASS obj)
           Whether a object is a product of this factory
 ObjectCreator objectToCreator(ABSTRACTCLASS obj)
           Getting destructor of the object
 ObjectDestructor objectToDestructor(ABSTRACTCLASS obj)
           Getting destructor of the object
 FactoryGlobal.ReturnCode objectToIdentifier(ABSTRACTCLASS obj, IDENTIFIER id)
           Getting class identifier (ID) from a object
 FactoryGlobal.ReturnCode removeFactory(IDENTIFIER id)
           Removes Factory from the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_New

protected RtcNewFunc m_New
Interface for component creation variable


m_Delete

protected RtcDeleteFunc m_Delete
Interface for component destruction variable


m_policy

protected NumberingPolicy m_policy
Class for numbering policy (naming policy) management.


m_creators

protected java.util.HashMap<IDENTIFIER,FactoryGlobal.FactoryEntry> m_creators
Map of FactoryEntry

Constructor Detail

FactoryGlobal

protected FactoryGlobal()
FactoryGlobal constructor

Method Detail

instance

public static FactoryGlobal instance()
Creates FactoryGlobal.

Returns:
FactoryGlobal object

instance

public static java.lang.Object instance(java.lang.String clazz)
Creates FactoryGlobal.

Parameters:
clazz - class name
Returns:
object

hasFactory

public boolean hasFactory(IDENTIFIER id)
Checks whether Identifier exists in the map.

Parameters:
id - Identifier
Returns:
boolean

getIdentifiers

public java.util.Set<IDENTIFIER> getIdentifiers()
Returns Identifiers of the map.

Returns:
Identifiers

addFactory

public FactoryGlobal.ReturnCode addFactory(IDENTIFIER id,
                                           ObjectCreator creator,
                                           ObjectDestructor destructor)
Resters Factory to the map.

Parameters:
id - Identifier
creator - creation function
destructor - destruction function
Returns:
The return code of ReturnCode type.

removeFactory

public FactoryGlobal.ReturnCode removeFactory(IDENTIFIER id)
Removes Factory from the map.

Parameters:
id - Identifier
Returns:
The return code of ReturnCode type.

createObject

public ABSTRACTCLASS createObject(IDENTIFIER id)
Object generation processing

This method creates the object with factory specified with identifier.

Parameters:
id - Identifier of created object
Returns:
Created object.

deleteObject

public FactoryGlobal.ReturnCode deleteObject(IDENTIFIER id,
                                             ABSTRACTCLASS obj)
Deletes the object.

This method deletes the object with factory specified with identifier.

Parameters:
id - Identifier of deleted object
obj - Deleteed object.

deleteObject

public FactoryGlobal.ReturnCode deleteObject(ABSTRACTCLASS obj)
Deletes the object. This method deletes specified Object. with identifier.}

Parameters:
obj - Deleteed object.

createdObjects

public java.util.ArrayList<ABSTRACTCLASS> createdObjects()
Getting created objects

This operation returns a list of created objects by the factory.

Returns:
created object list

isProducerOf

public boolean isProducerOf(ABSTRACTCLASS obj)
Whether a object is a product of this factory

Parameters:
obj - A target object
Returns:
true: The object is a product of the factory false: The object is not a product of the factory

objectToIdentifier

public FactoryGlobal.ReturnCode objectToIdentifier(ABSTRACTCLASS obj,
                                                   IDENTIFIER id)
Getting class identifier (ID) from a object

This operation returns a class identifier (ID) from a object.

Parameters:
obj - [in] An object to investigate its class ID.
id - [out] Class identifier (ID)
Returns:
Return code NOT_FOUND: ID not found FACTORY_OK: normal return

objectToCreator

public ObjectCreator objectToCreator(ABSTRACTCLASS obj)
Getting destructor of the object

This operation returns a constructor of the object created by the factory. obj must be a product of the factory. User must check if the object is a product of the factory by using isProducerOf()-function, before using this function.

Returns:
destructor of the object

objectToDestructor

public ObjectDestructor objectToDestructor(ABSTRACTCLASS obj)
Getting destructor of the object

This operation returns a destructor of the object created by the factory. obj must be a product of the factory. User must check if the object is a product of the factory by using isProducerOf()-function, before using this function.

Returns:
destructor of the object