PetaVision  Alpha
ColProbe.cpp
1 /*
2  * ColProbe.cpp
3  *
4  * Created on: Nov 25, 2010
5  * Author: pschultz
6  */
7 
8 #include "ColProbe.hpp"
9 #include "columns/HyPerCol.hpp"
10 
11 namespace PV {
12 
13 ColProbe::ColProbe() { // Default constructor to be called by derived classes.
14  // They should call ColProbe::initialize from their own initialization routine
15  // instead of calling a non-default constructor.
17 }
18 
19 ColProbe::ColProbe(const char *name, HyPerCol *hc) {
21  initialize(name, hc);
22 }
23 
25 
27  parent = NULL;
28  return PV_SUCCESS;
29 }
30 
31 int ColProbe::initialize(const char *name, HyPerCol *hc) {
32  int status = BaseProbe::initialize(name, hc);
33  return status;
34 }
35 
36 int ColProbe::ioParamsFillGroup(enum ParamsIOFlag ioFlag) {
37  int status = PV::BaseProbe::ioParamsFillGroup(ioFlag);
38  return status;
39 }
40 
41 void ColProbe::ioParam_targetName(enum ParamsIOFlag ioFlag) {
42  if (ioFlag == PARAMS_IO_READ) {
43  targetName = strdup("");
44  }
45 }
46 
47 void ColProbe::initOutputStreams(const char *filename, Checkpointer *checkpointer) {
48  BaseProbe::initOutputStreams(filename, checkpointer);
49  outputHeader();
50 }
51 
52 Response::Status ColProbe::respond(std::shared_ptr<BaseMessage const> message) {
53  Response::Status status = BaseProbe::respond(message);
54  if (status != Response::SUCCESS) {
55  return status;
56  }
57  else if (
58  auto castMessage = std::dynamic_pointer_cast<ColProbeOutputStateMessage const>(message)) {
59  return respondColProbeOutputState(castMessage);
60  }
61  else if (
62  auto castMessage = std::dynamic_pointer_cast<ColProbeWriteParamsMessage const>(message)) {
63  return respondColProbeWriteParams(castMessage);
64  }
65  else {
66  return status;
67  }
68 }
69 
70 Response::Status
71 ColProbe::respondColProbeWriteParams(std::shared_ptr<ColProbeWriteParamsMessage const>(message)) {
72  writeParams();
73  return Response::SUCCESS;
74 }
75 
76 Response::Status
77 ColProbe::respondColProbeOutputState(std::shared_ptr<ColProbeOutputStateMessage const>(message)) {
78  return outputStateWrapper(message->mTime, message->mDeltaTime);
79 }
80 
81 Response::Status
82 ColProbe::communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) {
83  return BaseProbe::communicateInitInfo(message);
84 }
85 
86 } // end namespace PV
virtual ~ColProbe()
Definition: ColProbe.cpp:24
virtual void ioParam_targetName(enum ParamsIOFlag ioFlag) override
targetName: ColProbe sets targetName to the empty string, since the only possible target is the paren...
Definition: ColProbe.cpp:41
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
Definition: BaseProbe.cpp:76
int initialize(const char *name, HyPerCol *hc)
Definition: ColProbe.cpp:31
virtual void initOutputStreams(const char *filename, Checkpointer *checkpointer)
Definition: BaseProbe.cpp:174
int initialize_base()
Definition: ColProbe.cpp:26
virtual Response::Status outputStateWrapper(double timef, double dt)
Definition: BaseProbe.cpp:358
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override
Definition: ColProbe.cpp:82
void writeParams()
Definition: BaseObject.hpp:69
virtual void outputHeader()
Definition: ColProbe.hpp:118
virtual void initOutputStreams(const char *filename, Checkpointer *checkpointer) override
Definition: ColProbe.cpp:47
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
Definition: ColProbe.cpp:36
int initialize(const char *name, HyPerCol *hc)
Definition: BaseProbe.cpp:64
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override=0
Definition: BaseProbe.cpp:240