OpenFrames
DescendantTracker.hpp
Go to the documentation of this file.
1 /***********************************
2  Copyright 2018 Ravishankar Mathur
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 ***********************************/
16 
21 #ifndef _OF_DESCENDANTTRACKER_
22 #define _OF_DESCENDANTTRACKER_
23 
24 #include <OpenFrames/Export.h>
26 #include <vector>
27 
28 namespace OpenFrames {
29 
30 class ReferenceFrame;
31 typedef std::vector<ReferenceFrame*> FramePath;
32 
41  class OF_EXPORT DescendantTracker : public FrameTracker
42  {
43  public:
46 
47  virtual void childAdded( ReferenceFrame* child, ReferenceFrame* parent ) {}
48 
51  virtual void childRemoved( ReferenceFrame* child, ReferenceFrame* parent );
52 
54  virtual void setRoot( ReferenceFrame* frame );
55 
57  bool trackDescendant( ReferenceFrame* frame );
58  inline ReferenceFrame* getTrackedDescendant()
59  {
60  if( _tracking ) return _framePath.back();
61  else return NULL;
62  }
63 
65  inline const FramePath& getFramePath() { return _framePath; }
66 
68  inline bool isTrackingDescendant() { return _tracking; }
69 
70  protected:
71  virtual ~DescendantTracker();
72 
73  bool _trackDescendant( ReferenceFrame* frame, ReferenceFrame* parent );
74  void _clearPath();
75 
76  FramePath _framePath;
77  bool _tracking;
78  }; // !class DescendantTracker
79 
80 } // !namespace OpenFrames
81 #endif // !_OF_DESCENDANTTRACKER_
This class tracks children of a reference frame.
Definition: FrameTracker.hpp:41
Definition: CoordinateAxes.hpp:29
const FramePath & getFramePath()
Definition: DescendantTracker.hpp:65
Definition: ReferenceFrame.hpp:54
This class stores the path from the tracked frame.
Definition: DescendantTracker.hpp:41
bool isTrackingDescendant()
Definition: DescendantTracker.hpp:68