This file is indexed.

/usr/include/crystalspace-2.0/cstool/animnodetmpl.h is in libcrystalspace-dev 2.0+dfsg-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/*
  Copyright (C) 2011 Christian Van Brussel, Institute of Information
      and Communication Technologies, Electronics and Applied Mathematics
      at Universite catholique de Louvain, Belgium
      http://www.uclouvain.be/en-icteam.html

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Library General Public License for more details.

  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CS_IMESH_ANIMNODE_TEMPLATE_H__
#define __CS_IMESH_ANIMNODE_TEMPLATE_H__

/**\file
 * Base implementation of CS::Animation::iSkeletonAnimNodeFactory and CS::Animation::iSkeletonAnimNode objects.
 */

#include "csextern.h"
#include "csutil/csstring.h"
#include "csutil/refarr.h"
#include "csutil/scf_implementation.h"
#include "csutil/weakref.h"
#include "imesh/animnode/skeleton2anim.h"
#include "iutil/comp.h"

namespace CS {
namespace Animation {

  /**
   * Template class for animation node plugin managers.
   * Usage:
   * - Your node manager class must descend from AnimNodeManagerCommon.
   * - \a ThisType must be the name of your node manager class, eg \a DebugNodeManager.
   * - \a ManagerInterface must be the interface type of your node manager, eg \a CS::Animation::iSkeletonDebugNodeManager.
   * - \a FactoryType is the node factory to be manipulated by your node manager, eg \a DebugNodeFactory.
   *
   * Here is an example of definition and implementation:
   * \code
   * class DebugNodeManager
   *   : public CS::Animation::AnimNodeManagerCommon
   *               <DebugNodeManager,
   *                CS::Animation::iSkeletonDebugNodeManager,
   *                DebugNodeFactory>
   * {
   * public:
   *   DebugNodeManager (iBase* parent)
   *    : AnimNodeManagerCommonType (parent) {}
   * };
   * \endcode
   */
  template<typename ThisType,
	   typename ManagerInterface,
	   typename FactoryType>
  class AnimNodeManagerCommon
    : public scfImplementation2<AnimNodeManagerCommon<ThisType, ManagerInterface, FactoryType>,
				ManagerInterface,
				iComponent>
  {
    typedef typename ManagerInterface::FactoryInterfaceType FactoryInterfaceType;
    typedef scfImplementation2<AnimNodeManagerCommon<ThisType, ManagerInterface, FactoryType>,
				ManagerInterface,
				iComponent> scfImplementationType;
  public:
    typedef AnimNodeManagerCommon<ThisType, ManagerInterface, FactoryType> AnimNodeManagerCommonType;
    
    AnimNodeManagerCommon (iBase* parent)
      : scfImplementationType (this, parent), object_reg (nullptr)
    {}      
    
    FactoryInterfaceType* CreateAnimNodeFactory (const char* name)
    {
      csRef<FactoryInterfaceType> newFact;
      newFact.AttachNew (new FactoryType (static_cast<ThisType*> (this), name));
      return nodeFactories.PutUnique (name, newFact);
    }
    FactoryInterfaceType* FindAnimNodeFactory (const char* name)
    {
      return nodeFactories.Get (name, 0);
    }
    void RemoveAnimNodeFactory (const char* name)
    {
      nodeFactories.DeleteAll (name);
    }
    void ClearAnimNodeFactories ()
    {
      nodeFactories.DeleteAll ();
    }
    
    /**\name iComponent implementation
     * @{ */
    bool Initialize (iObjectRegistry* object_reg)
    { this->object_reg = object_reg; return true; }
    /** @} */
    
    iObjectRegistry* GetObjectRegistry() const { return object_reg; }
  protected:
    iObjectRegistry* object_reg;
    csHash<csRef<FactoryInterfaceType>, csString> nodeFactories;
  };

/**
 * Base implementation of a CS::Animation::iSkeletonAnimNodeFactory
 */
class CS_CRYSTALSPACE_EXPORT SkeletonAnimNodeFactory
  : public virtual iSkeletonAnimNodeFactory
{
 public:
  /**
   * Constructor
   */
  SkeletonAnimNodeFactory (const char* name);

  /**
   * Destructor
   */
  virtual ~SkeletonAnimNodeFactory () {}

  /**
   * Get the name of this factory
   */
  virtual const char* GetNodeName () const;

 protected:
  /// The name of this factory
  csString name;
};

class SkeletonAnimNodeSingleBase;

/**
 * Base implementation of a CS::Animation::iSkeletonAnimNodeFactory with a single child
 */
class CS_CRYSTALSPACE_EXPORT SkeletonAnimNodeFactorySingle
  : public SkeletonAnimNodeFactory
{
 public:
  /**
   * Constructor
   */
  SkeletonAnimNodeFactorySingle (const char* name);

  /**
   * Destructor
   */
  virtual ~SkeletonAnimNodeFactorySingle () {}

  /**
   * Set the child animation node of this node. It is valid to provide a null pointer.
   */
  virtual void SetChildNode (iSkeletonAnimNodeFactory* factory);

  /**
   * Get the child animation node of this node, or nullptr if there are none.
   */
  virtual iSkeletonAnimNodeFactory* GetChildNode () const;

  csPtr<iSkeletonAnimNode> CreateInstance (iSkeletonAnimPacket* packet, iSkeleton* skeleton);
  iSkeletonAnimNodeFactory* FindNode (const char* name);

 protected:
  /// Factory of the child node
  csRef<CS::Animation::iSkeletonAnimNodeFactory> childNodeFactory;
  
  /// To be overridden by derived classes: create actual instance of a node
  virtual csPtr<SkeletonAnimNodeSingleBase> ActualCreateInstance (iSkeletonAnimPacket* packet,
								  iSkeleton* skeleton) = 0;
};

/// Methods of SkeletonAnimNodeSingle not dependent on the factory type.
class CS_CRYSTALSPACE_EXPORT SkeletonAnimNodeSingleBase : public virtual iSkeletonAnimNode
{
 public:
  /**
   * Constructor
   */
  SkeletonAnimNodeSingleBase (CS::Animation::iSkeleton* skeleton);

