OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
ossimImageChainMtAdaptor Class Reference

This class supports multi-threading of image chain getTile() requests and associated chain updating. More...

#include <ossimImageChainMtAdaptor.h>

Inheritance diagram for ossimImageChainMtAdaptor:
ossimImageChain ossimImageSource ossimConnectableObjectListener ossimConnectableContainerInterface ossimSource ossimListener ossimConnectableObject ossimErrorStatusInterface ossimObject ossimListenerManager ossimPropertyInterface ossimReferenced

Public Member Functions

 ossimImageChainMtAdaptor ()
 
 ossimImageChainMtAdaptor (ossimImageChain *original, ossim_uint32 num_threads=0, bool use_shared_handlers=false, bool use_cache=false, ossim_uint32 cache_tile_size=64)
 Full constructor accepts the original image chain to clone. More...
 
 ~ossimImageChainMtAdaptor ()
 
void setNumberOfThreads (ossim_uint32 num_threads)
 Alternate way of specifying number of threads to support. More...
 
void setUseSharedHandlers (bool use_shared_handlers)
 
void setCacheTileSize (ossim_uint32 cache_tile_size)
 
void setUseCache (bool use_cache)
 
void setOriginalChain (ossimImageChain *original)
 Alternate way of specifying the original chain being adapted for multi-threading. More...
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIrect &tileRect, ossim_uint32 resLevel=0)
 Intercepts the getTile because it should never be called directly. More...
 
virtual void initialize ()
 Adapts call to original chain so that all clones are initialized. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=NULL)
 Adapts call to original chain so that clones are replicated after original's loadState. More...
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=NULL) const
 Adapts call to original chain so that adapter-specific keywords can be added to KWL. More...
 
virtual void processEvent (ossimEvent &event)
 Adapts the image chain event handler. More...
 
ossimImageSourcegetClone (ossim_uint32 index)
 Returns pointer to a specific clone image chain, or NULL if index exceeds the max available. More...
 
ossim_uint32 getNumberOfClones () const
 Returns the number of clones available. The original chain always counts as the first clone. More...
 
virtual ossimConnectableObject::ConnectableObjectListimageChainList ()
 These overriding access methods greatly facilitate the implementation of an image chain adapter class operating on the member original chain. More...
 
virtual const ossimConnectableObject::ConnectableObjectListimageChainList () const
 
virtual ossim_int32 connectMyOutputTo (ossimConnectableObject *outputObject, bool makeInputConnection=true, bool createEventFlag=true)
 Overrides base class implementation in order to make the connection to each clone. More...
 
- Public Member Functions inherited from ossimImageChain
 ossimImageChain ()
 
virtual ~ossimImageChain ()
 
ossimConnectableObject::ConnectableObjectListgetChainList ()
 
const ossimConnectableObject::ConnectableObjectListgetChainList () const
 
ossimConnectableObjectoperator[] (ossim_uint32 index)
 
virtual ossimConnectableObjectgetConnectableObject (ossim_uint32 index)
 Same as operator[](ossim_uint32 i) More...
 
virtual ossim_int32 indexOf (ossimConnectableObject *obj) const
 
virtual ossimImageSourcegetFirstSource ()
 Return the first source which is the one that first receives the getTile request. More...
 
virtual const ossimImageSourcegetFirstSource () const
 
virtual ossimObjectgetFirstObject ()
 
virtual ossimImageSourcegetLastSource ()
 Return the last source which is the one that last receives the getTile request. More...
 
virtual const ossimImageSourcegetLastSource () const
 
virtual ossimObjectgetLastObject ()
 
bool addFirst (ossimConnectableObject *obj)
 Adds it to the start of the chain. More...
 
bool addLast (ossimConnectableObject *obj)
 Adds it to the end. More...
 
bool deleteFirst ()
 Deletes the first object. More...
 
bool deleteLast ()
 Deletes the last object. More...
 
bool insertRight (ossimConnectableObject *newObj, ossimConnectableObject *rightOfThisObj)
 
bool insertRight (ossimConnectableObject *newObj, const ossimId &id)
 
bool insertLeft (ossimConnectableObject *newObj, const ossimId &id)
 
bool insertLeft (ossimConnectableObject *newObj, ossimConnectableObject *leftOfThisObj)
 
bool replace (ossimConnectableObject *newObj, ossimConnectableObject *oldObj)
 
virtual bool add (ossimConnectableObject *source)
 Will return true or false if an image source was added to the chain. More...
 
virtual ossim_uint32 getNumberOfInputBands () const
 this call is passed to the head of the list. More...
 
virtual ossimScalarType getOutputScalarType () const
 This call is passed to the head of the list. More...
 
virtual double getNullPixelValue (ossim_uint32 band=0) const
 Each band has a null pixel associated with it. More...
 
virtual double getMinPixelValue (ossim_uint32 band=0) const
 Returns the min pixel of the band. More...
 
virtual double getMaxPixelValue (ossim_uint32 band=0) const
 Returns the max pixel of the band. More...
 
virtual void getOutputBandList (std::vector< ossim_uint32 > &bandList) const
 Initializes bandList. More...
 
virtual ossim_uint32 getTileWidth () const
 This call is passed to the head of the list. More...
 
virtual ossim_uint32 getTileHeight () const
 This call is passed to the head of the list. More...
 
virtual ossimIrect getBoundingRect (ossim_uint32 resLevel=0) const
 Will pass this call to the head of the list. More...
 
virtual void getValidImageVertices (vector< ossimIpt > &validVertices, ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, ossim_uint32 resLevel=0) const
 
virtual ossimRefPtr< ossimImageGeometrygetImageGeometry ()
 Returns the image geometry object associated with this tile source or NULL if not defined. More...
 
virtual void getDecimationFactor (ossim_uint32 resLevel, ossimDpt &result) const
 Will return the decimation factor for the given resolution level. More...
 
virtual void getDecimationFactors (vector< ossimDpt > &decimations) const
 
virtual ossim_uint32 getNumberOfDecimationLevels () const
 Will return the number of resolution levels. More...
 
virtual void enableSource ()
 
virtual void disableSource ()
 
