8 #include "ConnectionData.hpp" 9 #include "columns/HyPerCol.hpp" 10 #include "columns/ObjectMapComponent.hpp" 11 #include "utils/MapLookupByType.hpp" 15 ConnectionData::ConnectionData(
char const *name, HyPerCol *hc) { initialize(name, hc); }
17 ConnectionData::ConnectionData() {}
19 ConnectionData::~ConnectionData() {
24 int ConnectionData::initialize(
char const *name, HyPerCol *hc) {
25 return BaseObject::initialize(name, hc);
28 void ConnectionData::setObjectType() { mObjectType =
"ConnectionData"; }
37 this->parent->parameters()->ioParamString(
38 ioFlag, this->getName(),
"preLayerName", &mPreLayerName, NULL,
false );
42 this->parent->parameters()->ioParamString(
43 ioFlag, this->getName(),
"postLayerName", &mPostLayerName, NULL,
false );
47 ConnectionData::communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) {
49 std::string preLayerNameString, postLayerNameString;
52 parent->getCommunicator()->globalCommRank(),
55 mPreLayerName = strdup(preLayerNameString.c_str());
56 mPostLayerName = strdup(postLayerNameString.c_str());
58 MPI_Barrier(this->parent->getCommunicator()->globalCommunicator());
60 if (parent->getCommunicator()->globalCommRank() == 0) {
62 "%s: Unable to determine pre- and post-layer names. Exiting.\n", getDescription_c());
67 auto hierarchy = message->mHierarchy;
69 mapLookupByType<ObjectMapComponent>(hierarchy, getDescription());
71 objectMapComponent ==
nullptr,
72 "CommunicateInitInfo called for %s with no ObjectMapComponent object.\n",
78 if (parent->getCommunicator()->globalCommRank() == 0) {
80 "%s: preLayerName \"%s\" does not correspond to a layer in the column.\n",
89 if (parent->getCommunicator()->globalCommRank() == 0) {
91 "%s: postLayerName \"%s\" does not correspond to a layer in the column.\n",
97 MPI_Barrier(parent->getCommunicator()->globalCommunicator());
102 return Response::SUCCESS;
108 std::string &preLayerNameString,
109 std::string &postLayerNameString) {
111 preLayerNameString.clear();
112 postLayerNameString.clear();
113 std::string nameString(name);
114 auto locto = nameString.find(
"To");
115 if (locto == std::string::npos) {
117 ErrorLog(errorMessage);
118 errorMessage.printf(
"Unable to infer pre and post from connection name \"%s\".\n", name);
120 "The connection name must have the form \"AbcToXyz\", to infer the names,\n");
121 errorMessage.printf(
"but the string \"To\" does not appear.\n");
125 auto secondto = nameString.find(
"To", locto + 1);
126 if (secondto != std::string::npos) {
128 ErrorLog(errorMessage);
129 errorMessage.printf(
"Unable to infer pre and post from connection name \"%s\":\n", name);
130 errorMessage.printf(
"The string \"To\" cannot appear in the name more than once.\n");
133 preLayerNameString.append(nameString.substr(0, locto));
134 postLayerNameString.append(nameString.substr(locto + 2, std::string::npos));
char const * getPostLayerName() const
virtual void ioParam_preLayerName(enum ParamsIOFlag ioFlag)
preLayerName: Specifies the connection's pre layer
virtual void ioParam_postLayerName(enum ParamsIOFlag ioFlag)
preLayerName: Specifies the connection's post layer
char const * getPreLayerName() const
static void inferPreAndPostFromConnName(const char *name, int rank, std::string &preLayerNameString, std::string &postLayerNameString)
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override