  /**
   * Destructor
   */
  virtual ~SkeletonAnimNodeSingleBase () {}

  /** 
   * Get the child node of this node, or nullptr if there are none. 
   */ 
  virtual iSkeletonAnimNode* GetChildNode () const;

  virtual void Play ();
  virtual void Stop ();
  virtual void SetPlaybackPosition (float time);
  virtual float GetPlaybackPosition () const;
  virtual float GetDuration () const;
  virtual void SetPlaybackSpeed (float speed);
  virtual float GetPlaybackSpeed () const;
  virtual void BlendState (AnimatedMeshState* state, float baseWeight = 1.0f);
  virtual void TickAnimation (float dt);
  virtual bool IsActive () const;
  virtual void AddAnimationCallback (iSkeletonAnimCallback* callback);
  virtual void RemoveAnimationCallback (iSkeletonAnimCallback* callback);

protected:
  /// Reference to the skeleton animated by this node
  csWeakRef<CS::Animation::iSkeleton> skeleton;

  /// Reference to the child node of this node
  csRef<CS::Animation::iSkeletonAnimNode> childNode;

  /// Whether or not iSkeletonAnimNode::Play() has been called
  bool isPlaying;

  /// Speed of the animation of this node
  float playbackSpeed;

  friend class SkeletonAnimNodeFactorySingle;
};

/**
 * Base implementation of a CS::Animation::iSkeletonAnimNode with a single child.
 * \a FactoryType is the the of the node factory; it must be (publicly) derived
 * from SkeletonAnimNodeFactory.
 */
template<typename FactoryType>
class SkeletonAnimNodeSingle : public SkeletonAnimNodeSingleBase
{
public:
  SkeletonAnimNodeSingle (FactoryType* factory,
			  CS::Animation::iSkeleton* skeleton)
   : SkeletonAnimNodeSingleBase (skeleton), factory (factory) {}
  
  iSkeletonAnimNodeFactory* GetFactory () const
  {
    return factory;
  }

  iSkeletonAnimNode* FindNode (const char* name)
  {
    if (strcmp (factory->GetNodeName (), name) == 0)
      return this;

    if (childNode)
      return childNode->FindNode (name);

    return nullptr;
  }

protected:
  /// Reference to the factory that instanced this node.
  csRef<FactoryType> factory;
};

/**
 * Base implementation of a CS::Animation::iSkeletonAnimNodeFactory with more than one child
 */
class CS_CRYSTALSPACE_EXPORT SkeletonAnimNodeFactoryMulti
  : public SkeletonAnimNodeFactory
{
 public:
  /**
   * Constructor
   */
  SkeletonAnimNodeFactoryMulti (const char* name);

  /**
   * Destructor
   */
  virtual ~SkeletonAnimNodeFactoryMulti () {}

  /**
   * Add a child animation node to this node. It is NOT valid to provide a null pointer.
   */
  virtual void AddChildNode (iSkeletonAnimNodeFactory* factory);

  /**
   * Remove a child animation node from this node.
   */
  virtual void RemoveChildNode (iSkeletonAnimNodeFactory* factory);

  /**
   * Remove all child animation nodes from this node.
   */
  virtual void ClearChildNodes ();

  /**
   * Get the child animation node of this node with the given index.
   */
  virtual iSkeletonAnimNodeFactory* GetChildNode (size_t index) const;

 protected:
  /// Array of child node factories
  csRefArray<CS::Animation::iSkeletonAnimNodeFactory> childNodeFactories;
};

} // namespace Animation
} // namespace CS

#endif // __CS_IMESH_ANIMNODE_TEMPLATE_H__