/usr/include/magics/MagicsSingleton.h is in libmagics++-dev 2.18.15-5.
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 | /******************************** LICENSE ********************************
Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************** LICENSE ********************************/
/*! \file MagicsSingleton.h
\brief Definition of ...
Magics Team - ECMWF 2006
Started: Wed 27-Oct-2006
*/
#ifndef MagicsSingleton_H
#define MagicsSingleton_H
#include "magics.h"
#include "Data.h"
#include "UserPoint.h"
#include "Axis.h"
#include "Timer.h"
#include "XYList.h"
#include "GraphPlotting.h"
#include "EpsGraph.h"
#include "UserPointsDecoder.h"
#include "GribDecoder.h"
#include "OutputHandler.h"
#include "InputMatrix.h"
#include "MagicsSingletonAttributes.h"
namespace magics {
class MagicsSingleton : public MagicsSingletonAttributes
{
MagicsSingleton() : magics_(0),
page_(false),
geoTask_(0),
xyTask_(0),
timer_("Magics processing", MagLog::info()),
x_("x"), y_("y")
{
if (singleton_) return;
singleton_ = this;
magics_ = new MagicsManager();
output_.set(*magics_);
}
~MagicsSingleton() { MagLog::debug() << "Delete MagicsSingleton\n"; }
static MagicsSingleton* singleton_;
public:
static PlotManager& manager()
{
if (!singleton_) new MagicsSingleton();
return *(singleton_->layout_);
}
static void checkPage()
{
if (!singleton_) new MagicsSingleton();
singleton_->layout_->check(*(singleton_->magics_));
}
static void execute()
{
assert(singleton_);
MagLog::dev() << "Execute --->" << *(singleton_->magics_->root()) << "\n";
singleton_->magics_->execute();
}
static VisualTask<UserPoint>* getGeoTask()
{
assert(singleton_);
return singleton_->geoTask();
}
static VisualTask<UserPoint>* getXYTask()
{
assert(singleton_);
return singleton_->xyTask();
}
static void close()
{
if (!singleton_) new MagicsSingleton();
MagLog::dev() << "Close --->" << *(singleton_->magics_->root()) << "\n";
singleton_->magics_->execute();
singleton_->magics_->close();
delete singleton_;
singleton_ = 0;
}
static void createTask(Data* data)
{
if (!singleton_) new MagicsSingleton();
checkPage();
singleton_->geoTask_ = new VisualTask<UserPoint>();
singleton_->layout_->add(singleton_->geoTask_);
singleton_->geoTask_->set(data);
}
static void createTask(Data* data)
{
if (!singleton_) new MagicsSingleton();
checkPage();
singleton_->xyTask_ = new VisualTask<UserPoint>();
singleton_->layout_->add(singleton_->xyTask_);
singleton_->xyTask_->set(data);
}
static void superpage()
{
if (!singleton_) new MagicsSingleton();
singleton_->layout_->superpage(*(singleton_->magics_));
singleton_->page_ = false;
// singleton_->magics_->resetRoot();
}
static void page()
{
if (!singleton_) new MagicsSingleton();
singleton_->layout_->page(*(singleton_->magics_));
singleton_->page_ = true;
// singleton_->magics_->resetRoot();
}
static void subpage()
{
if (!singleton_) new MagicsSingleton();
singleton_->layout_->subpage(*(singleton_->magics_));
singleton_->page_ = true;
// singleton_->magics_->resetRoot();
}
static void add(BaseSceneObject* object)
{
singleton_->layout_->add(object);
}
static void addVisualiser(Visualiser<UserPoint>* visdef)
{
if (!singleton_) new MagicsSingleton();
if (!singleton_->xyTask_)
{
XYList* input = new XYList();
MagicsSingleton::createTask(input);
MagLog::dev() << *input << "\n";
//throw MagicsException("Plotting routine called prior any Data definition--> The call is ignored");
}
singleton_->xyTask_->set(visdef);
singleton_->xyTask_ = 0;
}
static void addVisualiser(Visualiser<UserPoint>* visdef)
{
if (!singleton_) new MagicsSingleton();
if (!singleton_->geoTask_)
{
InputMatrix* input = new InputMatrix();
if (input->defined() ) {
MagicsSingleton::createTask(input);
MagLog::dev() << *input << "\n";
}
else {
delete input;
GribDecoder* grib = new GribDecoder();
MagicsSingleton::createTask(grib);
MagLog::dev() << *grib << "\n";
}
//throw MagicsException("Plotting routine called prior any Data definition--> The call is ignored");
}
singleton_->geoTask_->set(visdef);
singleton_->geoTask_ = 0;
}
VisualTask<UserPoint>* geoTask() { return geoTask_; }
VisualTask<UserPoint>* xyTask() { return xyTask_; }
static bool xIsDate() {
if (!singleton_) new MagicsSingleton();
return (singleton_->x_ == "date");
}
static bool yIsDate() {
if (!singleton_) new MagicsSingleton();
return (singleton_->y_ == "date");
}
static void xIsDate(bool date) {
if (!singleton_) new MagicsSingleton();
singleton_->x_ = date ? "date" : "x";
}
static void yIsDate(bool date) {
if (!singleton_) new MagicsSingleton();
singleton_->y_ = date ? "date" : "y";
}
static void setHorizontalAxis(HorizontalAxis* axis) {
if (!singleton_) new MagicsSingleton();
singleton_->haxis_ = axis;
}
static void setVerticalAxis(VerticalAxis* axis) {
if (!singleton_) new MagicsSingleton();
singleton_->vaxis_ = axis;
}
static bool isCartesianSystem() {
return singleton_->haxis_ && singleton_->vaxis_;
}
static void setCartesianSystem() {
checkPage();
if (singleton_->haxis_) {
add(singleton_->haxis_);
singleton_->haxis_ = 0;
}
if (singleton_->vaxis_) {
add(singleton_->vaxis_);
singleton_->vaxis_ = 0;
}
}
protected :
MagicsManager* magics_;
bool page_;
bool superpage_;
VisualTask<UserPoint>* geoTask_;
VisualTask<UserPoint>* xyTask_;
Timer timer_;
string x_;
string y_;
HorizontalAxis* haxis_;
VerticalAxis* vaxis_;
OutputHandler output_;
};
} // namespace magics
#endif
|