OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimConnectableObject.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts
6 //
7 //*************************************************************************
8 // $Id: ossimConnectableObject.cpp 21850 2012-10-21 20:09:55Z dburken $
9 
18 #include <ossim/base/ossimNotify.h>
20 #include <algorithm>
21 
23  "ossimConnectableObject",
27 
28 const char* CONNECTABLE_INPUT_LIST_FIXED_KW = "input_list_fixed";
29 const char* CONNECTABLE_OUTPUT_LIST_FIXED_KW = "output_list_fixed";
30 
32 :ossimObject(),
34 theInputListIsFixedFlag(false),
35 theOutputListIsFixedFlag(false)
36 {
38  theOwner = owner;
39 }
40 
42  ossim_int32 inputListSize,
43  ossim_int32 outputListSize,
44  bool inputListIsFixedFlag,
45  bool outputListIsFixedFlag)
46 :ossimObject(),
48 theInputListIsFixedFlag(inputListIsFixedFlag),
49 theOutputListIsFixedFlag(outputListIsFixedFlag)
50 {
52  theOwner = owner;
53 
54  setNumberOfInputs(inputListSize);
55  setNumberOfOutputs(outputListSize);
56 }
57 
59 {
60 
61  // tell the immediate listeners that we are destructing.
62  // RP - Probably not a great change, but the multithread sequencer boms
63  // here due to one image handler with multiple connected thread image
64  // chains
65  //ossimObjectDestructingEvent event(this);
66 
67  // if(theOwner)
68  // {
69  // ossimListenerManager* manager = PTR_CAST(ossimListenerManager, theOwner);
70 
71  // if(manager)
72  // {
73  // // notify the owner that you are destructing
74  // //
75  // manager->fireEvent(event);
76  // }
77  // }
78 
79  // notify all other listeners that you are destructing
80  //
81  //fireEvent(event);
82 
83  }
84 
86 {
87  theOwner = owner;
88 }
89 
91 {
92  theDescription = description;
93 }
94 
96 {
97  return theDescription;
98 }
99 
101 {
102  if(direction & CONNECTABLE_DIRECTION_INPUT)
103  {
104  if(getNumberOfInputs())
105  {
106  ConnectableObjectList::const_iterator current = theInputObjectList.begin();
107 
108  while(current != theInputObjectList.end())
109  {
110  if(! (*current))
111  {
112  return false;
113  }
114 
115  ++current;
116  }
117  }
118  else if(!theInputListIsFixedFlag)
119  {
120  return false;
121  }
122  }
123 
124  if(direction & CONNECTABLE_DIRECTION_OUTPUT)
125  {
126  if(theOutputObjectList.empty())
127  {
129 
130  }
131  ConnectableObjectList::const_iterator current = theOutputObjectList.begin();
132  current = theOutputObjectList.begin();
133  while(current != theOutputObjectList.end())
134  {
135  if(! (*current))
136  {
137  return false;
138  }
139 
140  ++current;
141  }
142  }
143 
144  return true;
145 }
146 
147 ossimConnectableObject* ossimConnectableObject::findConnectableObject(const ossimId& id)
148 {
149  ConnectableObjectList::iterator current;
150 
151  current = theInputObjectList.begin();
152  while(current != theInputObjectList.end())
153  {
154  ossimConnectableObject* temp = (*current).get();
155 
156  if(temp->getId() == id)
157  {
158  return temp;
159  }
160 
161  ++current;
162  }
163 
164  // go through the outputs
165  current = theOutputObjectList.begin();
166  while(current != theOutputObjectList.end())
167  {
168  ossimConnectableObject* temp = (*current).get();
169 
170  if(temp->getId() == id)
171  {
172  return temp;
173  }
174 
175  ++current;
176  }
177 
178  return 0;
179 }
180 
182  RTTItypeid typeId,
184  bool recurse)
185 {
186  ossimConnectableObject* result = 0;
187 
188  if(directionType != CONNECTABLE_DIRECTION_NONE)
189  {
190  ConnectableObjectList* connectableList = 0;
191 
193  {
194  connectableList = &theInputObjectList;
195  }
196  else // (directionType == CONNECTABLE_DIRECTION_OUTPUT)
197  {
198  connectableList = &theOutputObjectList;
199  }
200 
201  // see if it is in the immediate list
202  for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
203  {
204  if( (*connectableList)[index].valid() )
205  {
206  if( (*connectableList)[index]->canCastTo( typeId ) )
207  {
208  result = (*connectableList)[index].get();
209  break;
210  }
211  }
212  }
213 
214  if ( !result )
215  {
217 
219  {
220  if ( recurse )
221  {
222  // Cast needed for compiler...
223  vType = (ossimVisitor::VisitorType)
225  }
226  else
227  {
229  }
230  }
231  else // (directionType == CONNECTABLE_DIRECTION_OUTPUT)
232  {
233  if ( recurse )
234  {
235  // Cast needed for compiler...
236  vType = (ossimVisitor::VisitorType)
238  }
239  else
240  {
242  }
243  }
244 
245  ossimTypeIdVisitor visitor( typeId,
246  true, // firstofTypeFlag
247  vType );
248 
249 
250  this->accept( visitor );
251  result = dynamic_cast<ossimConnectableObject*>( visitor.getObject(0) );
252  }
253 
254  } // Matches: if(directionType != CONNECTABLE_DIRECTION_NONE)
255 
256  return result;
257 
258 } // End: findObjectOfType( RTTItypeid ...
259 
261  const ossimString& className,
262  ossimConnectableObjectDirectionType directionType,
263  bool recurse )
264 {
265  ossimConnectableObject* result = 0;
266 
267  if(directionType != CONNECTABLE_DIRECTION_NONE)
268  {
269  ConnectableObjectList* connectableList = 0;
270 
272  {
273  connectableList = &theInputObjectList;
274  }
275  else // (directionType == CONNECTABLE_DIRECTION_OUTPUT)
276  {
277  connectableList = &theOutputObjectList;
278  }
279 
280  // see if it is in the immediate list
281  for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
282  {
283  if( (*connectableList)[index].valid() )
284  {
285  if( (*connectableList)[index]->canCastTo( className ) )
286  {
287  result = (*connectableList)[index].get();
288  break;
289  }
290  }
291  }
292 
293  if ( !result )
294  {
296 
298  {
299  if ( recurse )
300  {
301  // Cast needed for compiler...
302  vType = (ossimVisitor::VisitorType)
304  }
305  else
306  {
308  }
309  }
310  else // (directionType == CONNECTABLE_DIRECTION_OUTPUT)
311  {
312  if ( recurse )
313  {
314  // Cast needed for compiler...
315  vType = (ossimVisitor::VisitorType)
317  }
318  else
319  {
321  }
322  }
323 
324  ossimTypeNameVisitor visitor( className,
325  true, // firstofTypeFlag
326  vType );
327  this->accept( visitor );
328  result = dynamic_cast<ossimConnectableObject*>( visitor.getObject(0) );
329  }
330 
331  } // Matches: if(directionType != CONNECTABLE_DIRECTION_NONE)
332 
333  return result;
334 
335 } // End: findObjectOfType( const ossimString& className ...
336 
337 ossimConnectableObject* ossimConnectableObject::findInputObjectOfType(
338  const ossimString& className)
339 {
340  ossimConnectableObject* result = 0;
341 
342  // See if we are of class type.
343  if ( canCastTo( className ) )
344  {
345  result = this;
346  }
347 
348  if ( !result )
349  {
350  ConnectableObjectList* connectableList = &theInputObjectList;
351 
352  // see if it is in the immediate list
353  for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
354  {
355  if( (*connectableList)[index].valid() )
356  {
357  if( (*connectableList)[index]->canCastTo( className ) )
358  {
359  result = (*connectableList)[index].get();
360  break;
361  }
362  }
363  }
364 
365  if ( !result )
366  {
367  ossimTypeNameVisitor visitor( className,
368  true, // firstofTypeFlag
371  this->accept( visitor );
372  result = dynamic_cast<ossimConnectableObject*>( visitor.getObject(0) );
373  }
374  }
375 
376  return result;
377 
378 } // End: findInputObjectOfType( const ossimString& className )
379 
380 // Old findObject findInputObject code kept here until debugged to satisfaction.
381 #if 0 /* drb */
382 
384  ossimConnectableObjectDirectionType directionType,
385  bool recurse)
386 {
387  ConnectableObjectList* connectableList = &theInputObjectList;
388 
389 
390  if(directionType == CONNECTABLE_DIRECTION_NONE)
391  {
392  return 0;
393  }
394 
395  if(directionType == CONNECTABLE_DIRECTION_OUTPUT)
396  {
397  connectableList = &theOutputObjectList;
398  }
399  // see if it is in the immediate list
400  for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
401  {
402  if((*connectableList)[index].valid())
403  {
404  if((*connectableList)[index]->canCastTo(typeId))//typeId.can_cast(TYPE_INFO(theInputObjectList[index])))
405  {
406  return (*connectableList)[index].get();
407  }
408  }
409  }
410 
411  if(recurse)
412  {
414  dynamic_cast<ossimConnectableContainerInterface*>(this);
415  if(inter)
416  {
417  ossimConnectableObject* tempObj = inter->findFirstObjectOfType(typeId);
418  if(tempObj)
419  {
420  return tempObj;
421  }
422  }
423 
424  for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
425  {
426  inter = dynamic_cast<ossimConnectableContainerInterface*>((*connectableList)[index].get());
427  if(inter)
428  {
429  ossimConnectableObject* tempObj = inter->findFirstObjectOfType(typeId);
430  if(tempObj)
431  {
432  return tempObj;
433  }
434  }
435  if((*connectableList)[index].valid())
436  {
437  ossimConnectableObject* result = (*connectableList)[index]->findObjectOfType(typeId,
438  directionType,
439  recurse);
440  if(result)
441  {
442  return result;
443  }
444  }
445  }
446  }
447 
448  ossimConnectableObject* result = 0;
449  for(ossim_uint32 index = 0; (index < connectableList->size())&&!result; ++index)
450  {
451  if((*connectableList)[index].valid())
452  {
453  result = ((*connectableList)[index])->findObjectOfType(typeId,
454  directionType,
455  recurse);
456  }
457  }
458 
459  return result;
460 }
461 
463  const ossimString& className,
464  ossimConnectableObjectDirectionType directionType,
465  bool recurse)
466 {
467  ConnectableObjectList *connectableList = &theInputObjectList;
468 
469  if(directionType == CONNECTABLE_DIRECTION_NONE)
470  {
471  return 0;
472  }
473 
474  if(directionType == CONNECTABLE_DIRECTION_OUTPUT)
475  {
476  connectableList = &theOutputObjectList;
477 
478  }
479 
480  // see if it is in the immediate list
481  for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
482  {
483  if((*connectableList)[index].valid())
484  {
485  if((*connectableList)[index]->canCastTo(className))//typeId.can_cast(TYPE_INFO(theInputObjectList[index])))
486  {
487  return (*connectableList)[index].get();
488  }
489  }
490  }
491 
492  if(recurse)
493  {
495  dynamic_cast<ossimConnectableContainerInterface*>(this);
496  if(inter)
497  {
498  ossimConnectableObject* tempObj = inter->findFirstObjectOfType(className);
499  if(tempObj)
500  {
501  return tempObj;
502  }
503  }
504  for(ossim_uint32 index = 0; index < connectableList->size(); ++index)
505  {
506  inter = dynamic_cast<ossimConnectableContainerInterface*>(
507  (*connectableList)[index].get());
508  if(inter)
509  {
510  ossimConnectableObject* tempObj = inter->findFirstObjectOfType(className);
511  if(tempObj)
512  {
513  return tempObj;
514  }
515  }
516  if((*connectableList)[index].valid())
517  {
518  ossimConnectableObject* result = (*connectableList)[index]->findObjectOfType(className,
519  directionType,
520  recurse);
521  if(result)
522  {
523  return result;
524  }
525  }
526  }
527  }
528  ossimConnectableObject* result = 0;
529  for(ossim_uint32 index = 0; (index < connectableList->size())&&!result; ++index)
530  {
531  if((*connectableList)[index].valid())
532  {
533  result = ((*connectableList)[index])->findObjectOfType(className,
534  directionType,
535  recurse);
536  }
537  }
538 
539  return result;
540 }
541 
542 ossimConnectableObject* ossimConnectableObject::findInputObjectOfType(
543 
544  const ossimString& className)
545 {
546  // See if we are of class type.
547  if (canCastTo(className))
548  {
549  return this;
550  }
551  ossimConnectableObject* result = 0;
552  // If we are a container, look inside for type.
554  dynamic_cast<ossimConnectableContainerInterface*>(this);
555  if (container)
556  {
557  const ossim_uint32 NUMBER_OF_OBJECTS =
558  container->getNumberOfObjects(false);
559  if (NUMBER_OF_OBJECTS)
560  {
561  for (ossim_uint32 idx = NUMBER_OF_OBJECTS; idx > 0; --idx)
562  {
563  result =
564  container->getConnectableObject(idx-1);
565  if (result)
566  {
567  if (result->canCastTo(className))
568  {
569  return result;
570  }
571  else
572  {
573  result = result->findInputObjectOfType(className);
574  if(result)
575  {
576  return result;
577  }
578  }
579  }
580  }
581  }
582  }
583 
584  ossim_uint32 inputs = getNumberOfInputs();
585  ossim_uint32 inputIdx = 0;
586  for(inputIdx = 0; inputIdx < inputs; ++inputIdx)
587  {
588  ossimConnectableObject* input = getInput(inputIdx);
589  if(input)
590  {
591  result = input->findInputObjectOfType(className);
592  if(result)
593  {
594  return result;
595  }
596  }
597  }
598  return result;
599 }
600 #endif /* drb */
601 // End: Old findObject findInputObject code kept here until debugged to satisfaction.
602 
604 {
605  ossim_int32 i = 0;
606  for(i = 0; i < (ossim_int32)theInputObjectList.size(); ++i)
607  {
608  if(theInputObjectList[i].get() == object)
609  {
610  return i;
611  }
612  }
613 
614  return -1;
615 }
616 
618 {
619  ossim_int32 i = 0;
620  for(i = 0; i < (ossim_int32)theInputObjectList.size(); ++i)
621  {
622  if(theInputObjectList[i].valid() &&
623  (theInputObjectList[i]->getId() == id))
624  {
625  return i;
626  }
627  }
628 
629  return -1;
630 }
631 
633 {
634  ossim_int32 i = 0;
635  for(i = 0; i < (ossim_int32)theOutputObjectList.size(); ++i)
636  {
637  if(theOutputObjectList[i] == object)
638  {
639  return i;
640  }
641  }
642 
643  return -1;
644 }
645 
647 {
648  ossim_int32 i = 0;
649  for(i = 0; i < (ossim_int32)theOutputObjectList.size(); ++i)
650  {
651  if(theOutputObjectList[i].valid() &&
652  (theOutputObjectList[i]->getId() == id))
653  {
654  return i;
655  }
656  }
657 
658  return -1;
659 }
660 
662 {
663  ConnectableObjectList::const_iterator current;
664 
665  ossim_int32 index = 0;
666  current = theInputObjectList.begin();
667  while(current != theInputObjectList.end())
668  {
669  if(!(*current))
670  {
671  if(canConnectMyInputTo(index, object))
672  {
673  return index;
674  }
675  }
676  ++current;
677  ++index;
678  }
680  {
682  object))
683  {
684  return (ossim_int32)theInputObjectList.size();
685  }
686  }
687  return -1;
688 }
689 
691 {
692  ConnectableObjectList::const_iterator current;
693 
694  ossim_int32 index = 0;
695  current = theOutputObjectList.begin();
696  while(current != theOutputObjectList.end())
697  {
698  if(!(*current))
699  {
700  if(canConnectMyOutputTo(index, object))
701  {
702  return index;
703  }
704  }
705  ++current;
706  ++index;
707  }
709  {
711  object))
712  {
713  return (ossim_int32)theOutputObjectList.size();
714  }
715  }
716  // default to return the size. This will force an append.
717  //
718  return -1;
719 }
720 
722 {
723  if( (object==this) || (object==0) )
724  {
727  }
728  else
729  {
730  ossim_int32 index = findInputIndex(object);
731  if(index > -1)
732  {
733  disconnectMyInput(index);
734  }
735  index = findOutputIndex(object);
736  if(index > -1)
737  {
738  disconnectMyOutput(index, object);
739  }
740  }
741 }
742 
744 {
745  if(id == theId)
746  {
747  disconnect(this);
748  }
749  else
750  {
751  ossimIdVisitor visitor( id,
755  accept( visitor );
756  disconnect( visitor.getObject() );
757  }
758 }
759 
761  bool disconnectOutputFlag,
762  bool createEventFlag)
763 {
764  if(theInputObjectList.size() == 0)
765  {
766  return 0;
767  }
768 
769  ConnectableObjectList::iterator current;
771 
772  if( (inputIndex > -1)&&
773  (inputIndex < (ossim_int32)theInputObjectList.size()))
774  {
775  current = (theInputObjectList.begin()+inputIndex);
776  result = (*current).get();
777 
779  {
780  current = theInputObjectList.erase(current);
781  }
782  else
783  {
784  *current = 0;
785  }
786  if(createEventFlag&&result.valid())
787  {
788  ossimConnectionEvent event(this, // owner of message
790  0, // new object
791  result.get(),// old object
793 
794  // send event to all listeners.
795  //
796  fireEvent(event);
797  }
798 
799  if(disconnectOutputFlag&&result.valid())
800  {
801  result->disconnectMyOutput(this, false, createEventFlag);
802  }
803  }
804  return result;
805 }
806 
807 
809  bool disconnectOutputFlag,
810  bool createEventFlag)
811 {
813  disconnectOutputFlag,
814  createEventFlag);
815 }
816 
818  bool disconnectOutputFlag,
819  bool createEventFlag)
820 {
821  if(theInputObjectList.size() == 0) return;
822  ConnectableObjectList oldInputs;
823  ConnectableObjectList newInputs;
824  ossim_int32 i = 0;
825 
826  for(i = 0; i < (ossim_int32)inputList.size(); ++i)
827  {
828  if(findInputIndex(inputList[i].get()) >= 0)
829  {
830  disconnectMyInput(inputList[i].get(), disconnectOutputFlag, false);
831  oldInputs.push_back(inputList[i]);
832  }
833  }
834  if(createEventFlag && oldInputs.size())
835  {
836  ossimConnectionEvent event(this,
838  newInputs,
839  oldInputs,
841  fireEvent(event);
842  }
843 }
844 
846  bool disconnectInputFlag,
847  bool createEvent)
848 {
849  if(theOutputObjectList.size() == 0)
850  {
851  return 0;
852  }
853 
854  ConnectableObjectList::iterator current;
856  if( (outputIndex > -1)&&
857  (outputIndex < (ossim_int32)theOutputObjectList.size()))
858  {
859  current = (theOutputObjectList.begin()+outputIndex);
860  result = (*current).get();
862  {
863  current = theOutputObjectList.erase(current);
864  }
865  else
866  {
867  *current = 0;
868  }
869  if(createEvent)
870  {
871  ossimConnectionEvent event(this, // owner of message
873  0, // new object
874  result.get(),// old object
876 
877  // send event to all listeners.
878  //
879  fireEvent(event);
880  }
881 
882  if(disconnectInputFlag&&result.valid())
883  {
884  result->disconnectMyInput(this, false, createEvent);
885  }
886  }
887  return result;
888 }
889 
891  bool disconnectInputFlag,
892  bool createEventFlag)
893 {
894  disconnectMyOutput(findOutputIndex(output), disconnectInputFlag, createEventFlag);
895 }
896 
898  bool disconnectInputFlag,
899  bool createEventFlag)
900 {
901  if(theOutputObjectList.size() == 0) return;
902 
903  if(theOutputObjectList.size() == 1)
904  {
906  return;
907  }
908  ConnectableObjectList oldOutputs;
909  ConnectableObjectList newOutputs;
910  ossim_int32 i = 0;
911  for(i = 0; i < (ossim_int32)outputList.size(); ++i)
912  {
913  if(findOutputIndex(outputList[i].get()) >= 0)
914  {
915  disconnectMyOutput(outputList[i].get(), disconnectInputFlag, false);
916  oldOutputs.push_back(outputList[i]);
917  }
918  }
919  if(createEventFlag && oldOutputs.size())
920  {
921  ossimConnectionEvent event(this,
923  newOutputs,
924  oldOutputs,
926  fireEvent(event);
927  }
928 }
929 
931 {
932  if(theInputObjectList.size() == 0) return;
933  if(theInputObjectList.size() == 1)
934  {
935  // ossimConnectableObject* obj = disconnectMyInput((ossim_int32)0, false);
937  // if(obj)
938  // {
939  // obj->disconnectMyOutput(this, false);
940  // }
941  return;
942  }
943  ConnectableObjectList::iterator current;
945  ConnectableObjectList newInputs;
946 
947 
948  current = theInputObjectList.begin();
949  while(current != theInputObjectList.end())
950  {
952  {
953  current = theInputObjectList.erase(current);
954  }
955  else
956  {
957  *current = 0;
958  ++current;
959  }
960  }
961  ossimConnectionEvent event(this,
963  newInputs,
964  oldInputs,
966  fireEvent(event);
967 
968  for(ossim_uint32 index = 0; index < oldInputs.size(); ++index)
969  {
970  if(oldInputs[index].valid())
971  {
972  oldInputs[index]->disconnectMyOutput(this, false);
973  }
974  }
975 }
976 
978 {
979  if(theOutputObjectList.size() == 0) return;
980  if(theOutputObjectList.size() == 1)
981  {
982  // ossimConnectableObject* obj = disconnectMyOutput((ossim_int32)0, false);
983  // RP - another probably bad change to keep the multithread adapter from
984  // crashing on the destructor
985  disconnectMyOutput((ossim_int32)0, false, false);
986  // if(obj)
987  // {
988  // obj->disconnectMyInput(this,
989  // false);
990  // }
991  return;
992  }
993  ConnectableObjectList::iterator current;
994 
996  ConnectableObjectList newOutputs;
997 
998  current = theOutputObjectList.begin();
999  while(current != theOutputObjectList.end())
1000  {
1002  {
1003  current = theOutputObjectList.erase(current);
1004  }
1005  else
1006  {
1007  *current = 0;
1008  ++current;
1009  }
1010  }
1011  ossimConnectionEvent event(this,
1013  newOutputs,
1014  oldOutputs,
1016  fireEvent(event);
1017 
1018  for(ossim_uint32 index = 0; index < oldOutputs.size(); ++index)
1019  {
1020  if(oldOutputs[index].valid())
1021  {
1022  oldOutputs[index]->disconnectMyInput(this, false);
1023  }
1024  }
1025 }
1026 
1028  bool makeOutputConnection,
1029  bool createEventFlag)
1030 {
1031  if(!object) return false;
1032 
1033  ossim_int32 index = findInputIndex(object);
1034  if(index >= 0) return index;
1035 
1036  index = getMyInputIndexToConnectTo(object);
1037 
1038  if(index>-1)
1039  {
1040  if(index >= (ossim_int32)theInputObjectList.size())
1041  {
1042  if(theInputListIsFixedFlag) return -1;
1043 
1044  index = (ossim_int32)theInputObjectList.size();
1045  theInputObjectList.push_back(object);
1046  }
1047  else
1048  {
1049  if(!theInputObjectList[index])
1050  {
1051  theInputObjectList[index] = object;
1052  }
1053  else
1054  {
1055  ossimNotify(ossimNotifyLevel_WARN) << "Must issue a detach first!! trying to attach object " << object->getClassName()
1056  << "\n to input index " << index << " in " << getClassName() << "\n";
1057 
1058  return -1;
1059  }
1060  }
1061  if(createEventFlag)
1062  {
1063  ossimConnectionEvent event(this, // owner of message
1065  theInputObjectList[index].get(), // new object
1066  0,// old object
1068  // send event to any listener.
1069  //
1070  fireEvent(event);
1071  }
1072 
1073  if(makeOutputConnection&&object)
1074  {
1075  // make sure we tell the input not to connect
1076  // back to us or infinite loop
1077  //
1078  object->connectMyOutputTo(this, false, createEventFlag);
1079  }
1080  }
1081  else
1082  {
1083  return index;
1084  }
1085 
1086  return index;
1087 }
1088 
1090  ossimConnectableObject* inputObject,
1091  bool makeOutputConnection,
1092  bool createEventFlag)
1093 {
1094  if(!inputObject)
1095  {
1096  if(inputIndex < (ossim_int32)theInputObjectList.size())
1097  {
1098  ossimConnectableObject* oldObject = theInputObjectList[inputIndex].get();
1100  {
1101  theInputObjectList[inputIndex] = 0;
1102  }
1103  else
1104  {
1105  theInputObjectList.erase(theInputObjectList.begin() + inputIndex);
1106  }
1107  if(createEventFlag)
1108  {
1109  ossimConnectionEvent event(this, // owner of message
1111  0, // new object
1112  oldObject,// old object
1114  // send event to any listener.
1115  //
1116  fireEvent(event);
1117  }
1118  return -1;
1119  }
1120  return -1;
1121  }
1122 
1123  ossim_int32 index = findInputIndex(inputObject);
1124 
1125  if((index >= 0)&&!inputObject) return index;
1126  if(!inputObject) return -1;
1127 
1128  if(canConnectMyInputTo(inputIndex, inputObject))
1129  {
1130  if(inputIndex>-1)
1131  {
1132  ossimConnectableObject* oldObject=0;
1133  if(inputIndex >= (ossim_int32)theInputObjectList.size())
1134  {
1135  if(theInputListIsFixedFlag) return -1;
1136 
1137  inputIndex = (ossim_int32)theInputObjectList.size();
1138  theInputObjectList.push_back(inputObject);
1139  }
1140  else
1141  {
1142  oldObject = theInputObjectList[inputIndex].get();
1143  theInputObjectList[inputIndex] = inputObject;
1144  if(oldObject)
1145  {
1146  oldObject->disconnectMyOutput(this, false);
1147  }
1148  }
1149 
1150  if(createEventFlag)
1151  {
1152  ossimConnectionEvent event(this, // owner of message
1154  theInputObjectList[inputIndex].get(), // new object
1155  oldObject,// old object
1157  // send event to any listener.
1158  //
1159  fireEvent(event);
1160  }
1161 
1162  if(makeOutputConnection&&inputObject)
1163  {
1164  // make sure we tell the input not to connect
1165  // back to us or infinite loop
1166  //
1167  inputObject->connectMyOutputTo(this, false, createEventFlag);
1168  }
1169  }
1170  else
1171  {
1172  return inputIndex;
1173  }
1174 
1175  return inputIndex;
1176  }
1177 
1178  return -1;
1179 }
1180 
1182  bool makeOutputConnection,
1183  bool createEventFlag)
1184 {
1185  bool result = true;
1186  ConnectableObjectList oldInputs;
1187  ConnectableObjectList newInputs;
1188 
1189  if(inputList.size() == 1)
1190  {
1191  if(inputList[0].valid())
1192  {
1193  return (connectMyInputTo(inputList[0].get(), makeOutputConnection, createEventFlag) >= 0);
1194  }
1195  else
1196  {
1198  {
1199  theInputObjectList[0] = 0;
1200  }
1201  else
1202  {
1203  theInputObjectList.clear();
1204  }
1205  if(createEventFlag)
1206  {
1207  ossimConnectionEvent event(this,
1209  0,
1210  theInputObjectList[0].get(),
1212  fireEvent(event);
1213  }
1214 
1215  return true;
1216  }
1217  }
1218  ossim_int32 i = 0;
1219  for(i = 0; i < (ossim_int32)inputList.size(); ++i)
1220  {
1221  if(inputList[i].valid())
1222  {
1223  if(connectMyInputTo(inputList[i].get(), makeOutputConnection, false)<0)
1224  {
1225  result = false;
1226  }
1227  else
1228  {
1229  newInputs.push_back(inputList[i]);
1230  }
1231  }
1232  else
1233  {
1234  newInputs.push_back(0);
1235  }
1236  }
1237  if(createEventFlag)
1238  {
1239  ossimConnectionEvent event(this,
1241  newInputs,
1242  oldInputs,
1244  fireEvent(event);
1245  }
1246  return result;
1247 }
1248 
1250  bool makeInputConnection,
1251  bool createEventFlag)
1252 {
1253  ossim_int32 index = findOutputIndex(output);
1254  if(index >= 0) return index;
1255 
1256  index = getMyOutputIndexToConnectTo(output);
1257 
1258  if(index > -1)
1259  {
1260  if((index >= (ossim_int32)theOutputObjectList.size())&&
1262  {
1263  index = (ossim_int32)theOutputObjectList.size();
1264  theOutputObjectList.push_back(output);
1265  }
1266  else
1267  {
1268  if(!theOutputObjectList[index])
1269  {
1270  theOutputObjectList[index] = output;
1271  }
1272  else
1273  {
1274  ossimNotify(ossimNotifyLevel_WARN) << "Must issue a disconnect first!! trying to connect object " << output->getClassName()
1275  << "\n to output index " << index << " in " << getClassName() << "\n";
1276 
1277  return -1;
1278  }
1279  }
1280  if(createEventFlag)
1281  {
1282  ossimConnectionEvent event(this, // owner of message
1284  theOutputObjectList[index].get(), // new object
1285  0,// old object
1287  // send event to any listener.
1288  //
1289  fireEvent(event);
1290  }
1291  if(makeInputConnection&&output)
1292  {
1293  // tell the output object not to connect back
1294  // to us since this is already done.
1295  //
1296  output->connectMyInputTo(this, false, createEventFlag);
1297  }
1298  }
1299  else
1300  {
1301  return index;
1302  }
1303 
1304  return index;
1305 }
1306 
1308  bool makeInputConnection,
1309  bool createEventFlag)
1310 {
1311  bool result = true;
1312  ConnectableObjectList oldOutputs;
1313  ConnectableObjectList newOutputs;
1314 
1315  if(outputList.size() == 0)
1316  {
1318  return true;
1319  }
1320  if((outputList.size() == 1)&&outputList[0].valid())
1321  {
1322  if(outputList[0].valid())
1323  {
1324  return (connectMyOutputTo(outputList[0].get(), makeInputConnection, createEventFlag) >= 0);
1325  }
1326  else
1327  {
1329  }
1330  }
1331 
1332  ossim_int32 i = 0;
1333  for(i = 0; i < (ossim_int32)outputList.size(); ++i)
1334  {
1335  if((connectMyOutputTo(outputList[i].get(), makeInputConnection, false)<0)&&outputList[i].valid())
1336  {
1337  newOutputs.push_back(outputList[i].get());
1338  result = false;
1339  }
1340  }
1341  if(createEventFlag&&newOutputs.size())
1342  {
1343  ossimConnectionEvent event(this,
1345  newOutputs,
1346  oldOutputs,
1348  fireEvent(event);
1349  }
1350 
1351  return result;
1352 }
1353 
1355 {
1356  if(idx < theInputObjectList.size())
1357  {
1358  return theInputObjectList[idx].get();
1359  }
1360 
1361  return 0;
1362 }
1363 
1365 {
1366  if( idx < theInputObjectList.size())
1367  {
1368  return theInputObjectList[idx].get();
1369  }
1370 
1371  return 0;
1372 }
1373 
1375 {
1376  if(idx < theOutputObjectList.size())
1377  {
1378  return theOutputObjectList[idx].get();
1379  }
1380 
1381  return 0;
1382 }
1383 
1385 {
1386  bool result = true;
1387  ossim_uint32 i = 0;
1389  ConnectableObjectList newInputs;
1390  ConnectableObjectList::iterator currentInput = inputList.begin();
1391  ConnectableObjectList tempOld;
1392  if(theInputObjectList.size())
1393  {
1394  for(i = 0; i < theInputObjectList.size(); ++i)
1395  {
1396  if(oldInputs[i].valid())
1397  {
1398  tempOld.push_back(oldInputs[i].get());
1399  }
1400  theInputObjectList[i] = 0;
1401  }
1402  }
1403  if(theInputListIsFixedFlag && (theInputObjectList.size()==0))
1404  {
1405  return false;
1406  }
1407 
1409  {
1410  theInputObjectList.clear();
1411  }
1412  if(tempOld.size())
1413  {
1414  for(i = 0; i < tempOld.size(); ++ i)
1415  {
1416  tempOld[i]->disconnectMyOutput(this, false);
1417  }
1418  }
1419  // disconnectAllInputs();
1420 
1421  if(inputList.size() == 1)
1422  {
1423  return (connectMyInputTo(inputList[0].get())>=0);
1424  }
1425  i = 0;
1426  // now connect the new outputs
1427  //
1428  currentInput = inputList.begin();
1429  result = false;
1430 
1431  while(currentInput != inputList.end())
1432  {
1433  if((*currentInput).valid())
1434  {
1435  if(connectMyInputTo((*currentInput).get(), false) >= 0)
1436  {
1437  newInputs.push_back((*currentInput).get());
1438  result = true;
1439  }
1440  }
1441  ++currentInput;
1442  }
1443  ossimConnectionEvent event(this,
1445  newInputs,
1446  oldInputs,
1448 
1449  if(theInputObjectList.size())
1450  {
1451  fireEvent(event);
1452  }
1453 
1454  newInputs = theInputObjectList;
1455 
1456 
1457 
1458  event = ossimConnectionEvent(this,
1460  newInputs,
1461  oldInputs,
1463  fireEvent(event);
1464 
1465  return result;
1466 }
1467 
1469 {
1470  bool result = true;
1471  ossim_int32 index = 0;
1473  ConnectableObjectList newOutputs;
1474  ConnectableObjectList::const_iterator currentOutput = outputList.begin();
1475 
1477 
1478  if(outputList.size() == 1)
1479  {
1480  return (connectMyOutputTo(outputList[0].get())>=0);
1481  }
1482  while(currentOutput != outputList.end())
1483  {
1484  if(!canConnectMyOutputTo(index, (*currentOutput).get()))
1485  {
1486  result = false;
1487  }
1488  ++currentOutput;
1489  }
1490 
1491  if(!result)
1492  {
1493  return false;
1494  }
1495 
1496  theOutputObjectList = outputList;
1497  newOutputs = theOutputObjectList;
1498 
1499  ossimConnectionEvent event(this,
1501  newOutputs,
1502  oldOutputs,
1504  fireEvent(event);
1505 
1506  return result;
1507 }
1508 
1510 {
1511  if((ossim_int32)theInputObjectList.size() == numberOfInputs)
1512  {
1513  return;
1514  }
1515  ossim_int32 i = 0;
1516  if(numberOfInputs < (ossim_int32)theInputObjectList.size())
1517  {
1519  theInputObjectList.begin()+numberOfInputs);
1520  ConnectableObjectList disconnectList;
1521 
1522  for(i = numberOfInputs;
1523  i < (ossim_int32)theInputObjectList.size();
1524  ++i)
1525  {
1526  if(theInputObjectList[i].valid())
1527  {
1528  disconnectList.push_back(theInputObjectList[i]);
1529  }
1530  }
1531  disconnectMyInputs(disconnectList);
1532 
1533  theInputObjectList.clear();
1534  theInputObjectList = v;
1535  }
1536  else
1537  {
1538  for(i = (ossim_int32)theInputObjectList.size();
1539  i < numberOfInputs;
1540  ++i)
1541  {
1542  theInputObjectList.push_back(0);
1543  }
1544  }
1545 }
1546 
1548 {
1549  if((ossim_int32)theOutputObjectList.size() == numberOfOutputs)
1550  {
1551  return;
1552  }
1553  ossim_int32 i = 0;
1554  if(numberOfOutputs < (ossim_int32)theOutputObjectList.size())
1555  {
1557  theOutputObjectList.begin()+numberOfOutputs);
1558  ConnectableObjectList disconnectList;
1559  for(i = numberOfOutputs;
1560  i < (ossim_int32)theOutputObjectList.size();
1561  ++i)
1562  {
1563  if(theOutputObjectList[i].valid())
1564  {
1565  disconnectList.push_back(theOutputObjectList[i]);
1566  }
1567  }
1568  disconnectMyOutputs(disconnectList);
1569 
1570  theOutputObjectList.clear();
1571  theOutputObjectList = v;
1572  }
1573  else
1574  {
1575  for(i = (ossim_int32)theOutputObjectList.size();
1576  i < numberOfOutputs;
1577  ++i)
1578  {
1579  theOutputObjectList.push_back(0);
1580  }
1581  }
1582 }
1583 
1584 
1586 {
1587  if(idx < theOutputObjectList.size())
1588  {
1589  return theOutputObjectList[idx].get();
1590  }
1591 
1592  return 0;
1593 }
1594 
1595 void ossimConnectableObject::findAllObjectsOfType(ConnectableObjectList& result,
1596  const RTTItypeid& typeInfo,
1597  bool recurse)
1598 {
1599  int j;
1600  // go through children first
1601  //
1603  dynamic_cast<ossimConnectableContainerInterface*>(this);
1604  if(inter)
1605  {
1606  ConnectableObjectList tempList = inter->findAllObjectsOfType(typeInfo,
1607  recurse);
1608 
1609  for(j = 0; j < (int)tempList.size(); ++j)
1610  {
1611  ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
1612  if(iter == result.end())
1613  {
1614  result.push_back(tempList[j].get());
1615  }
1616  }
1617  }
1618 
1619 }
1620 
1621 void ossimConnectableObject::findAllObjectsOfType(ConnectableObjectList& result,
1622  const ossimString& className,
1623  bool recurse)
1624 {
1625  int j;
1626  // go through children first
1627  //
1629  dynamic_cast<ossimConnectableContainerInterface*>(this);
1630  if(inter)
1631  {
1632  ConnectableObjectList tempList = inter->findAllObjectsOfType(className,
1633  recurse);
1634 
1635  for(j = 0; j < (int)tempList.size(); ++j)
1636  {
1637  ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
1638  if(iter == result.end())
1639  {
1640  result.push_back(tempList[j].get());
1641  }
1642  }
1643  }
1644 }
1645 
1646 #if 0
1647 void ossimConnectableObject::findAllInputsOfType(ConnectableObjectList& result,
1648  const RTTItypeid& typeInfo,
1649  bool propagateToInputs,
1650  bool recurseChildren)
1651 {
1652  int i;
1653  int j;
1654  // go through children first
1655  //
1657  dynamic_cast<ossimConnectableContainerInterface*>(this);
1658  if(inter&&recurseChildren)
1659  {
1660  ConnectableObjectList tempList = inter->findAllObjectsOfType(typeInfo,
1661  true);
1662 
1663  for(j = 0; j < (int)tempList.size(); ++j)
1664  {
1665  ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
1666  if(iter == result.end())
1667  {
1668  result.push_back(tempList[j].get());
1669  }
1670  }
1671  }
1672 
1673  for(i = 0; i < (int)getNumberOfInputs(); ++i)
1674  {
1675  ossimConnectableObject* current = getInput(i);
1676  if(current&&(current->canCastTo(typeInfo)))
1677  {
1678  ConnectableObjectList::iterator position = std::find(result.begin(), result.end(), current);
1679 
1680  if(position == result.end())
1681  {
1682  result.push_back(current);
1683  }
1684  }
1685  inter = dynamic_cast<ossimConnectableContainerInterface*>(current);
1686  if(inter)
1687  {
1688  ConnectableObjectList tempList = inter->findAllObjectsOfType(typeInfo, true);
1689  for(j = 0; j < (int)tempList.size(); ++j)
1690  {
1691  ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
1692  if(iter == result.end())
1693  {
1694  result.push_back(tempList[j]);
1695  }
1696  }
1697  }
1698 
1699  if(propagateToInputs&&current)
1700  {
1701  current->findAllInputsOfType(result,
1702  typeInfo,
1703  true,
1704  recurseChildren);
1705  }
1706  }
1707 }
1708 
1709 void ossimConnectableObject::findAllInputsOfType(ConnectableObjectList& result,
1710  const ossimString& className,
1711  bool propagateToInputs,
1712  bool recurseChildren)
1713 {
1714  int j;
1715  // go through children first
1716  //
1718  dynamic_cast<ossimConnectableContainerInterface*>(this);
1719  if(inter&&recurseChildren)
1720  {
1721  ConnectableObjectList tempList = inter->findAllObjectsOfType(className,
1722  true);
1723 
1724  for(j = 0; j < (int)tempList.size(); ++j)
1725  {
1726  ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
1727  if(iter == result.end())
1728  {
1729  result.push_back(tempList[j]);
1730  }
1731  }
1732  }
1733  for(ossim_uint32 i = 0; i < getNumberOfInputs(); ++i)
1734  {
1735  ossimConnectableObject* current = getInput(i);
1736  if(current&&(current->canCastTo(className)))
1737  {
1738  ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), current);
1739  if(iter == result.end())
1740  {
1741  result.push_back(current);
1742  }
1743  }
1745  dynamic_cast<ossimConnectableContainerInterface*>(current);
1746  if(inter)
1747  {
1748  ConnectableObjectList tempList = inter->findAllObjectsOfType(className, true);
1749  for(j = 0; j < (int)tempList.size(); ++j)
1750  {
1751  ConnectableObjectList::iterator iter = std::find(result.begin(), result.end(), tempList[j]);
1752  if(iter == result.end())
1753  {
1754  result.push_back(tempList[j]);
1755  }
1756  }
1757  }
1758 
1759  if(propagateToInputs&&current)
1760  {
1761  current->findAllInputsOfType(result,
1762  className,
1763  true,
1764  recurseChildren);
1765  }
1766  }
1767 }
1768 #endif
1769 
1771 {
1772  ossim_uint32 i;
1773 
1774  for(i = 0; i <getNumberOfOutputs(); ++i)
1775  {
1777  if(obj)
1778  {
1779  event.setPropagationType(ossimEvent::PROPAGATION_OUTPUT);
1780  obj->fireEvent(event);
1781  obj->propagateEventToOutputs(event);
1782  }
1783  }
1784 }
1785 
1787 {
1788  ossim_uint32 i;
1789 
1790  for(i = 0; i <getNumberOfInputs(); ++i)
1791  {
1792  ossimConnectableObject* obj = getInput(i);
1793  if(obj)
1794  {
1795  obj->fireEvent(event);
1796  obj->propagateEventToInputs(event);
1797  }
1798  }
1799 }
1800 
1802 {
1803  if(!property.valid()) return;
1804  if(property->getName() == "Description")
1805  {
1806  property->valueToString(theDescription);
1807  }
1808 }
1809 
1811 {
1813 }
1814 
1816 {
1817  if(name == "Description")
1818  {
1819  return new ossimTextProperty(name, theDescription);
1820  }
1821  // "Class name" check for backwards compatibility only.
1822  else if( (name == "class_name") ||
1823  (name == "Class name") )
1824  {
1825  ossimProperty* prop = new ossimTextProperty(name,
1826  getClassName());
1827  prop->setReadOnlyFlag(true);
1828 
1829  return prop;
1830  }
1831  return ossimRefPtr<ossimProperty>();
1832 }
1833 
1834 void ossimConnectableObject::getPropertyNames(std::vector<ossimString>& propertyNames)const
1835 {
1836  propertyNames.push_back("class_name");
1837  propertyNames.push_back("Description");
1838 }
1839 
1841  const char* prefix)
1842 {
1843  const char* lookup = kwl.find(prefix,
1845 
1846  // disconnect(this);
1847 
1848  if(lookup)
1849  {
1850  theId = ossimId(ossimString(lookup).toLong());
1851  }
1852 
1853  lookup = kwl.find(prefix, CONNECTABLE_INPUT_LIST_FIXED_KW);
1854  if(lookup)
1855  {
1857  }
1858 
1859  lookup = kwl.find(prefix, CONNECTABLE_OUTPUT_LIST_FIXED_KW);
1860  if(lookup)
1861  {
1863  }
1864 
1865  ossim_int32 numberInputs = 0;
1866  ossim_int32 numberOutputs = 0;
1867 
1868  ossimString regExpression;
1869  lookup = kwl.find(prefix, ossimKeywordNames::NUMBER_INPUTS_KW);
1870  if(lookup)
1871  {
1872  numberInputs = ossimString(lookup).toLong();
1873  }
1874  else if(!theInputListIsFixedFlag)
1875  {
1876  regExpression = ossimString("^(") + ossimString(prefix) + "input_connection[0-9]+)";
1877  numberInputs = kwl.getNumberOfSubstringKeys(regExpression);
1878  }
1879  else
1880  {
1881  // if we are fixed then the list should already be set
1882  numberInputs = (ossim_int32) theInputObjectList.size();
1883  }
1884 
1885 
1886  lookup = kwl.find(prefix, ossimKeywordNames::NUMBER_OUTPUTS_KW);
1887  if(lookup)
1888  {
1889  numberOutputs = ossimString(lookup).toLong();
1890  }
1891  else if(!theOutputListIsFixedFlag)
1892  {
1893  regExpression = ossimString("^(") + ossimString(prefix) + "output_connection[0-9]+)";
1894  numberOutputs = kwl.getNumberOfSubstringKeys(regExpression);
1895  }
1896  else
1897  {
1898  // if we are fixed then the list should already be set
1899  numberOutputs = (ossim_int32) theOutputObjectList.size();
1900  }
1901 
1902  lookup = kwl.find(prefix, ossimKeywordNames::DESCRIPTION_KW);
1903  if (lookup)
1904  {
1905  theDescription = lookup;
1906  }
1907 
1908  setNumberOfInputs(numberInputs);
1909  setNumberOfOutputs(numberOutputs);
1910 
1911  return ossimObject::loadState(kwl, prefix);
1912 }
1913 
1915  const char* prefix)const
1916 {
1917  ossimObject::saveState(kwl, prefix);
1918 
1919  kwl.add(prefix,
1921  theId.getId(),
1922  true);
1923 
1924  kwl.add(prefix,
1927  true);
1928 
1929  kwl.add(prefix,
1932  true);
1933 
1934  kwl.add(prefix,
1937  true);
1938 
1939  kwl.add(prefix,
1941  static_cast<ossim_uint32>(theInputObjectList.size()),
1942  true);
1943 
1944  kwl.add(prefix,
1946  static_cast<ossim_uint32>(theOutputObjectList.size()),
1947  true);
1948 
1949  ossim_int32 i = 0;
1950  for(i = 1; i <= (ossim_int32)theInputObjectList.size(); ++i)
1951  {
1952  ossimString value = "input_connection" + ossimString::toString(i);
1953 
1954  ossim_int32 id;
1955 
1956  if(theInputObjectList[i-1].valid())
1957  {
1958  id = theInputObjectList[i-1]->getId().getId();
1959  }
1960  else
1961  {
1962  id = -1;
1963  }
1964  kwl.add(prefix,
1965  value.c_str(),
1966  id,
1967  true);
1968  }
1969 
1970  for(i = 1; i <= (ossim_int32)theOutputObjectList.size(); ++i)
1971  {
1972  ossimString value = "output_connection" + ossimString::toString(i);
1973 
1974  ossim_int32 id;
1975 
1976  if(theOutputObjectList[i-1].valid())
1977  {
1978  id = theOutputObjectList[i-1]->getId().getId();
1979  }
1980  else
1981  {
1982  id = -1;
1983  }
1984  kwl.add(prefix,
1985  value.c_str(),
1986  id,
1987  true);
1988  }
1989 
1990  return true;
1991 }
1992 
1994  bool saveThisStateFlag,
1995  ossim_uint32 objectIndex,
1996  const char* prefix) const
1997 {
1998  ossim_uint32 index = objectIndex;
1999 
2000  const ossim_uint32 NUMBER_OF_INPUTS = getNumberOfInputs();
2001  if (NUMBER_OF_INPUTS)
2002  {
2003  // Save all the inputs.
2004  for(ossim_uint32 i = 0; i < NUMBER_OF_INPUTS; ++i)
2005  {
2006  const ossimConnectableObject* input = getInput(i);
2007  if(input)
2008  index = input->saveStateOfAllInputs(kwl, true, index, prefix);
2009  }
2010  }
2011 
2012  if (saveThisStateFlag)
2013  {
2014  ossimString myPrefix;
2015  if (prefix)
2016  myPrefix = prefix;
2017 
2018  myPrefix += "object" + ossimString::toString(index) + ".";
2019 
2020  // Save the state of this object.
2021  saveState(kwl, myPrefix.c_str());
2022  ++index;
2023  }
2024 
2025  return index;
2026 }
2027 
2029 {
2030  // Insert inputs into the container:
2031  bool good_fill = true;
2032  ossim_uint32 num_inputs = getNumberOfInputs();
2033  for(ossim_uint32 i=0; (i<num_inputs) && good_fill; ++i)
2034  {
2035  ossimConnectableObject* input = getInput(i);
2036  if (input)
2037  good_fill = input->fillContainer(container);
2038  }
2039 
2040  // Insert this object and all of its children and inputs into the container provided:
2041  if (good_fill)
2042  good_fill = container.addChild(this);
2043 
2044  return good_fill;
2045 }
2046 
2048  const ossimConnectableObject* /* object */ ) const
2049 {
2051  {
2052  return ((myOutputIndex >= 0) &&
2053  (myOutputIndex < (ossim_int32)theOutputObjectList.size()));
2054  }
2055 
2056  return ((myOutputIndex >= 0) &&
2057  (myOutputIndex <= (ossim_int32)theOutputObjectList.size()));
2058 }
2059 
2061 {
2062  bool result = false;
2063 
2064  if (theInputListIsFixedFlag == false)
2065  {
2066  if ( theInputObjectList.size() )
2067  {
2068  ossim_int32 indexOfId = findInputIndex(id);
2069 
2070  if (indexOfId > 0)
2071  {
2072  ConnectableObjectList oldInputs =
2074 
2075  // Swap with index above.
2076  ossimRefPtr<ossimConnectableObject> tmpObj = theInputObjectList[indexOfId].get();
2077  theInputObjectList[indexOfId] = theInputObjectList[indexOfId-1].get();
2078  theInputObjectList[indexOfId-1] = tmpObj;
2079  result = true;
2080 
2081  ConnectableObjectList newInputs =
2083 
2084  ossimConnectionEvent event(this,
2086  newInputs,
2087  oldInputs,
2089  fireEvent(event);
2090  }
2091  }
2092  }
2093 
2094  return result;
2095 }
2096 
2098 {
2099  bool result = false;
2100 
2101  if (theInputListIsFixedFlag == false)
2102  {
2103  if ( theInputObjectList.size() )
2104  {
2105  ossim_int32 indexOfId = findInputIndex(id);
2106 
2107  if ( indexOfId <
2108  static_cast<ossim_int32>(theInputObjectList.size()-1) )
2109  {
2110  ConnectableObjectList oldInputs =
2112 
2113  // Swap with index below.
2114  ossimRefPtr<ossimConnectableObject> tmpObj = theInputObjectList[indexOfId].get();
2115  theInputObjectList[indexOfId] = theInputObjectList[indexOfId+1].get();
2116  theInputObjectList[indexOfId+1] = tmpObj;
2117  result = true;
2118 
2119  ConnectableObjectList newInputs =
2121 
2122  ossimConnectionEvent event(this,
2124  newInputs,
2125  oldInputs,
2127  fireEvent(event);
2128  }
2129  }
2130  }
2131 
2132  return result;
2133 }
2134 
2136 {
2137  bool result = false;
2138 
2139  if (theInputListIsFixedFlag == false)
2140  {
2141  if ( theInputObjectList.size() )
2142  {
2143  ConnectableObjectList::iterator i =
2144  theInputObjectList.begin();
2145 
2146  while (i != theInputObjectList.end())
2147  {
2148  if ( (*i)->getId() == id )
2149  {
2150  break;
2151  }
2152  ++i;
2153  }
2154 
2155  if ( (i != theInputObjectList.begin()) &&
2156  (i != theInputObjectList.end()) )
2157  {
2158  ConnectableObjectList oldInputs =
2160 
2162  theInputObjectList.erase(i);
2163  theInputObjectList.insert(theInputObjectList.begin(), obj.get());
2164  result = true;
2165 
2166  ConnectableObjectList newInputs =
2168 
2169  ossimConnectionEvent event(
2170  this,
2172  newInputs,
2173  oldInputs,
2175  fireEvent(event);
2176  }
2177  }
2178  }
2179 
2180  return result;
2181 }
2182 
2184 {
2185  bool result = false;
2186 
2187  if (theInputListIsFixedFlag == false)
2188  {
2189  if ( theInputObjectList.size() )
2190  {
2191  ConnectableObjectList::iterator bottom =
2192  theInputObjectList.end()-1;
2193 
2194  // if not bottom already
2195  if ( (*bottom)->getId() != id )
2196  {
2197  ConnectableObjectList::iterator i =
2198  theInputObjectList.begin();
2199 
2200  while (i != bottom)
2201  {
2202  if ( (*i)->getId() == id )
2203  {
2204  break;
2205  }
2206  ++i;
2207  }
2208 
2209  if (i != bottom)
2210  {
2211  ConnectableObjectList oldInputs =
2213 
2215  theInputObjectList.erase(i);
2216  theInputObjectList.push_back(obj);
2217  result = true;
2218 
2219  ConnectableObjectList newInputs =
2221 
2222  ossimConnectionEvent event(
2223  this,
2225  newInputs,
2226  oldInputs,
2228  fireEvent(event);
2229  }
2230  }
2231  }
2232  }
2233 
2234  return result;
2235 }
2236 
2238 {
2239  if(!visitor.stopTraversal())
2240  {
2241  if(!visitor.hasVisited(this))
2242  {
2243  visitor.visit(this);
2244  }
2245 
2246  if(!visitor.stopTraversal())
2247  {
2248 
2250  {
2251  ConnectableObjectList::iterator current = theInputObjectList.begin();
2252  while(current != theInputObjectList.end())
2253  {
2254  if((*current).get()&&!visitor.hasVisited((*current).get())) (*current)->accept(visitor);
2255  ++current;
2256  }
2257  }
2258 
2260  {
2261  // go through the outputs
2262  ConnectableObjectList::iterator current = theOutputObjectList.begin();
2263  while(current != theOutputObjectList.end())
2264  {
2265  if((*current).get()&&!visitor.hasVisited((*current).get())) (*current)->accept(visitor);
2266  ++current;
2267  }
2269 
2271  {
2272  ossimVisitor::VisitorType currentType = visitor.getVisitorType();
2273  // lets make sure inputs and outputs are turned off for we are traversing all children and we should not have
2274  // to have that enabled
2275  //
2276  visitor.turnOffVisitorType(ossimVisitor::VISIT_INPUTS);// |ossimVisitor::VISIT_CHILDREN);
2277 
2278  //obj->accept(visitor);
2279  visitor.setVisitorType(currentType);
2280  // visitor.turnOffVisitorType(ossimVisitor::VISIT_INPUTS);
2281  // now go through outputs
2282  //
2283  ConnectableObjectList::iterator current = obj->theOutputObjectList.begin();
2284  while(current != obj->theOutputObjectList.end())
2285  {
2286  if((*current).get()&&!visitor.hasVisited((*current).get())) (*current)->accept(visitor);
2287  ++current;
2288  }
2289 
2290  visitor.setVisitorType(currentType);
2291 
2292  }
2293  }
2294  }
2295  }
2296 }
2297 
2299 {
2300  theId = id;
2301 }
2302 
2304 {
2305  return theId;
2306 }
2307 
2309 {
2310  return theOwner;
2311 }
2312 
2314 {
2315  return (ossim_uint32)theInputObjectList.size();
2316 }
2317 
2319 {
2320  return (ossim_uint32)theOutputObjectList.size();
2321 }
2322 
2324 {
2325  return theInputListIsFixedFlag;
2326 }
2327 
2329 {
2330  return theOutputListIsFixedFlag;
2331 }
2332 
2334 {
2335  return theInputObjectList;
2336 }
2337 
2339 {
2340  return theOutputObjectList;
2341 }
2342 
2344 {
2345  return theInputObjectList;
2346 }
2347 
2349 {
2350  return theOutputObjectList;
2351 }
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual void setNumberOfInputs(ossim_int32 numberOfInputs)
Will set the number of inputs.
virtual void visit(ossimObject *obj)
const ossimObject * getOwner() const
Fetches the current owner, most likely a container but not limited to one.
virtual ossimRefPtr< ossimConnectableObject > disconnectMyInput(ossim_int32 inputIndex, bool disconnectOutputFlag=true, bool createEventFlag=true)
Will disconnect the object at the given input index and generate a connection event.
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...
virtual void setDescription(const ossimString &description)
RTTI_DEF3(ossimConnectableObject, "ossimConnectableObject", ossimObject, ossimListenerManager, ossimPropertyInterface)
bool moveInputUp(const ossimId &id)
Moves the input connection matching id up one in the connection list.
virtual void disconnectAllOutputs()
Will disconnect all of the output objects.
ossim_uint32 getNumberOfSubstringKeys(const ossimString &regularExpression) const
const char * CONNECTABLE_INPUT_LIST_FIXED_KW
virtual ossimConnectableObject * findFirstObjectOfType(const RTTItypeid &typeInfo, bool recurse=true)=0
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
virtual bool getInputListIsFixedFlag() const
virtual ossim_uint32 getNumberOfObjects(bool recurse=true) const =0
Represents serializable keyword/value map.
virtual void disconnectMyInputs(ConnectableObjectList &inputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
virtual bool getOutputListIsFixedFlag() const
void setVisitorType(int vType, bool on=true)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Definition: ossimObject.cpp:95
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
#define OSSIM_EVENT_CONNECTION_DISCONNECT_ID
Definition: ossimEventIds.h:21
virtual bool connectOutputList(ConnectableObjectList &outputList)
Will disconnect itself from all outputs and reset to the passed in output list.
virtual void propagateEventToOutputs(ossimEvent &event)
virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const RTTItypeid &typeInfo, bool recurse=true)=0
static ossimString toString(bool aValue)
Numeric to string methods.
bool moveInputToBottom(const ossimId &id)
Moves the input connection matching id to the bottom of the connection list.
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
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.
ossimConnectableObject(ossimObject *owner=0)
Base constructor of this object.
virtual void setReadOnlyFlag(bool flag)
virtual ossim_uint32 getNumberOfOutputs() const
Return the number of output objects.
ossim_int64 getId() const
Definition: ossimId.h:29
bool moveInputDown(const ossimId &id)
Moves the input connection matching id down one in the connection list.
virtual void fireEvent(ossimEvent &event)
void turnOffVisitorType(int vType)
static const char * NUMBER_INPUTS_KW
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...
ossimConnectableObject * getInput(ossim_uint32 index=0)
returns the object at the specified index.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual ossim_int32 getMyOutputIndexToConnectTo(ossimConnectableObject *object) const
Should return the first available index to connect to.
const ConnectableObjectList & getInputList() const
ossimId generateId()
std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
ossimConnectableObject * getOutput(ossim_uint32 index=0)
returns the object at the specified index.
virtual void changeOwner(ossimObject *owner)
Permits changing the object&#39;s owner.
#define OSSIM_EVENT_CONNECTION_CONNECT_ID
Definition: ossimEventIds.h:22
virtual ossim_int32 getMyInputIndexToConnectTo(ossimConnectableObject *object) const
Should return the first available index to connect to.
virtual bool isConnected(ossimConnectableObjectDirectionType direction=CONNECTABLE_DIRECTION_INPUT) const
will check the direction specified to see if all slots are full.
virtual ossimString getDescription() const
const ossimId & getId() const
Will allow us to get this object&#39;s id.
bool toBool() const
String to numeric methods.
unsigned int ossim_uint32
bool moveInputToTop(const ossimId &id)
Moves the input connection matching id to the top of the connection list.
bool hasVisited(ossimObject *obj) const
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual void propagateEventToInputs(ossimEvent &event)
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
const char * CONNECTABLE_OUTPUT_LIST_FIXED_KW
ossimConnectableObject * getObject()
ossimConnectableObject * findObjectOfType(ConnectableObjectList *connectableList, ossimVisitor &visitor)
virtual bool connectInputList(ConnectableObjectList &inputList)
Will disconnect itself from all inputs and reset to the passed in input list.
ossimObject * getObject(ossim_uint32 idx=0)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
const ConnectableObjectList & getOutputList() const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual ossim_int32 connectMyOutputTo(ossimConnectableObject *outputObject, bool makeInputConnection=true, bool createEventFlag=true)
Will try to connect this objects output to the passed in object.
long toLong() const
toLong&#39;s deprecated, please use the toInts...
ConnectableObjectList theInputObjectList
Holds a list of input objects.
virtual bool addChild(ossimConnectableObject *attachableObject)
static const char * DESCRIPTION_KW
virtual void setProperty(const ossimString &name, const ossimString &value)
virtual ossim_uint32 getNumberOfInputs() const
Returns the number of input objects.
virtual ossimConnectableObject * getConnectableObject(ossim_uint32 index)=0
VisitorType getVisitorType() const
virtual bool canCastTo(ossimObject *obj) const
Definition: ossimObject.cpp:74
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
bool theInputListIsFixedFlag
Indicates whether the theInputObjectList is fixed.
static const char * ID_KW
ConnectableObjectList theOutputObjectList
Holds a list of output objects.
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 ossimRefPtr< ossimConnectableObject > disconnectMyOutput(ossim_int32 outputIndex, bool disconnectInputFlag=true, bool createEventFlag=true)
Will disconnect the object at the given output index and generate a connection event.
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.
virtual bool canConnectMyInputTo(ossim_int32 myInputIndex, const ossimConnectableObject *object) const =0
required to be overriden by derived classes
void setId(const ossimId &id)
All connectable objects will have id&#39;s.
bool theOutputListIsFixedFlag
Indicates whether the theOutputObjectList is fixed.
virtual bool canConnectMyOutputTo(ossim_int32 myOutputIndex, const ossimConnectableObject *object) const
default implementation is to allow anyone to connect to us.
virtual void disconnectAllInputs()
Will disconnect all of the input objects.
virtual bool fillContainer(ossimConnectableContainer &container)
Inserts this object and all of its children and inputs into the container provided.
static const char * NUMBER_OUTPUTS_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
static ossimIdManager * instance()
const ossimString & getName() const
int ossim_int32
virtual void disconnectMyOutputs(ConnectableObjectList &outputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
virtual void setNumberOfOutputs(ossim_int32 numberOfInputs)
Will set the number of outputs.