summaryrefslogtreecommitdiff
path: root/src/TObj/TObj_SequenceIterator.cxx
blob: 1913e887ca27cffbc37c7304288e922c6795a98b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// File:        TObj_SequenceIterator.cxx
// Created:     Tue Nov 23 12:39:22 2004
// Author:      Pavel TELKOV
// Copyright:   Open CASCADE  2007
// The original implementation Copyright: (C) RINA S.p.A

#include <TObj_SequenceIterator.hxx>

#include <TObj_Object.hxx>

IMPLEMENT_STANDARD_HANDLE(TObj_SequenceIterator,TObj_ObjectIterator)
IMPLEMENT_STANDARD_RTTIEXT(TObj_SequenceIterator,TObj_ObjectIterator)

//=======================================================================
//function : TObj_SequenceIterator
//purpose  :
//=======================================================================

TObj_SequenceIterator::TObj_SequenceIterator() :
  myIndex( 1 )
{
}

//=======================================================================
//function : TObj_SequenceIterator
//purpose  :
//=======================================================================

TObj_SequenceIterator::TObj_SequenceIterator
  (const Handle(TObj_HSequenceOfObject)& theObjects,
   const Handle(Standard_Type)&              theType)
{
  myIndex = 1;
  myType = theType;
  myObjects = theObjects;
}

//=======================================================================
//function : More
//purpose  :
//=======================================================================

Standard_Boolean TObj_SequenceIterator::More() const
{
  const Standard_Boolean isMore = (!myObjects.IsNull() &&
                                   (myIndex <= myObjects->Length() && myIndex > 0) &&
                                   !myObjects->Value(myIndex).IsNull());

  // check type
  if (isMore && !myType.IsNull() && !myObjects->Value(myIndex)->IsKind( myType ))
  {
    TObj_SequenceIterator* me = (TObj_SequenceIterator*) this;
    me->Next();
    return More();
  }

  return isMore;
}

//=======================================================================
//function : Next
//purpose  :
//=======================================================================

void TObj_SequenceIterator::Next()
{ myIndex++; }

//=======================================================================
//function : Value
//purpose  :
//=======================================================================

Handle(TObj_Object) TObj_SequenceIterator::Value() const
{
  return myObjects->Value(myIndex);
}