-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogger.h
95 lines (72 loc) · 3.05 KB
/
logger.h
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
//
// logger.h
// Xcode
//
// Created by jacob on 7/18/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
// Logger singleton.
// NOTE: Construction is NOT thread-safe, must be initialized in main before any threads are spawned.
#ifndef LOGGER_H
#define LOGGER_H
#include <fstream>
using std::ofstream;
#include <iostream>
using std::cout;
using std::endl;
#include <string>
#include <boost/thread/mutex.hpp>
// Forward decleration of objects.
class Photon;
class Vector3d;
class Logger
{
public:
static Logger * getInstance(void);
void openExitFile(std::string filename);
void openAbsorberFile(std::string filename);
void openMetaData(std::string filename);
void write(double val);
void writeMetaData(const double absorberRadius, const double detectorRadius,
const int Nphotons, const double detectorPlane, const Vector3d &absorberLocation);
void writeExitData(const boost::shared_ptr<Vector3d> vectorCoords);
void writeExitData(const boost::shared_ptr<Vector3d> vectorCoords,
const double weight,
bool tagged);
void writeExitData(const boost::shared_ptr<Vector3d> photonVector,
const double weight);
void writeExitData(const boost::shared_ptr<Vector3d> photonVector,
const double weight,
const double transmissionAngle);
void writeAbsorberData(const double absorbedWeight);
// XXX: Finish me
void writeAbsorberData(const double absorbedWeight,
const double theta,
const double phi);
// Writes the photon's weight, transmission angle, modulated path length through the medium,
// and its exit location on the exit detector window.
void writeWeightAngleLengthCoords(const double exitWeight,
const double transmissionAngle,
const double modulatedPathLength,
const boost::shared_ptr<Vector3d> photonVector);
// XXX:
// - Does this introduce race conditions by pointing to a threaded object that could
// potentially have data changing in obscure ways? Unsure, but each object is given
// it's own CPU "core" to run on, which means any object's state between switches (which
// there should be none (i.e. context switching) in a perfect world since threads == cores)
// should be coherent.
void writePhoton(Photon *p);
private:
Logger(); // default constructor is private
Logger(Logger const&){}; // copy constructor is private
~Logger();
Logger& operator=(Logger const&){}; // assignment operator is private
static Logger * pInstance;
// The output streams associated with data for the photon and data for
// the absorbers.
ofstream exit_data_stream;
ofstream absorber_data_stream;
ofstream meta_data_stream;
boost::mutex m_mutex;
};
#endif