bool canConnectMyInputTo (ossim_int32 myInputIndex, const ossimConnectableObject *object) const
 required to be overriden by derived classes More...
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const RTTItypeid &typeInfo, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const ossimString &className, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findFirstObjectOfType(const RTTItypeid &typeInfo, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findFirstObjectOfType(const ossimString &className, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObject(const ossimId &id, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObject(const ossimConnectableObject *obj, bool recurse=true))
 
virtual void makeUniqueIds ()
 Will cycle through all sources setting their ids. More...
 
virtual ossim_uint32 getNumberOfObjects (bool recurse=true) const
 Returns the number of objects within this container and all child containers. More...
 
virtual ossim_uint32 getNumberOfSources () const
 Deprecated! Please use getNumberOfObjects(false). More...
 
virtual bool addChild (ossimConnectableObject *attachableObject)
 Will add an object to the container and then set the added objects owner to this. More...
 
virtual bool removeChild (ossimConnectableObject *object)
 Will remove the child from the container. More...
 
virtual ossimConnectableObjectremoveChild (const ossimId &id)
 
virtual void getChildren (vector< ossimConnectableObject *> &children, bool immediateChildrenOnlyFlag)
 
virtual void disconnectInputEvent (ossimConnectionEvent &event)
 
virtual void disconnectOutputEvent (ossimConnectionEvent &event)
 
virtual void connectInputEvent (ossimConnectionEvent &event)
 
virtual void connectOutputEvent (ossimConnectionEvent &event)
 
virtual void objectDestructingEvent (ossimObjectDestructingEvent &event)
 
virtual void propagateEventToOutputs (ossimEvent &event)
 
virtual void propagateEventToInputs (ossimEvent &event)
 
virtual void accept (ossimVisitor &visitor)
 We will add a visitor interface for all connectable objects. More...
 
void deleteList ()
 
- Public Member Functions inherited from ossimImageSource
 ossimImageSource (ossimObject *owner=0)
 
 ossimImageSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimImageSource ()
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIpt &origin, ossim_uint32 resLevel=0)
 
virtual bool getTile (ossimImageData *result, ossim_uint32 resLevel=0)
 Method to get a tile. More...
 
virtual ossimObjectgetObject ()
 For RTTI support. More...
 
virtual const ossimObjectgetObject () const
 For RTTI support. More...
 
virtual void getDecimationFactors (std::vector< ossimDpt > &decimations) const
 Will return an array of all decimations for each resolution level. More...
 
virtual ossim_uint32 getNumberOfOutputBands () const
 Returns the number of bands in a tile returned from this TileSource. More...
 
virtual void getBoundingRect (ossimIrect &rect, ossim_uint32 resLevel=0) const
 Gets the bounding rectangle of the source. More...
 
virtual void getValidImageVertices (std::vector< ossimIpt > &validVertices, ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, ossim_uint32 resLevel=0) const
 ordering specifies how the vertices should be arranged. More...
 
virtual void setImageGeometry (const ossimImageGeometry *geom)
 Default implementation sets geometry of the first input to the geometry specified. More...
 
virtual void saveImageGeometry () const
 Default method to call input's saveImageGeometry. More...
 
virtual void saveImageGeometry (const ossimFilename &geometry_file) const
 Default method to call input's saveImageGeometry. More...
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 
virtual bool isIndexedData () const
 
- Public Member Functions inherited from ossimSource
 ossimSource (ossimObject *owner=0)
 
 ossimSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimSource ()
 
virtual bool isSourceEnabled () const
 
virtual bool getEnableFlag () const
 
virtual void setEnableFlag (bool flag)
 
virtual bool isInitialized () const
 
virtual void setInitializedFlag (bool flag)
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 
- Public Member Functions inherited from ossimConnectableObject
 ossimConnectableObject (ossimObject *owner=0)
 Base constructor of this object. More...
 
 ossimConnectableObject (ossimObject *owner, ossim_int32 inputListSize, ossim_int32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimConnectableObject ()
 
void setId (const ossimId &id)
 All connectable objects will have id's. More...
 
const ossimIdgetId () const
 Will allow us to get this object's id. More...
 
const ossimObjectgetOwner () const
 Fetches the current owner, most likely a container but not limited to one. More...
 
virtual void changeOwner (ossimObject *owner)
 Permits changing the object's owner. More...
 
virtual void setDescription (const ossimString &description)
 
virtual ossimString getDescription () const
 
virtual bool isConnected (ossimConnectableObjectDirectionType direction=CONNECTABLE_DIRECTION_INPUT) const
 will check the direction specified to see if all slots are full. More...
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findConnectableObject(const ossimId &id))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(RTTItypeid typeId, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(const ossimString &obj, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findInputObjectOfType(const ossimString &className))
 
virtual ossim_int32 findInputIndex (const ossimConnectableObject *object)
 Return a valid index of the input list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findInputIndex (const ossimId &id)
 Return a valid index of the input list if the passed id is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimConnectableObject *object)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimId &id)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 getMyInputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual ossim_int32 getMyOutputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual bool canConnectMyOutputTo (ossim_int32 myOutputIndex, const ossimConnectableObject *object) const
 default implementation is to allow anyone to connect to us. More...
 
virtual void disconnect (ossimConnectableObject *object=0)
 Will disconnect the object passed in. More...
 
