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

#include <ossimConnectableContainer.h>

Inheritance diagram for ossimConnectableContainer:
ossimConnectableObject ossimConnectableContainerInterface ossimConnectableObjectListener ossimObject ossimListenerManager ossimPropertyInterface ossimListener ossimReferenced

Public Types

typedef std::map< ossim_int64, ossimRefPtr< ossimConnectableObject > > connectablObjectMapType
 
- 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
 

Public Member Functions

 ossimConnectableContainer (ossimConnectableObject *owner=0)
 
virtual ossimObjectgetObject ()
 
virtual const ossimObjectgetObject () const
 
virtual ossimConnectableObjectgetConnectableObject (ossim_uint32 index)
 
 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 (ossimConnectableObject *findObject(const ossimId &id, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (ossimConnectableObject *findObject(const ossimConnectableObject *obj, bool recurse=true))
 Please use the new ossimVisitor design pattern to visit objects in the container. More...
 
void makeUniqueIds ()
 
ossim_uint32 getNumberOfObjects (bool recurse=true) const
 
virtual bool addChild (ossimConnectableObject *attachableObject)
 
virtual bool removeChild (ossimConnectableObject *object)
 
virtual bool canConnectMyInputTo (ossim_int32 index, const ossimConnectableObject *obj) const
 required to be overriden by derived classes More...
 
virtual bool canConnectMyOutputTo (ossim_int32 index, const ossimConnectableObject *obj) const
 default implementation is to allow anyone to connect to us. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual void getChildren (std::vector< ossimConnectableObject *> &children, bool immediateChildrenOnlyFlag)
 
void deleteAllChildren ()
 
virtual void accept (ossimVisitor &visitor)
 We will add a visitor interface for all connectable objects. More...
 
virtual bool fillContainer (ossimConnectableContainer &container)
 
- 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 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 ossim_int32 connectMyOutputTo (ossimConnectableObject *outputObject, bool makeInputConnection=true, bool createEventFlag=true)
 Will try to connect this objects output to the passed in object. More...
 
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 propagateEventToOutputs (ossimEvent &event)
 
virtual void propagateEventToInputs (ossimEvent &event)
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 
virtual void setProperty (const ossimString &name, const ossimString &value)
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 
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...
 
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 std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
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 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 ()
 
- Public Member Functions inherited from ossimConnectableObjectListener
 ossimConnectableObjectListener ()
 
virtual ~ossimConnectableObjectListener ()
 
virtual void processEvent (ossimEvent &event)
 ProcessEvent. More...
 
virtual void objectDestructingEvent (ossimObjectDestructingEvent &)
 
virtual void connectionEvent (ossimConnectionEvent &)
 
virtual void disconnectInputEvent (ossimConnectionEvent &)
 
virtual void disconnectOutputEvent (ossimConnectionEvent &)
 
virtual void connectInputEvent (ossimConnectionEvent &)
 
virtual void connectOutputEvent (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
 

Protected Member Functions

virtual ~ossimConnectableContainer ()
 
 ossimConnectableContainer (const ossimConnectableContainer &rhs)
 
void removeAllListeners ()
 
bool addAllObjects (std::map< ossimId, std::vector< ossimId > > &idMapping, const ossimKeywordlist &kwl, const char *prefix)
 
bool connectAllObjects (const std::map< ossimId, std::vector< ossimId > > &idMapping)
 
void findInputConnectionIds (std::vector< ossimId > &result, const ossimKeywordlist &kwl, const char *prefix)
 
- 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

connectablObjectMapType theObjectMap
 
ossimConnectableContainerChildListenertheChildListener
 
- 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 ossimConnectableContainerInterface
ossimObjecttheBaseObject
 
- Protected Attributes inherited from ossimListener
bool theListenerEnableFlag
 

Detailed Description

Definition at line 22 of file ossimConnectableContainer.h.

Member Typedef Documentation

◆ connectablObjectMapType

Definition at line 28 of file ossimConnectableContainer.h.

Constructor & Destructor Documentation

◆ ossimConnectableContainer() [1/2]

ossimConnectableContainer::ossimConnectableContainer ( ossimConnectableObject owner = 0)

Definition at line 81 of file ossimConnectableContainer.cpp.

References ossimConnectableContainerChildListener, ossimConnectableContainerInterface::theBaseObject, and theChildListener.

82  :ossimConnectableObject(owner, 0, 0, true, true),
84 {
87 }
ossimConnectableContainerChildListener * theChildListener
ossimConnectableObject(ossimObject *owner=0)
Base constructor of this object.
class OSSIMDLLEXPORT ossimConnectableContainerChildListener

◆ ~ossimConnectableContainer()

ossimConnectableContainer::~ossimConnectableContainer ( )
protectedvirtual

Definition at line 89 of file ossimConnectableContainer.cpp.

References deleteAllChildren(), and theChildListener.

90 {
91  // will need to destory and detach all children
92  //
94 
96  {
97  delete theChildListener;
98  }
99  theChildListener = 0;
100 }
ossimConnectableContainerChildListener * theChildListener

◆ ossimConnectableContainer() [2/2]

ossimConnectableContainer::ossimConnectableContainer ( const ossimConnectableContainer rhs)
protected

Member Function Documentation

◆ accept()

void ossimConnectableContainer::accept ( ossimVisitor visitor)
virtual

We will add a visitor interface for all connectable objects.

Reimplemented from ossimConnectableObject.

Definition at line 775 of file ossimConnectableContainer.cpp.

References ossimConnectableObject::accept(), ossimRefPtr< T >::get(), ossimVisitor::getVisitorType(), ossimVisitor::hasVisited(), ossimVisitor::setVisitorType(), ossimVisitor::stopTraversal(), theObjectMap, ossimVisitor::turnOffVisitorType(), ossimRefPtr< T >::valid(), ossimVisitor::visit(), ossimVisitor::VISIT_CHILDREN, ossimVisitor::VISIT_INPUTS, and ossimVisitor::VISIT_OUTPUTS.

Referenced by addChild(), connectAllObjects(), and ossimIgen::outputProduct().

776 {
777  if(!visitor.hasVisited(this))
778  {
779  visitor.visit(this);
780  ossimVisitor::VisitorType currentType = visitor.getVisitorType();
781  // lets make sure inputs and outputs are turned off for we are traversing all children and we should not have
782  // to have that enabled
783  //
786  {
787  connectablObjectMapType::iterator current = theObjectMap.begin();
788  while((current != theObjectMap.end())&&!visitor.stopTraversal())
789  {
790  ossimRefPtr<ossimConnectableObject> currentObject = (current->second);
791  if(currentObject.valid()&&!visitor.hasVisited(currentObject.get())) currentObject->accept(visitor);
792  ++current;
793  }
794  }
795  visitor.setVisitorType(currentType);
796  }
797 
799 
800 }
virtual void visit(ossimObject *obj)
bool valid() const
Definition: ossimRefPtr.h:75
void setVisitorType(int vType, bool on=true)
void turnOffVisitorType(int vType)
bool hasVisited(ossimObject *obj) const
VisitorType getVisitorType() const
VisitorType
Enumeration type can be a mask and will traverse a graph of connectables based on the values...
Definition: ossimVisitor.h:27
bool stopTraversal() const
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.
connectablObjectMapType theObjectMap

◆ addAllObjects()

bool ossimConnectableContainer::addAllObjects ( std::map< ossimId, std::vector< ossimId > > &  idMapping,
const ossimKeywordlist kwl,
const char *  prefix 
)
protected

Definition at line 580 of file ossimConnectableContainer.cpp.

References ossimKeywordlist::getSubstringKeyList(), ossimString::toInt(), and ossimString::toString().

Referenced by loadState().

584 {
585  ossimString copyPrefix = prefix;
586 
587  std::vector<ossimId> inputConnectionIds;
588 
589  ossimString regExpression = ossimString("^(") + copyPrefix + "object[0-9]+.)";
590  std::vector<ossimString> keys =
591  kwl.getSubstringKeyList( regExpression );
592  long numberOfSources = (long)keys.size();
593 
594  int offset = (int)(copyPrefix+"object").size();
595  int idx = 0;
596  std::vector<int> theNumberList(numberOfSources);
597  for(idx = 0; idx < (int)theNumberList.size();++idx)
598  {
599  ossimString numberStr(keys[idx].begin() + offset,
600  keys[idx].end());
601  theNumberList[idx] = numberStr.toInt();
602  }
603  std::sort(theNumberList.begin(), theNumberList.end());
604  for(idx=0;idx < (int)theNumberList.size();++idx)
605  {
606  ossimString newPrefix = copyPrefix;
607  newPrefix += ossimString("object");
608  newPrefix += ossimString::toString(theNumberList[idx]);
609  newPrefix += ossimString(".");
610 
611  if(traceDebug())
612  {
613  ossimNotify(ossimNotifyLevel_DEBUG) << "trying to create source with prefix: " << newPrefix << "\n";
614  }
616  newPrefix.c_str());
617  if(object.valid())
618  {
619  ossimConnectableObject* connectable = PTR_CAST(ossimConnectableObject, object.get());
620  if(connectable)
621  {
622  if(traceDebug())
623  {
624  ossimNotify(ossimNotifyLevel_DEBUG) << "Created source with prefix: " << newPrefix << "\n";
625  }
626  // we did find a source so include it in the count
627  ossimId id = connectable->getId();
628  inputConnectionIds.clear();
629 
630  findInputConnectionIds(inputConnectionIds,
631  kwl,
632  newPrefix);
633 
634  if(inputConnectionIds.size() != 0)
635  {
636  idMapping.insert(std::make_pair(id, inputConnectionIds));
637  }
638  addChild(connectable);
639  }
640  }
641  }
642 
643  return true;
644 }
static ossimString toString(bool aValue)
Numeric to string methods.
static ossimObjectFactoryRegistry * instance()
void findInputConnectionIds(std::vector< ossimId > &result, const ossimKeywordlist &kwl, const char *prefix)
const ossimId & getId() const
Will allow us to get this object&#39;s id.
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
std::vector< ossimString > getSubstringKeyList(const ossimString &regularExpression) const
virtual bool addChild(ossimConnectableObject *attachableObject)
virtual ossimObject * createObject(const ossimString &name) const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ addChild()

bool ossimConnectableContainer::addChild ( ossimConnectableObject attachableObject)
virtual

Will add an object to the container and then set the added objects owner to this.

Implements ossimConnectableContainerInterface.

Definition at line 390 of file ossimConnectableContainer.cpp.

References accept(), ossimId::getId(), ossimConnectableObject::getId(), ossimIdVisitor::getObject(), theChildListener, theObjectMap, ossimVisitor::VISIT_CHILDREN, and ossimVisitor::VISIT_INPUTS.

Referenced by fillContainer(), and ossimConnectableObject::fillContainer().

391 {
392  if(object)
393  {
394  // if it's not already a child
395 
396  ossimIdVisitor visitor(
397  object->getId(),
399  accept( visitor );
400 
401  // if(!findObject(object->getId()))
402  if ( !visitor.getObject() )
403  {
404  object->changeOwner(this);
405  theObjectMap.insert(std::make_pair(object->getId().getId(), object));
406  object->addListener(theChildListener);
407  }
408 
409  return true;
410  }
411 
412  return false;
413 }
ossimConnectableContainerChildListener * theChildListener
connectablObjectMapType theObjectMap
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.

◆ canConnectMyInputTo()

bool ossimConnectableContainer::canConnectMyInputTo ( ossim_int32  myInputIndex,
const ossimConnectableObject object 
) const
virtual

required to be overriden by derived classes

Implements ossimConnectableObject.

Definition at line 763 of file ossimConnectableContainer.cpp.

765 {
766  return false;
767 }

◆ canConnectMyOutputTo()

bool ossimConnectableContainer::canConnectMyOutputTo ( ossim_int32  myOutputIndex,
const ossimConnectableObject object 
) const
virtual

default implementation is to allow anyone to connect to us.

Reimplemented from ossimConnectableObject.

Definition at line 769 of file ossimConnectableContainer.cpp.

771 {
772  return false;
773 }

◆ connectAllObjects()

bool ossimConnectableContainer::connectAllObjects ( const std::map< ossimId, std::vector< ossimId > > &  idMapping)
protected

Definition at line 680 of file ossimConnectableContainer.cpp.

References accept(), ossimConnectableObject::connectMyInputTo(), ossimIdVisitor::getObject(), ossimNotify(), ossimNotifyLevel_FATAL, ossimIdVisitor::reset(), ossimIdVisitor::setId(), ossimVisitor::VISIT_CHILDREN, and ossimVisitor::VISIT_INPUTS.

Referenced by loadState().

681 {
682  if(idMapping.size())
683  {
684 
686 
687  std::map<ossimId, std::vector<ossimId> >::const_iterator iter = idMapping.begin();
688 
689  while(iter != idMapping.end())
690  {
691  visitor.setId( (*iter).first );
692  accept( visitor );
693  ossimConnectableObject* currentObject = visitor.getObject();
694  // ossimConnectableObject* currentObject = findObject((*iter).first);
695 
696  if(currentObject)
697  {
698  long upperBound = (long)(*iter).second.size();
699  for(long index = 0; index < upperBound; ++index)
700  {
701  visitor.reset();
702  visitor.setId( (*iter).second[index] );
703  accept( visitor );
704  ossimConnectableObject* inputObject = visitor.getObject();
705  if ( inputObject )
706  {
707  currentObject->connectMyInputTo(index, inputObject);
708  }
709  // ossimConnectableObject* inputObject = findObject((*iter).second[index]);
710  // currentObject->connectMyInputTo(index, inputObject);
711  }
712  }
713  else
714  {
716  << "ossimConnectableContainer::connectAllObjects, Could not find "
717  << (*iter).first << " for source: \n";
718  return false;
719  }
720  visitor.reset();
721  ++iter;
722  }
723  }
724  return true;
725 }
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
void setId(const ossimId &id)
All connectable objects will have id&#39;s.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.

◆ deleteAllChildren()

void ossimConnectableContainer::deleteAllChildren ( )

Definition at line 541 of file ossimConnectableContainer.cpp.

References ossimConnectableObject::disconnect(), removeAllListeners(), ossimListenerManager::removeListener(), theChildListener, and theObjectMap.

Referenced by ~ossimConnectableContainer(), and ossimIgen::~ossimIgen().

542 {
543  connectablObjectMapType::iterator current;
545  current = theObjectMap.begin();
547 
548  while(theObjectMap.size())
549  {
550  current = theObjectMap.begin();
551  temp = (*current).second.get();
552  if(temp)
553  {
555  temp->disconnect();
556  (*current).second = NULL;
557  }
558  theObjectMap.erase(current);
559  }
560 }
ossimConnectableContainerChildListener * theChildListener
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
connectablObjectMapType theObjectMap
virtual bool removeListener(ossimListener *listener)

◆ fillContainer()

bool ossimConnectableContainer::fillContainer ( ossimConnectableContainer container)
virtual

Inserts all of this object's children and inputs into the container provided. Since this is itself a container, this method will consolidate this with the argument container. Consequently, this object will not be represented in the argument container but its children will be. Ownership of children will pass to the argument container.

Returns
Returns TRUE if successful.

Reimplemented from ossimConnectableObject.

Definition at line 808 of file ossimConnectableContainer.cpp.

References addChild(), ossimRefPtr< T >::get(), theObjectMap, and ossimRefPtr< T >::valid().

809 {
810  connectablObjectMapType::iterator current;
811  current = theObjectMap.begin();
812  // ossim_uint32 i = 0;
813  // bool fill_ok;
814  while(current != theObjectMap.end())
815  {
816  ossimRefPtr<ossimConnectableObject> currentObject = current->second;
817  if (currentObject.valid())
818  container.addChild(currentObject.get());
819  current++;
820  }
821  return true;
822 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool addChild(ossimConnectableObject *attachableObject)
connectablObjectMapType theObjectMap

◆ findInputConnectionIds()

void ossimConnectableContainer::findInputConnectionIds ( std::vector< ossimId > &  result,
const ossimKeywordlist kwl,
const char *  prefix 
)
protected

Definition at line 646 of file ossimConnectableContainer.cpp.

References ossimKeywordlist::find(), ossimKeywordlist::getNumberOfSubstringKeys(), ossimKeywordlist::getSubstringKeyList(), ossimId::INVALID_ID, ossimString::toLong(), and ossimString::toString().

649 {
650  ossimString newPrefix = prefix;
651 
652  ossim_uint32 counter = 0;
653  ossim_uint32 numberOfMatches = 0;
654 
655  ossimString regExpression = ossimString("^") + newPrefix + "input_connection[0-9]+";
656  ossim_uint32 numberOfKeys = kwl.getNumberOfSubstringKeys( regExpression);
657  std::vector<ossimString> l = kwl.getSubstringKeyList(regExpression);
658  if(numberOfKeys > 0)
659  {
660  newPrefix += "input_connection";
661 
662  while(numberOfMatches < numberOfKeys)
663  {
664  const char* lookup = kwl.find(newPrefix,
665  ossimString::toString(counter));
666  if(lookup)
667  {
668  ++numberOfMatches;
669  long id = ossimString(lookup).toLong();
670  if(id != ossimId::INVALID_ID)
671  {
672  result.push_back(ossimId(id));
673  }
674  }
675  ++counter;
676  }
677  }
678 }
ossim_uint32 getNumberOfSubstringKeys(const ossimString &regularExpression) const
const char * find(const char *key) const
static ossimString toString(bool aValue)
Numeric to string methods.
static const ossim_int64 INVALID_ID
Definition: ossimId.h:83
unsigned int ossim_uint32
std::vector< ossimString > getSubstringKeyList(const ossimString &regularExpression) const
long toLong() const
toLong&#39;s deprecated, please use the toInts...

◆ getChildren()

void ossimConnectableContainer::getChildren ( std::vector< ossimConnectableObject *> &  children,
bool  immediateChildrenOnlyFlag 
)
virtual

Implements ossimConnectableContainerInterface.

Definition at line 495 of file ossimConnectableContainer.cpp.

References ossimConnectableContainerInterface::getChildren(), PTR_CAST, and theObjectMap.

497 {
498  connectablObjectMapType::iterator current;
499  current = theObjectMap.begin();
500  std::vector<ossimConnectableObject*> temp;
501 
502  while(current != theObjectMap.end())
503  {
504  temp.push_back((*current).second.get());
505  }
506  ossim_uint32 i;
507  for(i = 0; i < temp.size();++i)
508  {
509 
510  if(!immediateChildrenOnlyFlag)
511  {
513  (*current).second.get());
514  if(!inter)
515  {
516  children.push_back(temp[i]);
517  }
518  }
519  else
520  {
521  children.push_back(temp[i]);
522  }
523  }
524 
525  if(!immediateChildrenOnlyFlag)
526  {
527  for(i = 0; i < temp.size(); ++i)
528  {
530  (*current).second.get());
531 
532  if(inter)
533  {
534  inter->getChildren(children,
535  immediateChildrenOnlyFlag);
536  }
537  }
538  }
539 }
virtual void getChildren(std::vector< ossimConnectableObject *> &children, bool immediateChildrenOnlyFlag)=0
unsigned int ossim_uint32
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
connectablObjectMapType theObjectMap

◆ getConnectableObject()

ossimConnectableObject * ossimConnectableContainer::getConnectableObject ( ossim_uint32  index)
virtual
Parameters
indexIndex of object to get.
See also
getNumberOfObjects(false) to get the number of objects inside the container.
Returns
Container's object at that index or NULL if out of range.
Note
This does not recurse into other containers.

Implements ossimConnectableContainerInterface.

Definition at line 737 of file ossimConnectableContainer.cpp.

References theObjectMap.

739 {
740  ossimConnectableObject* result = NULL;
741 
742  if (index > theObjectMap.size())
743  {
744  return result;
745  }
746 
747  connectablObjectMapType::iterator current;
748  current = theObjectMap.begin();
749  ossim_uint32 i = 0;
750  while(current != theObjectMap.end())
751  {
752  if (i == index)
753  {
754  return (*current).second.get();
755  }
756  ++current;
757  ++i;
758  }
759 
760  return result;
761 }
unsigned int ossim_uint32
connectablObjectMapType theObjectMap

◆ getNumberOfObjects()

ossim_uint32 ossimConnectableContainer::getNumberOfObjects ( bool  recurse = true) const
virtual

Returns the number of objects within this container and all child containers.

Implements ossimConnectableContainerInterface.

Definition at line 364 of file ossimConnectableContainer.cpp.

References ossimConnectableContainerInterface::getNumberOfObjects(), PTR_CAST, and theObjectMap.

365 {
366  ossim_uint32 result = 0;
367 
368  connectablObjectMapType::const_iterator current;
369 
370  current = theObjectMap.begin();
371 
372  while(current != theObjectMap.end())
373  {
374  ++result;
375 
376  if(recurse)
377  {
379  if(child)
380  {
381  result += child->getNumberOfObjects(true);
382  }
383  }
384  ++current;
385  }
386 
387  return result;
388 }
virtual ossim_uint32 getNumberOfObjects(bool recurse=true) const =0
unsigned int ossim_uint32
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
connectablObjectMapType theObjectMap

◆ getObject() [1/2]

ossimObject * ossimConnectableContainer::getObject ( )
virtual

Definition at line 727 of file ossimConnectableContainer.cpp.

728 {
729  return this;
730 }

◆ getObject() [2/2]

const ossimObject * ossimConnectableContainer::getObject ( ) const
virtual

Definition at line 732 of file ossimConnectableContainer.cpp.

733 {
734  return this;
735 }

◆ loadState()

bool ossimConnectableContainer::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Method to the load (recreate) the state of the object from a keyword list. Return true if ok or false on error.

Reimplemented from ossimConnectableObject.

Definition at line 438 of file ossimConnectableContainer.cpp.

References addAllObjects(), ossimString::c_str(), connectAllObjects(), ossimConnectableObject::loadState(), ossimNotify(), and ossimNotifyLevel_FATAL.

440 {
441  static const char* MODULE = "ossimConnectableContainer::loadState(kwl, prefix)";
442 
443  ossimString copyPrefix = prefix;
444  bool result = ossimConnectableObject::loadState(kwl, copyPrefix.c_str());
445 
446  std::map<ossimId, std::vector<ossimId> > idMapping;
447  result = addAllObjects(idMapping, kwl, prefix);
448  if(!result)
449  {
451  << MODULE << " error: " << "problems adding sources" << std::endl;
452  }
453  result = connectAllObjects(idMapping);
454  if(!result)
455  {
457  << MODULE << " error: " << "problems connecting sources\n";
458  }
459 
460  return result;
461 }
bool connectAllObjects(const std::map< ossimId, std::vector< ossimId > > &idMapping)
bool addAllObjects(std::map< ossimId, std::vector< ossimId > > &idMapping, const ossimKeywordlist &kwl, const char *prefix)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ makeUniqueIds()

void ossimConnectableContainer::makeUniqueIds ( )
virtual

Will cycle through all sources setting their ids. the idLast wlil be updated so we can recurse into other containers.

Implements ossimConnectableContainerInterface.

Definition at line 329 of file ossimConnectableContainer.cpp.

References ossimConnectableObject::getId(), ossimIdManager::instance(), ossimConnectableContainerInterface::makeUniqueIds(), PTR_CAST, ossimConnectableObject::setId(), and theObjectMap.

330 {
331  connectablObjectMapType::iterator current;
332  std::vector<ossimRefPtr<ossimConnectableObject> > objectList;
333 
334 
335  current = theObjectMap.begin();
336 
337  setId(ossimIdManager::instance()->generateId());
338  while(current != theObjectMap.end())
339  {
340  objectList.push_back((*current).second.get());
341  ++current;
342  }
343  theObjectMap.clear();
344 
345  for(long index = 0; index < (long)objectList.size(); ++index)
346  {
348  objectList[index].get());
349  if(container)
350  {
351  container->makeUniqueIds();
352  theObjectMap.insert(std::make_pair(objectList[index]->getId().getId(),
353  objectList[index].get()));
354  }
355  else
356  {
357  objectList[index]->setId(ossimIdManager::instance()->generateId());
358  theObjectMap.insert(std::make_pair(objectList[index]->getId().getId(),
359  objectList[index].get()));
360  }
361  }
362 }
const ossimId & getId() const
Will allow us to get this object&#39;s id.
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
void setId(const ossimId &id)
All connectable objects will have id&#39;s.
connectablObjectMapType theObjectMap
static ossimIdManager * instance()

◆ OSSIM_DEPRECATE_METHOD() [1/6]

ossimConnectableContainer::OSSIM_DEPRECATE_METHOD ( virtual ossimConnectableObject::ConnectableObjectList   findAllObjectsOfTypeconst RTTItypeid &typeInfo, bool recurse=true)

These methods are now deprecated. You can achieve the same thing by using the new visitor design pattern. If this does not achieve exactly what you want then you can derive new rules by overriding the virtual visit method in ossimVisitor

   ossimTypeNameVisitor visitor("<put type name here>", false, ossimVisitor::VISIT_CHILDREN);
   connectableObject->accept(visitor);
   ossimCollectionVisitor::List& collection = visitor.getObjects();

◆ OSSIM_DEPRECATE_METHOD() [2/6]

ossimConnectableContainer::OSSIM_DEPRECATE_METHOD ( virtual ossimConnectableObject::ConnectableObjectList   findAllObjectsOfTypeconst ossimString &className, bool recurse=true)

These methods are now deprecated. You can achieve the same thing by using the new visitor design pattern. If this does not achieve exactly what you want then you can derive new rules by overriding the virtual visit method in ossimVisitor

   ossimConnectableTypeIdVisitor visitor(typeId, false, ossimVisitor::VISIT_CHILDREN);
   connectableObject->accept(visitor);
   ossimConnectableCollectionVisitor::List& collection = visitor.getObjects();

◆ OSSIM_DEPRECATE_METHOD() [3/6]

ossimConnectableContainer::OSSIM_DEPRECATE_METHOD ( virtual ossimConnectableObject findFirstObjectOfTypeconst RTTItypeid &typeInfo, bool recurse=true)

These methods are now deprecated. You can achieve the same thing by using the new visitor design pattern. If this does not achieve exactly what you want then you can derive new rules by overriding the virtual visit method in ossimVisitor

   ossimTypeIdVisitor visitor(typeId, true, ossimVisitor::VISIT_CHILDREN);
   connectableObject->accept(visitor);
   ossimRefPtr<ossimConnectableObject> obj = visitor.getObject();

◆ OSSIM_DEPRECATE_METHOD() [4/6]

ossimConnectableContainer::OSSIM_DEPRECATE_METHOD ( virtual ossimConnectableObject findFirstObjectOfTypeconst ossimString &className, bool recurse=true)

These methods are now deprecated. You can achieve the same thing by using the new visitor design pattern. If this does not achieve exactly what you want then you can derive new rules by overriding the virtual visit method in ossimVisitor

   ossimTypeNameVisitor visitor(className, true, ossimVisitor::VISIT_CHILDREN);
   connectableObject->accept(visitor);
   ossimRefPtr<ossimConnectableObject> obj = visitor.getObject();

◆ OSSIM_DEPRECATE_METHOD() [5/6]

ossimConnectableContainer::OSSIM_DEPRECATE_METHOD ( ossimConnectableObject findObjectconst ossimId &id, bool recurse=true)

These methods are now deprecated. You can achieve the same thing by using the new visitor design pattern. If this does not achieve exactly what you want then you can derive new rules by overriding the virtual visit method in ossimVisitor

   ossimIdVisitor visitor(id, ossimVisitor::VISIT_CHILDREN);
   connectableObject->accept(visitor);
   ossimRefPtr<ossimConnectableObject> obj = visitor.object();

◆ OSSIM_DEPRECATE_METHOD() [6/6]

ossimConnectableContainer::OSSIM_DEPRECATE_METHOD ( ossimConnectableObject findObjectconst ossimConnectableObject *obj, bool recurse=true)

Please use the new ossimVisitor design pattern to visit objects in the container.

◆ removeAllListeners()

void ossimConnectableContainer::removeAllListeners ( )
protected

Definition at line 562 of file ossimConnectableContainer.cpp.

References ossimListenerManager::removeListener(), theChildListener, and theObjectMap.

Referenced by deleteAllChildren().

563 {
564  connectablObjectMapType::iterator current;
566  current = theObjectMap.begin();
567 
568  while(current != theObjectMap.end())
569  {
570  temp = (*current).second.get();
571  if(temp)
572  {
574 // temp->removeListener((ossimConnectableObjectListener*) this);
575  }
576  ++current;
577  }
578 }
ossimConnectableContainerChildListener * theChildListener
connectablObjectMapType theObjectMap
virtual bool removeListener(ossimListener *listener)

◆ removeChild()

bool ossimConnectableContainer::removeChild ( ossimConnectableObject object)
virtual

Will remove the child from the container. Changes the owner of the child to be NULL;

Implements ossimConnectableContainerInterface.

Definition at line 415 of file ossimConnectableContainer.cpp.

References ossimConnectableObject::changeOwner(), ossimId::getId(), ossimConnectableObject::getId(), ossimConnectableObject::getOwner(), ossimListenerManager::removeListener(), theChildListener, and theObjectMap.

Referenced by ossimConnectableContainerChildListener::objectDestructingEvent().

416 {
417  ossimConnectableObject* result = NULL;
418 
419  if(object)
420  {
421  connectablObjectMapType::iterator childIter = theObjectMap.find(object->getId().getId());
422  if(childIter != theObjectMap.end())
423  {
424  result = (*childIter).second.get();
425  if(result->getOwner() == this)
426  {
427  result->changeOwner(NULL);
429 // result->removeListener(this);
430  }
431  theObjectMap.erase(childIter);
432  }
433  }
434 
435  return (result!=NULL);
436 }
const ossimObject * getOwner() const
Fetches the current owner, most likely a container but not limited to one.
ossimConnectableContainerChildListener * theChildListener
ossim_int64 getId() const
Definition: ossimId.h:29
virtual void changeOwner(ossimObject *owner)
Permits changing the object&#39;s owner.
const ossimId & getId() const
Will allow us to get this object&#39;s id.
connectablObjectMapType theObjectMap
virtual bool removeListener(ossimListener *listener)

◆ saveState()

bool ossimConnectableContainer::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Method to save the state of the object to a keyword list. Return true if ok or false on error.

Reimplemented from ossimConnectableObject.

Definition at line 463 of file ossimConnectableContainer.cpp.

References ossimConnectableObject::saveState(), theObjectMap, and ossimString::toString().

465 {
466  bool result = true;
467  connectablObjectMapType::const_iterator current;
468 
469  ossim_int32 childIndex = 1;
470  current = theObjectMap.begin();
471  while(current != theObjectMap.end())
472  {
473  ossimString newPrefix = ( (ossimString(prefix) +
474  ossimString("object") +
475  ossimString::toString(childIndex) + "."));
476  if((*current).second.valid())
477  {
478  bool test = ((*current).second)->saveState(kwl, newPrefix);
479  if(!test)
480  {
481  result = false;
482  }
483  }
484  ++childIndex;
485  ++current;
486  }
487  if(result)
488  {
489  result = ossimConnectableObject::saveState(kwl, prefix);
490  }
491 
492  return result;
493 }
static ossimString toString(bool aValue)
Numeric to string methods.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
connectablObjectMapType theObjectMap
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
int ossim_int32

Member Data Documentation

◆ theChildListener

ossimConnectableContainerChildListener* ossimConnectableContainer::theChildListener
protected

◆ theObjectMap

connectablObjectMapType ossimConnectableContainer::theObjectMap
protected

Every object added must have a unique id. We will sort them in a easy to query form. Since the container can have hundreds of objects we will use a more efficient map that allows us to do binary searches of the objects.

map<key, value> The key will be the objectsUnique id and the value is a pointer to the attachable object.

Definition at line 207 of file ossimConnectableContainer.h.

Referenced by accept(), addChild(), deleteAllChildren(), fillContainer(), getChildren(), getConnectableObject(), getNumberOfObjects(), makeUniqueIds(), removeAllListeners(), removeChild(), and saveState().


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