1 // trajmanager.h
2 //
3 // Copyright (C) 2001-2007 Chris Laurel <claurel@shatters.net>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 
10 #ifndef CELENGINE_TRAJMANAGER_H_
11 #define CELENGINE_TRAJMANAGER_H_
12 
13 #include <string>
14 #include <map>
15 #include <celutil/resmanager.h>
16 #include <celengine/orbit.h>
17 #include <celengine/samporbit.h>
18 
19 
20 class TrajectoryInfo : public ResourceInfo<Orbit>
21 {
22  public:
23     std::string source;
24     std::string path;
25     TrajectoryInterpolation interpolation;
26     TrajectoryPrecision precision;
27 
28     TrajectoryInfo(const std::string _source,
29                    const std::string _path = "",
30                    TrajectoryInterpolation _interpolation = TrajectoryInterpolationCubic,
31                    TrajectoryPrecision _precision = TrajectoryPrecisionSingle) :
source(_source)32         source(_source), path(_path), interpolation(_interpolation), precision(_precision) {};
33 
34     virtual std::string resolve(const std::string&);
35     virtual Orbit* load(const std::string&);
36 };
37 
38 // Sort trajectory info records. The same trajectory can be loaded multiple times with
39 // different attributes for precision and interpolation. How the ordering is defined isn't
40 // as important making this operator distinguish between trajectories with either different
41 // sources or different attributes.
42 inline bool operator<(const TrajectoryInfo& ti0, const TrajectoryInfo& ti1)
43 {
44     if (ti0.interpolation == ti1.interpolation)
45     {
46         if (ti0.precision == ti1.precision)
47         {
48             if (ti0.source == ti1.source)
49                 return ti0.path < ti1.path;
50             else
51                 return ti0.source < ti1.source;
52         }
53         else
54         {
55             return ti0.precision < ti1.precision;
56         }
57     }
58     else
59     {
60         return ti0.interpolation < ti1.interpolation;
61     }
62 }
63 
64 typedef ResourceManager<TrajectoryInfo> TrajectoryManager;
65 
66 extern TrajectoryManager* GetTrajectoryManager();
67 
68 #endif // CELENGINE_TRAJMANAGER_H_
69 
70