PetaVision  Alpha
CopyConn.cpp
1 /*
2  * CopyConn.cpp
3  *
4  * Created on: Nov 19, 2014
5  * Author: pschultz
6  */
7 
8 #include "CopyConn.hpp"
9 #include "columns/HyPerCol.hpp"
10 #include "components/CopyWeightsPair.hpp"
11 #include "components/DependentArborList.hpp"
12 #include "components/DependentPatchSize.hpp"
13 #include "components/DependentSharedWeights.hpp"
14 #include "utils/MapLookupByType.hpp"
15 #include "weightupdaters/CopyUpdater.hpp"
16 
17 namespace PV {
18 
19 CopyConn::CopyConn(char const *name, HyPerCol *hc) { initialize(name, hc); }
20 
21 CopyConn::CopyConn() {}
22 
23 CopyConn::~CopyConn() {}
24 
25 int CopyConn::initialize(char const *name, HyPerCol *hc) {
26  int status = HyPerConn::initialize(name, hc);
27  return status;
28 }
29 
30 void CopyConn::defineComponents() {
31  HyPerConn::defineComponents();
32  mOriginalConnNameParam = createOriginalConnNameParam();
33  if (mOriginalConnNameParam) {
34  addObserver(mOriginalConnNameParam);
35  }
36 }
37 
38 ArborList *CopyConn::createArborList() { return new DependentArborList(name, parent); }
39 
40 PatchSize *CopyConn::createPatchSize() { return new DependentPatchSize(name, parent); }
41 
42 SharedWeights *CopyConn::createSharedWeights() { return new DependentSharedWeights(name, parent); }
43 
44 WeightsPairInterface *CopyConn::createWeightsPair() { return new CopyWeightsPair(name, parent); }
45 
46 InitWeights *CopyConn::createWeightInitializer() { return nullptr; }
47 
48 BaseWeightUpdater *CopyConn::createWeightUpdater() { return new CopyUpdater(name, parent); }
49 
50 OriginalConnNameParam *CopyConn::createOriginalConnNameParam() {
51  return new OriginalConnNameParam(name, parent);
52 }
53 
54 Response::Status CopyConn::initializeState() {
55  auto *copyWeightsPair = dynamic_cast<CopyWeightsPair *>(mWeightsPair);
56  pvAssert(copyWeightsPair);
57  if (!copyWeightsPair->getOriginalWeightsPair()->getInitialValuesSetFlag()) {
58  return Response::POSTPONE;
59  }
60  copyWeightsPair->copy();
61  return Response::SUCCESS;
62 }
63 
64 } // namespace PV
virtual void addObserver(Observer *observer) override