virtual void disconnect (const ossimId &id)
 Will disconnect the object passed in. More...
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyInput (ossim_int32 inputIndex, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given input index and generate a connection event. More...
 
virtual void disconnectMyInput (ossimConnectableObject *input, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Finds the index of the passed in input and calls disconnectMyInput(inputIndex, disconnectOutputFlag, createEventFlag);. More...
 
virtual void disconnectMyInputs (ConnectableObjectList &inputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyOutput (ossim_int32 outputIndex, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given output index and generate a connection event. More...
 
virtual void disconnectMyOutput (ossimConnectableObject *output, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the output object. More...
 
virtual void disconnectMyOutputs (ConnectableObjectList &outputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual void disconnectAllInputs ()
 Will disconnect all of the input objects. More...
 
virtual void disconnectAllOutputs ()
 Will disconnect all of the output objects. More...
 
virtual ossim_int32 connectMyInputTo (ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will try to connect this objects input to the passed in object. More...
 
virtual ossim_int32 connectMyInputTo (ossim_int32 inputIndex, ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will connect the specified input to the passed in object. More...
 
virtual bool connectMyInputTo (ConnectableObjectList &inputList, bool makeOutputConnection=true, bool createEventFlag=true)
 
virtual bool connectMyOutputTo (ConnectableObjectList &outputList, bool makeInputConnection=true, bool createEventFlag=true)
 
virtual bool connectInputList (ConnectableObjectList &inputList)
 Will disconnect itself from all inputs and reset to the passed in input list. More...
 
virtual bool connectOutputList (ConnectableObjectList &outputList)
 Will disconnect itself from all outputs and reset to the passed in output list. More...
 
virtual ossim_uint32 getNumberOfInputs () const
 Returns the number of input objects. More...
 
virtual ossim_uint32 getNumberOfOutputs () const
 Return the number of output objects. More...
 
ossimConnectableObjectgetInput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetInput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
ossimConnectableObjectgetOutput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetOutput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
virtual void setNumberOfInputs (ossim_int32 numberOfInputs)
 Will set the number of inputs. More...
 
virtual bool getInputListIsFixedFlag () const
 
virtual bool getOutputListIsFixedFlag () const
 
virtual void setNumberOfOutputs (ossim_int32 numberOfInputs)
 Will set the number of outputs. More...
 
const ConnectableObjectListgetInputList () const
 
const ConnectableObjectListgetOutputList () const
 
ConnectableObjectListgetInputList ()
 
ConnectableObjectListgetOutputList ()
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const RTTItypeid &typeInfo, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const ossimString &className, bool recurse=true))
 
virtual void setProperty (const ossimString &name, const ossimString &value)
 
virtual ossim_uint32 saveStateOfAllInputs (ossimKeywordlist &kwl, bool saveThisStateFlag=true, ossim_uint32 objectIndex=1, const char *prefix=0) const
 Save the state of all inputs to a keyword list. More...
 
virtual bool fillContainer (ossimConnectableContainer &container)
 Inserts this object and all of its children and inputs into the container provided. More...
 
bool moveInputUp (const ossimId &id)
 Moves the input connection matching id up one in the connection list. More...
 
bool moveInputDown (const ossimId &id)
 Moves the input connection matching id down one in the connection list. More...
 
bool moveInputToTop (const ossimId &id)
 Moves the input connection matching id to the top of the connection list. More...
 
bool moveInputToBottom (const ossimId &id)
 Moves the input connection matching id to the bottom of the connection list. More...
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 
- Public Member Functions inherited from ossimListenerManager
 ossimListenerManager ()
 
virtual ~ossimListenerManager ()
 
virtual void fireEvent (ossimEvent &event)
 
virtual bool addListener (ossimListener *listener)
 
virtual bool removeListener (ossimListener *listener)
 
virtual bool findListener (ossimListener *listener)
 
- Public Member Functions inherited from ossimPropertyInterface
 ossimPropertyInterface ()
 
virtual ~ossimPropertyInterface ()
 
virtual ossimString getPropertyValueAsString (const ossimString &name) const
 
void getPropertyList (std::vector< ossimRefPtr< ossimProperty > > &propertyList) const
 
void setProperties (std::vector< ossimRefPtr< ossimProperty > > &propertyList)
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 
- Public Member Functions inherited from ossimConnectableObjectListener
 ossimConnectableObjectListener ()
 
virtual ~ossimConnectableObjectListener ()
 
virtual void connectionEvent (ossimConnectionEvent &)
 
virtual void propertyEvent (ossimPropertyEvent &)
 
virtual void addObjectEvent (ossimContainerEvent &)
 
virtual void removeObjectEvent (ossimContainerEvent &)
 
virtual void containerEvent (ossimContainerEvent &)
 
virtual void refreshEvent (ossimRefreshEvent &)
 
- Public Member Functions inherited from ossimListener
 ossimListener ()
 
virtual ~ossimListener ()
 
void enableListener ()
 
void disableListener ()
 
void setListenerEnableFlag (bool flag)
 
bool isListenerEnabled () const
 
bool getListenerEnableFlag () const
 
- Public Member Functions inherited from ossimConnectableContainerInterface
 ossimConnectableContainerInterface (ossimObject *obj)
 
virtual ~ossimConnectableContainerInterface ()
 
virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType (const RTTItypeid &typeInfo, bool recurse=true)=0
 
virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType (const ossimString &className, bool recurse=true)=0
 
virtual ossimConnectableObjectfindFirstObjectOfType (const RTTItypeid &typeInfo, bool recurse=true)=0
 
virtual ossimConnectableObjectfindFirstObjectOfType (const ossimString &className, bool recurse=true)=0
 
virtual ossimConnectableObjectfindObject (const ossimId &id, bool recurse=true)=0
 
virtual ossimConnectableObjectfindObject (const ossimConnectableObject *obj, bool recurse=true)=0
 
ossimObjectgetObject ()
 
const ossimObjectgetObject () const
 
void deleteAllChildren ()
 
virtual void getChildren (std::vector< ossimConnectableObject *> &children, bool immediateChildrenOnlyFlag)=0
 

Protected Types

typedef std::vector< ossimRefPtr< ossimImageHandlerMtAdaptor > > SharedHandlerList
 List of handlers that are being shared among all clones (if requested). More...
 

Protected Member Functions

void deleteReplicas ()
 Deletes instances of all replicas from the clone list and leaves only the original. More...
 
bool replicate ()
 Creates clones of original and pushes them onto the clone list. Returns TRUE if successful. More...
 
bool connectSharedHandlers (ossim_uint32 index)
 Manages reconnecting shared image handlers to a cloned image chain (identified by index) after its creation. More...
 
- Protected Member Functions inherited from ossimImageChain
void prepareForRemoval (ossimConnectableObject *connectableObject)
 Inserts all of this object's children and inputs into the container provided. More...
 
bool addAllSources (map< ossimId, vector< ossimId > > &idMapping, const ossimKeywordlist &kwl, const char *prefix=NULL)
 For dynamic loading to take place we must allocate all objects first and then assign id's later. More...
 
void findInputConnectionIds (vector< ossimId > &result, const ossimKeywordlist &kwl, const char *prefix=NULL)
 
bool connectAllSources (const map< ossimId, vector< ossimId > > &idMapping)
 
- Protected Member Functions inherited from ossimImageSource
 ossimImageSource (const ossimImageSource &rhs)
 
const ossimImageSourceoperator= (const ossimImageSource &)
 
- Protected Member Functions inherited from ossimSource
 ossimSource (const ossimSource &rhs)
 
const ossimSourceoperator= (const ossimSource &rhs)
 
- Protected Member Functions inherited from ossimConnectableObject
ossimConnectableObjectfindObjectOfType (ConnectableObjectList *connectableList, ossimVisitor &visitor)
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Member Functions inherited from ossimListenerManager
 ossimListenerManager (const ossimListenerManager &rhs)
 

Protected Attributes

ossimRefPtr< ossimImageChainm_adaptedChain
 This is the adaptee image chain. More...
 
std::vector< ossimRefPtr< ossimImageSource > > m_clones
 List of replicated child chains' first source (the one receiving the getTile call). More...
 
std::vector< ossimRefPtr< ossimConnectableContainer > > m_chainContainers
 The container objects must be kept alive in this vector while their child chains in m_clones are used. More...
 
SharedHandlerList m_sharedHandlers
 
ossim_uint32 m_numThreads
 
bool d_useSharedHandlers
 
ossim_uint32 d_cacheTileSize
 
bool d_useCache
 
bool d_debugEnabled
 
- Protected Attributes inherited from ossimImageChain
ossimConnectableObject::ConnectableObjectList theImageChainList
 This will hold a sequence of image sources. More...
 
ossimRefPtr< ossimImageDatatheBlankTile
 
bool theLoadStateFlag
 
- Protected Attributes inherited from ossimSource
bool theEnableFlag
 
bool theInitializedFlag
 
- Protected Attributes inherited from ossimConnectableObject
ossimId theId
 
ossimString theDescription
 
ossimObjecttheOwner
 
bool theInputListIsFixedFlag
 Indicates whether the theInputObjectList is fixed. More...
 
bool theOutputListIsFixedFlag
 Indicates whether the theOutputObjectList is fixed. More...
 
ConnectableObjectList theInputObjectList
 Holds a list of input objects. More...
 
ConnectableObjectList theOutputObjectList
 Holds a list of output objects. More...
 
- Protected Attributes inherited from ossimListenerManager
std::list< ossimListener * > theListenerList
 
bool theEnabledFlag
 
std::list< ossimListener * > theDelayedAdd
 
std::list< ossimListener * > theDelayedRemove
 
bool theFireEventFlag
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 
- Protected Attributes inherited from ossimListener
bool theListenerEnableFlag
 
- Protected Attributes inherited from ossimConnectableContainerInterface
ossimObjecttheBaseObject
 

Friends

class ossimMultiThreadSequencer
 

Additional Inherited Members

- Public Types inherited from ossimConnectableObject
enum  ossimConnectableObjectDirectionType { CONNECTABLE_DIRECTION_NONE = 0, CONNECTABLE_DIRECTION_INPUT = 1, CONNECTABLE_DIRECTION_OUTPUT = 2 }
 
typedef std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
 

Detailed Description

This class supports multi-threading of image chain getTile() requests and associated chain updating.

It accepts an original ossimImageChain object which is then cloned (replicated). One clone per thread is created, counting the original as clone(0), with all clones sharing a common input handler (if directed) so that disk access is serialized and thread-safe.

Definition at line 25 of file ossimImageChainMtAdaptor.h.

Member Typedef Documentation

◆ SharedHandlerList

List of handlers that are being shared among all clones (if requested).

It is a list since the original chain may involve a combiner with multiple image inputs.

Definition at line 116 of file ossimImageChainMtAdaptor.h.

Constructor & Destructor Documentation

◆ ossimImageChainMtAdaptor() [1/2]

ossimImageChainMtAdaptor::ossimImageChainMtAdaptor ( )

Definition at line 30 of file ossimImageChainMtAdaptor.cpp.

References ossimMtDebug::chainDebugEnabled, d_debugEnabled, and ossimMtDebug::instance().

31 : m_numThreads (0),
32  d_useSharedHandlers(false),
33  d_debugEnabled(false),
34  d_cacheTileSize(1024),
35  d_useCache(false)
36 {
37  //###### DEBUG ############
39  //d_useSharedHandlers = mt_debug->chainSharedHandlers;
41  //###### END DEBUG ############
42 }
bool chainDebugEnabled
Definition: ossimMtDebug.h:33
For debugging purposes. To be removed with final release:
Definition: ossimMtDebug.h:7
static ossimMtDebug * instance()
Definition: ossimMtDebug.h:24

◆ ossimImageChainMtAdaptor() [2/2]

ossimImageChainMtAdaptor::ossimImageChainMtAdaptor ( ossimImageChain original,
ossim_uint32  num_threads = 0,
bool  use_shared_handlers = false,
bool  use_cache = false,
ossim_uint32  cache_tile_size = 64 
)

Full constructor accepts the original image chain to clone.

Parameters
num_threadsTotal number of cloned chains to make available.

Definition at line 47 of file ossimImageChainMtAdaptor.cpp.

References ossimMtDebug::chainDebugEnabled, d_debugEnabled, ossimMtDebug::instance(), setCacheTileSize(), setNumberOfThreads(), setOriginalChain(), setUseCache(), and setUseSharedHandlers().

49 : m_numThreads (0),
50  d_useSharedHandlers(false),
51  d_debugEnabled(false),
52  d_cacheTileSize(1024),
53  d_useCache(false)
54 {
55  //###### DEBUG ############
57  //d_useSharedHandlers = mt_debug->chainSharedHandlers;
59  //###### END DEBUG ############
60 
61  setNumberOfThreads(num_threads_req);
62  setUseSharedHandlers(use_shared_handlers);
63  setUseCache(use_cache);
64  setCacheTileSize(cache_tile_size);
65  setOriginalChain(original);
66 }
void setOriginalChain(ossimImageChain *original)
Alternate way of specifying the original chain being adapted for multi-threading. ...
void setNumberOfThreads(ossim_uint32 num_threads)
Alternate way of specifying number of threads to support.
void setUseSharedHandlers(bool use_shared_handlers)
bool chainDebugEnabled
Definition: ossimMtDebug.h:33
For debugging purposes. To be removed with final release:
Definition: ossimMtDebug.h:7
void setCacheTileSize(ossim_uint32 cache_tile_size)
static ossimMtDebug * instance()
Definition: ossimMtDebug.h:24

◆ ~ossimImageChainMtAdaptor()

ossimImageChainMtAdaptor::~ossimImageChainMtAdaptor ( )

Definition at line 71 of file ossimImageChainMtAdaptor.cpp.

References d_useSharedHandlers, m_chainContainers, m_clones, m_sharedHandlers, and ossimListenerManager::removeListener().

72 {
75  m_sharedHandlers[0]->disconnectAllOutputs();
76  m_clones.clear();
77  m_chainContainers.clear();
79  {
80  m_sharedHandlers[0]->close();
81  m_sharedHandlers[0] = 0;
82  m_sharedHandlers.clear();
83  }
84 }
std::vector< ossimRefPtr< ossimImageSource > > m_clones
List of replicated child chains&#39; first source (the one receiving the getTile call).
std::vector< ossimRefPtr< ossimConnectableContainer > > m_chainContainers
The container objects must be kept alive in this vector while their child chains in m_clones are used...
virtual bool removeListener(ossimListener *listener)

Member Function Documentation

◆ connectMyOutputTo()

ossim_int32 ossimImageChainMtAdaptor::connectMyOutputTo ( ossimConnectableObject outputObject,
bool  makeInputConnection = true,
bool  createEventFlag = true 
)
virtual

Overrides base class implementation in order to make the connection to each clone.

This connection is typically to the multi-thread sequencer object.

Reimplemented from ossimConnectableObject.

Definition at line 473 of file ossimImageChainMtAdaptor.cpp.

References ossimConnectableObject::connectMyOutputTo(), and m_clones.

476 {
477  // Make output connection for each clone source:
478  std::vector< ossimRefPtr<ossimImageSource> >::iterator clone_source = m_clones.begin();
479  while (clone_source != m_clones.end())
480  {
481  (*clone_source)->connectMyOutputTo(outputObject, false, false);
482  clone_source++;
483  }
484 
485  // Now make master connection including making input connection on outputObject and firing event:
486  return ossimConnectableObject::connectMyOutputTo(outputObject,
487  makeInputConnection,
488  createEventFlag);
489 }
std::vector< ossimRefPtr< ossimImageSource > > m_clones
List of replicated child chains&#39; first source (the one receiving the getTile call).
virtual ossim_int32 connectMyOutputTo(ossimConnectableObject *outputObject, bool makeInputConnection=true, bool createEventFlag=true)
Will try to connect this objects output to the passed in object.

◆ connectSharedHandlers()

bool ossimImageChainMtAdaptor::connectSharedHandlers ( ossim_uint32  index)
protected

Manages reconnecting shared image handlers to a cloned image chain (identified by index) after its creation.

This is in support of shared image handlers. Returns TRUE if successful.

Definition at line 388 of file ossimImageChainMtAdaptor.cpp.

References ossimConnectableObject::connectMyInputTo(), ossimId::getId(), ossimIdVisitor::getObject(), m_chainContainers, and m_sharedHandlers.

Referenced by replicate().

389 {
390  if ((size_t)chain_index >= m_chainContainers.size())
391  return false;
392 
393  // Loop over each adapted handler in our shared handler list:
394  SharedHandlerList::iterator handler = m_sharedHandlers.begin();
395  while (handler != m_sharedHandlers.end())
396  {
397  // Fetch all objects connected to this adapted handler. The list will point to objects in
398  // m_chainContainers[0], the original chain. The new chain's objects share the same ID's as
399  // the original chain for the moment. So we can search for the output connection
400  // in the new chain using the ID of the corresponding object in the original chain:
401  ConnectableObjectList handler_connections = (*handler)->getOutputList();
402  ConnectableObjectList::iterator output_connection = handler_connections.begin();
403  // BUG HERE AFTER UPGRADING FROM 1.8.14 to 1.8.20 - only grabbing the first output connection
404  //while (output_connection != handler_connections.end())
405  //{
406  ossimId obj_id = (*output_connection)->getId();
407  ossimIdVisitor visitor (obj_id);
408  m_chainContainers[chain_index]->accept(visitor);
409 
410  // Get the pointer to the actual output object that needs to be connected to the shared
411  // handler:
412  ossimConnectableObject* output_obj = visitor.getObject();
413  if (output_obj == NULL)
414  return false; // Should never happen
415  output_obj->connectMyInputTo((*handler).get(), true, true);
416 
417  output_connection++;
418  //}
419  handler++;
420  }
421  return true;
422 }
ossim_int64 getId() const
Definition: ossimId.h:29
std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
std::vector< ossimRefPtr< ossimConnectableContainer > > m_chainContainers
The container objects must be kept alive in this vector while their child chains in m_clones are used...

◆ deleteReplicas()

void ossimImageChainMtAdaptor::deleteReplicas ( )
protected

Deletes instances of all replicas from the clone list and leaves only the original.

Definition at line 230 of file ossimImageChainMtAdaptor.cpp.

References m_clones, and m_numThreads.

Referenced by loadState().

231 {
232  if (m_clones.size() > 1)
233  {
234  std::vector< ossimRefPtr<ossimImageSource> >::iterator first_copy = m_clones.begin();
235  first_copy++;
236  m_clones.erase(first_copy, m_clones.end());
237  }
238  m_numThreads = 1;
239 }
std::vector< ossimRefPtr< ossimImageSource > > m_clones
List of replicated child chains&#39; first source (the one receiving the getTile call).

◆ getClone()

ossimImageSource * ossimImageChainMtAdaptor::getClone ( ossim_uint32  index)

Returns pointer to a specific clone image chain, or NULL if index exceeds the max available.

The clone at index=0 corresponds to the original, though this detail should be ignored.

Definition at line 461 of file ossimImageChainMtAdaptor.cpp.

References m_clones.

Referenced by ossimMultiThreadSequencer::ossimGetTileJob::run().

462 {
463  if (index < (ossim_uint32) m_clones.size())
464  return m_clones[index].get();
465 
466  return 0;
467 }
std::vector< ossimRefPtr< ossimImageSource > > m_clones
List of replicated child chains&#39; first source (the one receiving the getTile call).
unsigned int ossim_uint32

◆ getNumberOfClones()

ossim_uint32 ossimImageChainMtAdaptor::getNumberOfClones ( ) const
inline

Returns the number of clones available. The original chain always counts as the first clone.

Definition at line 73 of file ossimImageChainMtAdaptor.h.

73 { return (ossim_uint32) m_clones.size(); }
std::vector< ossimRefPtr< ossimImageSource > > m_clones
List of replicated child chains&#39; first source (the one receiving the getTile call).
unsigned int ossim_uint32

◆ getTile()

ossimRefPtr< ossimImageData > ossimImageChainMtAdaptor::getTile ( const ossimIrect tileRect,
ossim_uint32  resLevel = 0 
)
virtual

Intercepts the getTile because it should never be called directly.

The tile request must go to the specific chain clone.

Reimplemented from ossimImageChain.

Definition at line 371 of file ossimImageChainMtAdaptor.cpp.

References ossimImageChain::getTile(), m_adaptedChain, ossimNotify(), ossimNotifyLevel_WARN, and ossimRefPtr< T >::valid().

373 {
374  ossimNotify(ossimNotifyLevel_WARN)<<"ossimImageChainMtAdaptor::getTile() -- This method "
375  "Should never be called directly. The tile request must go to the specific chain clone. "
376  "Returning a tile using the original chain's getTile (not threaded)..."<<endl;
377 
378  if (!m_adaptedChain.valid())
379  return ossimRefPtr<ossimImageData>(0);
380 
381  return m_adaptedChain->getTile(tileRect, resLevel);
382 }
ossimRefPtr< ossimImageChain > m_adaptedChain
This is the adaptee image chain.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tileRect, ossim_uint32 resLevel=0)
Within the image chain will pass the head of the list.
bool valid() const
Definition: ossimRefPtr.h:75
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ imageChainList() [1/2]

ossimConnectableObject::ConnectableObjectList & ossimImageChainMtAdaptor::imageChainList ( )
virtual

These overriding access methods greatly facilitate the implementation of an image chain adapter class operating on the member original chain.

These methods really should be "protected" but the compiler complains if the base class declarations are "protected".

Reimplemented from ossimImageChain.

Definition at line 428 of file ossimImageChainMtAdaptor.cpp.

References ossimImageChain::imageChainList(), m_adaptedChain, ossimImageChain::theImageChainList, and ossimRefPtr< T >::valid().

429 {
430  // If there is no original chain defined, then just return our own blank list:
431  if (!m_adaptedChain.valid())
432  return theImageChainList;
433 
434  return m_adaptedChain->imageChainList();
435 }
ossimRefPtr< ossimImageChain > m_adaptedChain
This is the adaptee image chain.
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimConnectableObject::ConnectableObjectList & imageChainList()
These access methods greatly facilitate the implementation of an image chain adaptor class...
ossimConnectableObject::ConnectableObjectList theImageChainList
This will hold a sequence of image sources.

◆ imageChainList() [2/2]

const ossimConnectableObject::ConnectableObjectList & ossimImageChainMtAdaptor::imageChainList ( ) const
virtual

Reimplemented from ossimImageChain.

Definition at line 441 of file ossimImageChainMtAdaptor.cpp.

References ossimImageChain::imageChainList(), m_adaptedChain, ossimImageChain::theImageChainList, and ossimRefPtr< T >::valid().

442 {
443  // If there is no original chain defined, then just return our own blank list:
444  if (!m_adaptedChain.valid())
445  return theImageChainList;
446 
447  return m_adaptedChain->imageChainList();
448 }
ossimRefPtr< ossimImageChain > m_adaptedChain
This is the adaptee image chain.
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimConnectableObject::ConnectableObjectList & imageChainList()
These access methods greatly facilitate the implementation of an image chain adaptor class...
ossimConnectableObject::ConnectableObjectList theImageChainList
This will hold a sequence of image sources.

◆ initialize()

void ossimImageChainMtAdaptor::initialize ( )
virtual

Adapts call to original chain so that all clones are initialized.

Reimplemented from ossimImageChain.

Definition at line 361 of file ossimImageChainMtAdaptor.cpp.

References m_clones.

362 {
363  for (size_t i=0; i<m_clones.size(); ++i)
364  m_clones[i]->initialize();
365 }
std::vector< ossimRefPtr< ossimImageSource > > m_clones
List of replicated child chains&#39; first source (the one receiving the getTile call).
virtual void initialize()
Adapts call to original chain so that all clones are initialized.

◆ loadState()

bool ossimImageChainMtAdaptor::loadState ( const ossimKeywordlist kwl,
const char *  prefix = NULL 
)
virtual

Adapts call to original chain so that clones are replicated after original's loadState.

Reimplemented from ossimImageChain.

Definition at line 264 of file ossimImageChainMtAdaptor.cpp.

References deleteReplicas(), and ossimKeywordlist::find().

Referenced by replicate().

265 {
266  bool succeeded;
267 
268  // Reset this object:
269  deleteReplicas();
270 
271  // Fetch this object's data members before moving onto original chain:
272  ossimString value = kwl.find(prefix, NUM_THREADS_KW);
273  if (value.empty())
274  return false;
275  m_numThreads = value.toUInt32();
276  if (m_numThreads == 0)
277  return false;
278 
279  // The chain ID needs to be read from KWL:
280  ossimId orig_source_id (ossimId::INVALID_ID);
281  value = kwl.find(prefix, ORIGINAL_SOURCE_ID_KW);
282  if (value.empty())
283  return false;
284  orig_source_id.setId(value.toInt64());
285 
286  // This loadState may be called for the purpose of replicating the existing original, or it can
287  // be intended as an adapter to a yet-to-be-instantiated original chain. Check if we already
288  // have a valid original chain:
289  ossimConnectableObject* candidate = 0;
290  ossimImageSource* original_source = 0;
291  if (!m_adaptedChain.valid() || m_chainContainers.empty())
292  {
293  m_chainContainers.clear();
295  m_chainContainers[0]->loadState(kwl, prefix);
296 
297  // Need to instantiate a new original. This is a bootstrap for a full initialization of this
298  // object. We'll need to replicate the clones afterwards:
299  ossimIdVisitor visitor (orig_source_id);
300  m_chainContainers[0]->accept(visitor);
301  candidate = visitor.getObject();
302  original_source = dynamic_cast<ossimImageSource*>(candidate);
303  if (original_source == NULL)
304  return false;
305  m_clones.push_back(original_source); // original is always in first position of clones list
306 
307  // The original "chain" is morphed into a chain with a single child (original first source).
308  // This source is the one maintaining the connection to the rest of the sources in the real
309  // processing chain:
311  m_adaptedChain->add(original_source);
312 
313  // Now that we have an original chain, Recursive code to replicate clones:
314  succeeded = replicate();
315  if (!succeeded)
316  return false;
317  }
318 
319  // We may be done:
320  if (m_numThreads == 1)
321  return true;
322 
323  // In preparation for multi-threading jobs, loop to instantiate all clone chains. The container
324  // class is used to perform a deep copy of the original chain with all connections established.
325  // It would have been cleaner to just use the ossimImageChain::dup() but that method was not
326  // traversing the full chain, resulting in missing input sources:
327  succeeded = true;
328  for (ossim_uint32 i=1; (i<m_numThreads) && succeeded; ++i)
329  {
330  // Use original container's kwl to dup clone container, and pull out our chain of interest:
332  m_chainContainers[i]->loadState(kwl, prefix);
333 
334  // Special handling required if the handlers are being shared. In this case, the handler had
335  // been removed from the original chain, so connections need to be identified and made:
337  {
338  succeeded = connectSharedHandlers(i);
339  if (!succeeded)
340  return false;
341  }
342 
343  // Find the first (right-most) source in the chain and store it in the clone list. Need to
344  // Modify all IDs
345  ossimIdVisitor visitor (orig_source_id);
346  m_chainContainers[i]->accept(visitor);
347  candidate = visitor.getObject();
348  m_chainContainers[i]->makeUniqueIds();
349  ossimRefPtr<ossimImageSource> clone_source = dynamic_cast<ossimImageSource*>(candidate);
350  if (!clone_source)
351  return false;
352  m_clones.push_back(clone_source);
353  }
354 
355  return succeeded;
356 }
ossimRefPtr< ossimImageChain > m_adaptedChain
This is the adaptee image chain.
std::vector< ossimRefPtr< ossimImageSource > > m_clones
List of replicated child chains&#39; first source (the one receiving the getTile call).
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
static const ossim_int64 INVALID_ID
Definition: ossimId.h:83
ossim_uint32 toUInt32() const
bool replicate()
Creates clones of original and pushes them onto the clone list. Returns TRUE if successful.
unsigned int ossim_uint32
virtual bool add(ossimConnectableObject *source)
Will return true or false if an image source was added to the chain.
void deleteReplicas()
Deletes instances of all replicas from the clone list and leaves only the original.
bool connectSharedHandlers(ossim_uint32 index)
Manages reconnecting shared image handlers to a cloned image chain (identified by index) after its cr...
bool empty() const
Definition: ossimString.h:411
ossim_int64 toInt64() const
std::vector< ossimRefPtr< ossimConnectableContainer > > m_chainContainers
The container objects must be kept alive in this vector while their child chains in m_clones are used...

◆ processEvent()

void ossimImageChainMtAdaptor::processEvent ( ossimEvent event)
virtual

Adapts the image chain event handler.

If the event involves a change to the original image chain, then the clones will need to be regenerated here.

Reimplemented from ossimImageChain.

Definition at line 454 of file ossimImageChainMtAdaptor.cpp.

References ossimNotify(), and ossimNotifyLevel_WARN.

455 {
456  ossimNotify(ossimNotifyLevel_WARN)<<"ossimImageChainMtAdaptor::processEvent() -- "
457  "NOT YET IMPLEMENTED"<<endl;
458 }
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ replicate()

bool ossimImageChainMtAdaptor::replicate ( )
protected

Creates clones of original and pushes them onto the clone list. Returns TRUE if successful.

Definition at line 162 of file ossimImageChainMtAdaptor.cpp.

References ossimConnectableObject::changeOwner(), connectSharedHandlers(), d_cacheTileSize, d_useCache, d_useSharedHandlers, ossimRefPtr< T >::get(), ossimCollectionVisitor::getObjectAs(), loadState(), m_chainContainers, m_clones, m_numThreads, m_sharedHandlers, and saveState().

Referenced by setNumberOfThreads(), and setOriginalChain().

163 {
164  if ((m_clones.empty()) || (m_numThreads == 0))
165  return false;
166 
167  // Don't need to replicate if only one thread is being requested. This is not an error though:
168  if (m_numThreads == 1)
169  return true;
170 
171  // If the handlers are to be shared, need to isolate them from the original chain and replace
172  // them with a "hollow adaptor" (i.e., a handler adaptor without the adaptee set yet:
173  m_sharedHandlers.clear();
175  {
176  if (m_chainContainers.empty())
177  return false;
178 
179  // Collect all image handlers in original chain for possible sharing with all clones:
180  ossimTypeNameVisitor visitor (ossimString("ossimImageHandler"));
181  m_chainContainers[0]->accept(visitor);
182  ossimRefPtr<ossimImageHandler> handler = 0;
183  ossimRefPtr<ossimImageHandlerMtAdaptor> handler_adaptor = 0;
184  ossimRefPtr<ossimConnectableObject> output_connection = 0;
185  ossim_uint32 handler_idx = 0;
186 
187  // Loop over all image handlers found in the original chain. Each handler's connection info
188  // is stored and the handler is removed temporarily from the original chain.
189  while (1)
190  {
191  // Fetch a handler from the chain and wrap it with a handler adaptor:
192  handler = visitor.getObjectAs<ossimImageHandler>(handler_idx++);
193  if (!handler)
194  break; // Only exit point of while loop
195 
196  handler_adaptor = new ossimImageHandlerMtAdaptor(handler.get(), d_useCache, d_cacheTileSize);
197  m_sharedHandlers.push_back(handler_adaptor);
198 
199  // Change ownership:
200  m_chainContainers[0]->removeChild(handler.get());
201  handler->changeOwner(this);
202  }
203 
204  // If no handler was found, we can't continue.
205  if (m_sharedHandlers.empty())
206  return false;
207  }
208 
209  // Fetch the state of this and the original chain. This KWL will be used for creating replicas
210  // via the loadState. The saveState essentially bootstraps the replication task:
211  ossimKeywordlist kwl;
212  bool succeeded = saveState(kwl);
213 
214  // The original chain may have had the handlers temporarily removed for the saveState in support
215  // of shared handlers. If so, need to restore them now:
217  succeeded = connectSharedHandlers(0);
218 
219  // Finally, initialize THIS chain with the original chain's state. This call will also create
220  // the clones:
221  if (succeeded)
222  succeeded = loadState(kwl);
223 
224  return succeeded;
225 }
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=NULL) const
Adapts call to original chain so that adapter-specific keywords can be added to KWL.
Intended mainly to provide a mechanism for mutex-locking access to a shared resource during a getTile...
Represents serializable keyword/value map.
std::vector< ossimRefPtr< ossimImageSource > > m_clones
List of replicated child chains&#39; first source (the one receiving the getTile call).
virtual void changeOwner(ossimObject *owner)
Permits changing the object&#39;s owner.
unsigned int ossim_uint32
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=NULL)
Adapts call to original chain so that clones are replicated after original&#39;s loadState.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
bool connectSharedHandlers(ossim_uint32 index)
Manages reconnecting shared image handlers to a cloned image chain (identified by index) after its cr...
std::vector< ossimRefPtr< ossimConnectableContainer > > m_chainContainers
The container objects must be kept alive in this vector while their child chains in m_clones are used...

◆ saveState()

bool ossimImageChainMtAdaptor::saveState ( ossimKeywordlist kwl,
const char *  prefix = NULL 
) const
virtual

Adapts call to original chain so that adapter-specific keywords can be added to KWL.

Reimplemented from ossimImageChain.

Definition at line 244 of file ossimImageChainMtAdaptor.cpp.

References ossimKeywordlist::add(), and m_chainContainers.

Referenced by replicate().

245 {
246  if (m_chainContainers.empty())
247  return false;
248 
249  kwl.add(prefix, NUM_THREADS_KW, m_numThreads);
250  kwl.add(prefix, ORIGINAL_SOURCE_ID_KW, m_clones[0]->getId().getId());
251 
252  bool rtn_state = m_chainContainers[0]->saveState(kwl, prefix);
253 
254  if (d_debugEnabled)
255  kwl.write("ossimImageChainMtAdaptor.kwl");
256 
257  return rtn_state;
258 }
std::vector< ossimRefPtr< ossimImageSource > > m_clones
List of replicated child chains&#39; first source (the one receiving the getTile call).
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
const ossimId & getId() const
Will allow us to get this object&#39;s id.
std::vector< ossimRefPtr< ossimConnectableContainer > > m_chainContainers
The container objects must be kept alive in this vector while their child chains in m_clones are used...

◆ setCacheTileSize()

void ossimImageChainMtAdaptor::setCacheTileSize ( ossim_uint32  cache_tile_size)

◆ setNumberOfThreads()

void ossimImageChainMtAdaptor::setNumberOfThreads ( ossim_uint32  num_threads)

Alternate way of specifying number of threads to support.

This is the same as the number of clones that will be available after replicating the original chain.

Parameters
num_threadsTotal number of cloned chains to make available.

This is the same as the number of clones that will be available after replicating the original chain.

Definition at line 90 of file ossimImageChainMtAdaptor.cpp.

References ossimString::empty(), ossimPreferences::findPreference(), ossimPreferences::instance(), m_chainContainers, m_numThreads, replicate(), and ossimString::toUInt32().

Referenced by ossimImageChainMtAdaptor(), ossimMultiThreadSequencer::setNumberOfThreads(), and ossimMultiThreadSequencer::setToStartOfSequence().

91 {
92  if (m_numThreads == num_threads)
93  return;
94 
95  // Determine number of cores/threads to set up:
96  if (num_threads > 0)
97  {
98  m_numThreads = num_threads;
99  }
100  else
101  {
102  // Look in ossim preferences if arg is provided above.
103  ossimString value = ossimPreferences::instance()->findPreference("ossim_threads");
104  if ( !value.empty() )
105  m_numThreads = value.toUInt32();
106  }
107 
108  // If there is a valid original chain, we can perform the replication:
109  if (!m_chainContainers.empty())
110  replicate();
111 }
ossim_uint32 toUInt32() const
bool replicate()
Creates clones of original and pushes them onto the clone list. Returns TRUE if successful.
const char * findPreference(const char *key) const
static ossimPreferences * instance()
bool empty() const
Definition: ossimString.h:411
std::vector< ossimRefPtr< ossimConnectableContainer > > m_chainContainers
The container objects must be kept alive in this vector while their child chains in m_clones are used...

◆ setOriginalChain()

void ossimImageChainMtAdaptor::setOriginalChain ( ossimImageChain original)

Alternate way of specifying the original chain being adapted for multi-threading.

Parameters
originalImage chain to be adapted.

Definition at line 131 of file ossimImageChainMtAdaptor.cpp.

References ossimConnectableObject::fillContainer(), ossimImageChain::getFirstSource(), m_adaptedChain, m_chainContainers, m_clones, m_numThreads, and replicate().

Referenced by ossimImageChainMtAdaptor().

132 {
133  if (original == NULL)
134  return;
135 
136  ossimImageSource* first_source = original->getFirstSource();
137  if (first_source == NULL)
138  return;
139 
140  // Assign the adaptee and put it in the first position of the clones list:
141  m_adaptedChain = original;
142  m_clones.clear();
143  m_clones.push_back(first_source);
144 
145  m_chainContainers.clear();
148 
149  // If we know the number of threads, we can begin replicating:
150  if (m_numThreads > 1)
151  replicate();
152 }
ossimRefPtr< ossimImageChain > m_adaptedChain
This is the adaptee image chain.
virtual ossimImageSource * getFirstSource()
Return the first source which is the one that first receives the getTile request. ...
std::vector< ossimRefPtr< ossimImageSource > > m_clones
List of replicated child chains&#39; first source (the one receiving the getTile call).
bool replicate()
Creates clones of original and pushes them onto the clone list. Returns TRUE if successful.
virtual bool fillContainer(ossimConnectableContainer &container)
Inserts this object and all of its children and inputs into the container provided.
std::vector< ossimRefPtr< ossimConnectableContainer > > m_chainContainers
The container objects must be kept alive in this vector while their child chains in m_clones are used...

◆ setUseCache()

void ossimImageChainMtAdaptor::setUseCache ( bool  use_cache)

◆ setUseSharedHandlers()

void ossimImageChainMtAdaptor::setUseSharedHandlers ( bool  use_shared_handlers)

Friends And Related Function Documentation

◆ ossimMultiThreadSequencer

friend class ossimMultiThreadSequencer
friend

Definition at line 27 of file ossimImageChainMtAdaptor.h.

Member Data Documentation

◆ d_cacheTileSize

ossim_uint32 ossimImageChainMtAdaptor::d_cacheTileSize
protected

Definition at line 122 of file ossimImageChainMtAdaptor.h.

Referenced by replicate(), and setCacheTileSize().

◆ d_debugEnabled

bool ossimImageChainMtAdaptor::d_debugEnabled
protected

Definition at line 124 of file ossimImageChainMtAdaptor.h.

Referenced by ossimImageChainMtAdaptor().

◆ d_useCache

bool ossimImageChainMtAdaptor::d_useCache
protected

Definition at line 123 of file ossimImageChainMtAdaptor.h.

Referenced by replicate(), and setUseCache().

◆ d_useSharedHandlers

bool ossimImageChainMtAdaptor::d_useSharedHandlers
protected

◆ m_adaptedChain

ossimRefPtr<ossimImageChain> ossimImageChainMtAdaptor::m_adaptedChain
protected

This is the adaptee image chain.

Definition at line 99 of file ossimImageChainMtAdaptor.h.

Referenced by getTile(), imageChainList(), and setOriginalChain().

◆ m_chainContainers

std::vector< ossimRefPtr<ossimConnectableContainer> > ossimImageChainMtAdaptor::m_chainContainers
protected

The container objects must be kept alive in this vector while their child chains in m_clones are used.

Containers are used because they are the only way of "duping" a complete chain with all connections properly done. The containers need to persist in order for the chain connections to be maintained (apparent bug in connectable object code). I found it impossible to dissociate the chain from its container. As soon as the container disappeared, the chain's internal connections would be disrupted. (OLK 11/11)

Definition at line 112 of file ossimImageChainMtAdaptor.h.

Referenced by connectSharedHandlers(), replicate(), saveState(), setNumberOfThreads(), setOriginalChain(), and ~ossimImageChainMtAdaptor().

◆ m_clones

std::vector< ossimRefPtr<ossimImageSource> > ossimImageChainMtAdaptor::m_clones
protected

List of replicated child chains' first source (the one receiving the getTile call).

The first in the list is always the original (adaptee) source. These are owned by the m_chainContainers that are maintained here.

Definition at line 104 of file ossimImageChainMtAdaptor.h.

Referenced by connectMyOutputTo(), deleteReplicas(), getClone(), initialize(), replicate(), setOriginalChain(), and ~ossimImageChainMtAdaptor().

◆ m_numThreads

ossim_uint32 ossimImageChainMtAdaptor::m_numThreads
protected

◆ m_sharedHandlers

SharedHandlerList ossimImageChainMtAdaptor::m_sharedHandlers
protected

The documentation for this class was generated from the following files: