Skip to content

Commit

Permalink
Removed retrieve AC functions. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent ad82428 commit 5751320
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 211 deletions.
6 changes: 3 additions & 3 deletions src/netedit/GNENet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ GNENet::deleteNetworkElement(GNENetworkElement* networkElement, GNEUndoList* und
}
} else if (networkElement->getTagProperty().getTag() == SUMO_TAG_CROSSING) {
// get crossing (note: could be already removed if is a child, then hardfail=false)
GNECrossing* crossing = myAttributeCarriers->retrieveCrossing(networkElement, false);
GNECrossing* crossing = myAttributeCarriers->retrieveCrossingGL(networkElement->getGUIGlObject(), false);
// if exist, remove it
if (crossing) {
deleteCrossing(crossing, undoList);
Expand All @@ -346,14 +346,14 @@ GNENet::deleteNetworkElement(GNENetworkElement* networkElement, GNEUndoList* und
}
} else if (networkElement->getTagProperty().getTag() == SUMO_TAG_LANE) {
// get lane (note: could be already removed if is a child, then hardfail=false)
GNELane* lane = myAttributeCarriers->retrieveLane(networkElement, false);
GNELane* lane = myAttributeCarriers->retrieveLaneGL(networkElement->getGUIGlObject(), false);
// if exist, remove it
if (lane) {
deleteLane(lane, undoList, false);
}
} else if (networkElement->getTagProperty().getTag() == SUMO_TAG_CONNECTION) {
// get connection (note: could be already removed if is a child, then hardfail=false)
GNEConnection* connection = myAttributeCarriers->retrieveConnection(networkElement, false);
GNEConnection* connection = myAttributeCarriers->retrieveConnectionGL(networkElement->getGUIGlObject(), false);
// if exist, remove it
if (connection) {
deleteConnection(connection, undoList);
Expand Down
130 changes: 1 addition & 129 deletions src/netedit/GNENetHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ GNENetHelper::AttributeCarriers::isNetworkElementAroundShape(GNEAttributeCarrier
return shape.overlapsWith(dynamic_cast<GNECrossing*>(AC)->getCrossingShape());
} else if (AC->getTagProperty().isAdditionalElement()) {
// Additional (including shapes and TAZs
const GNEAdditional* additional = retrieveAdditional(AC);
const GNEAdditional* additional = retrieveAdditionalGL(AC->getGUIGlObject());
if (additional->getAdditionalGeometry().getShape().size() <= 1) {
return shape.around(additional->getPositionInView());
} else {
Expand Down Expand Up @@ -523,24 +523,6 @@ GNENetHelper::AttributeCarriers::getNumberOfSelectedJunctions() const {
}


GNECrossing*
GNENetHelper::AttributeCarriers::retrieveCrossing(GNEAttributeCarrier* AC, bool hardFail) const {
// cast crossing
GNECrossing* crossing = dynamic_cast<GNECrossing*>(AC);
if (crossing && (myCrossings.count(crossing) > 0)) {
return crossing;
} else if (hardFail) {
if (AC) {
throw UnknownElement("Crossing " + AC->getID());
} else {
throw UnknownElement("Crossing");
}
} else {
return nullptr;
}
}


GNECrossing*
GNENetHelper::AttributeCarriers::retrieveCrossingGL(const GUIGlObject* glObject, bool hardFail) const {
if (myCrossings.count(glObject)) {
Expand Down Expand Up @@ -606,24 +588,6 @@ GNENetHelper::AttributeCarriers::getNumberOfSelectedCrossings() const {
}


GNEWalkingArea*
GNENetHelper::AttributeCarriers::retrieveWalkingArea(GNEAttributeCarrier* AC, bool hardFail) const {
// cast walkingArea
GNEWalkingArea* walkingArea = dynamic_cast<GNEWalkingArea*>(AC);
if (walkingArea && (myWalkingAreas.count(walkingArea) > 0)) {
return walkingArea;
} else if (hardFail) {
if (AC) {
throw UnknownElement("WalkingArea " + AC->getID());
} else {
throw UnknownElement("WalkingArea");
}
} else {
return nullptr;
}
}


GNEWalkingArea*
GNENetHelper::AttributeCarriers::retrieveWalkingAreaGL(const GUIGlObject* glObject, bool hardFail) const {
if (myWalkingAreas.count(glObject)) {
Expand Down Expand Up @@ -932,24 +896,6 @@ GNENetHelper::AttributeCarriers::retrieveLane(const std::string& id, bool hardFa
}


GNELane*
GNENetHelper::AttributeCarriers::retrieveLane(GNEAttributeCarrier* AC, bool hardFail) const {
// cast lane
GNELane* lane = dynamic_cast<GNELane*>(AC);
if (lane && (myLanes.count(lane) > 0)) {
return lane;
} else if (hardFail) {
if (AC) {
throw UnknownElement("Lane " + AC->getID());
} else {
throw UnknownElement("Lane");
}
} else {
return nullptr;
}
}


GNELane*
GNENetHelper::AttributeCarriers::retrieveLaneGL(const GUIGlObject* glObject, bool hardFail) const {
if (myLanes.count(glObject)) {
Expand Down Expand Up @@ -1049,24 +995,6 @@ GNENetHelper::AttributeCarriers::retrieveConnectionGL(const GUIGlObject* glObjec
}


GNEConnection*
GNENetHelper::AttributeCarriers::retrieveConnection(GNEAttributeCarrier* AC, bool hardFail) const {
// cast connection
GNEConnection* connection = dynamic_cast<GNEConnection*>(AC);
if (connection && (myConnections.count(connection) > 0)) {
return connection;
} else if (hardFail) {
if (AC) {
throw UnknownElement("Connection " + AC->getID());
} else {
throw UnknownElement("Connection");
}
} else {
return nullptr;
}
}


const std::map<const GUIGlObject*, GNEConnection*>&
GNENetHelper::AttributeCarriers::getConnections() const {
return myConnections;
Expand Down Expand Up @@ -1151,20 +1079,6 @@ GNENetHelper::AttributeCarriers::retrieveAdditionals(const std::vector<SumoXMLTa
}


GNEAdditional*
GNENetHelper::AttributeCarriers::retrieveAdditional(GNEAttributeCarrier* AC, bool hardFail) const {
// cast additional
GNEAdditional* additional = dynamic_cast<GNEAdditional*>(AC);
if (additional && (myAdditionals.at(AC->getTagProperty().getTag()).count(additional) > 0)) {
return additional;
} else if (hardFail) {
throw ProcessError("Attempted to retrieve non-existant additional (AttributeCarrier)");
} else {
return nullptr;
}
}


GNEAdditional*
GNENetHelper::AttributeCarriers::retrieveAdditionalGL(const GUIGlObject* glObject, bool hardFail) const {
// iterate over all additionals
Expand Down Expand Up @@ -1514,20 +1428,6 @@ GNENetHelper::AttributeCarriers::retrieveDemandElements(std::vector<SumoXMLTag>
}


GNEDemandElement*
GNENetHelper::AttributeCarriers::retrieveDemandElement(GNEAttributeCarrier* AC, bool hardFail) const {
// cast demandElement
GNEDemandElement* demandElement = dynamic_cast<GNEDemandElement*>(AC);
if (demandElement && (myDemandElements.at(AC->getTagProperty().getTag()).count(demandElement) > 0)) {
return demandElement;
} else if (hardFail) {
throw ProcessError("Attempted to retrieve non-existant demand element (AttributeCarrier)");
} else {
return nullptr;
}
}


GNEDemandElement*
GNENetHelper::AttributeCarriers::retrieveDemandElementGL(const GUIGlObject* glObject, bool hardFail) const {
// iterate over all demand elements
Expand Down Expand Up @@ -2029,20 +1929,6 @@ GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool har
}


GNEDataSet*
GNENetHelper::AttributeCarriers::retrieveDataSet(GNEAttributeCarrier* AC, bool hardFail) const {
// cast dataSet
GNEDataSet* dataSet = dynamic_cast<GNEDataSet*>(AC);
if (dataSet && (myDataSets.count(dataSet) > 0)) {
return dataSet;
} else if (hardFail) {
throw ProcessError("Attempted to retrieve non-existant data set");
} else {
return nullptr;
}
}


const std::set<GNEDataSet*>&
GNENetHelper::AttributeCarriers::getDataSets() const {
return myDataSets;
Expand Down Expand Up @@ -2343,20 +2229,6 @@ GNENetHelper::AttributeCarriers::retrieveMeanData(SumoXMLTag type, const std::st
}


GNEMeanData*
GNENetHelper::AttributeCarriers::retrieveMeanData(GNEAttributeCarrier* AC, bool hardFail) const {
// cast meanData
GNEMeanData* meanData = dynamic_cast<GNEMeanData*>(AC);
if (meanData && (myMeanDatas.at(AC->getTagProperty().getTag()).count(meanData) > 0)) {
return meanData;
} else if (hardFail) {
throw ProcessError("Attempted to retrieve non-existant meanData (AttributeCarrier)");
} else {
return nullptr;
}
}


const std::map<SumoXMLTag, std::set<GNEMeanData*> >&
GNENetHelper::AttributeCarriers::getMeanDatas() const {
return myMeanDatas;
Expand Down
53 changes: 0 additions & 53 deletions src/netedit/GNENetHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,6 @@ struct GNENetHelper {

/// @name function for crossings
/// @{
/**@brief get Crossing by AC
* @param[in] AC The attribute carrier related with the crossing
* @param[in] hardFail Whether attempts to retrieve a nonexisting Crossing should result in an exception
* @throws UnknownElement
*/
GNECrossing* retrieveCrossing(GNEAttributeCarrier* AC, bool hardFail = true) const;

/**@brief get Crossing by AC
* @param[in] glObject The GUIGlObject related with the crossing
* @param[in] hardFail Whether attempts to retrieve a nonexisting Crossing should result in an exception
Expand All @@ -197,13 +190,6 @@ struct GNENetHelper {

/// @name function for walkingAreas
/// @{
/**@brief get WalkingArea by AC
* @param[in] AC The attribute carrier related with the walkingArea
* @param[in] hardFail Whether attempts to retrieve a nonexisting WalkingArea should result in an exception
* @throws UnknownElement
*/
GNEWalkingArea* retrieveWalkingArea(GNEAttributeCarrier* AC, bool hardFail = true) const;

/**@brief get WalkingArea by GlObject
* @param[in] glObject The GUIGlObject related with the walkingArea
* @param[in] hardFail Whether attempts to retrieve a nonexisting WalkingArea should result in an exception
Expand Down Expand Up @@ -319,13 +305,6 @@ struct GNENetHelper {
*/
GNELane* retrieveLaneGL(const GUIGlObject* glObject, bool hardFail = true) const;

/**@brief get lane by Attribute Carrier
* @param[in] AC The attribute carrier related with the lane
* @param[in] hardFail Whether attempts to retrieve a nonexisting lane should result in an exception
* @throws UnknownElement
*/
GNELane* retrieveLane(GNEAttributeCarrier* AC, bool hardFail = true) const;

/// @brief get lanes
const std::map<const GUIGlObject*, GNELane*>& getLanes() const;

Expand Down Expand Up @@ -359,13 +338,6 @@ struct GNENetHelper {
*/
GNEConnection* retrieveConnectionGL(const GUIGlObject* glObject, bool hardFail = true) const;

/**@brief get connection by Attribute Carrier
* @param[in] AC The attribute carrier related with the connection
* @param[in] hardFail Whether attempts to retrieve a nonexisting connection should result in an exception
* @throws UnknownElement
*/
GNEConnection* retrieveConnection(GNEAttributeCarrier* AC, bool hardFail = true) const;

/// @brief get connections
const std::map<const GUIGlObject*, GNEConnection*>& getConnections() const;

Expand Down Expand Up @@ -401,12 +373,6 @@ struct GNENetHelper {
*/
GNEAdditional* retrieveAdditionals(const std::vector<SumoXMLTag> types, const std::string& id, bool hardFail = true) const;

/**@brief Returns the named additional
* @param[in] id The attribute carrier related with the additional element
* @param[in] hardFail Whether attempts to retrieve a nonexisting additional should result in an exception
*/
GNEAdditional* retrieveAdditional(GNEAttributeCarrier* AC, bool hardFail = true) const;

/**@brief Returns the named additional
* @param[in] glObject The GLObject related with the additional element
* @param[in] hardFail Whether attempts to retrieve a nonexisting additional should result in an exception
Expand Down Expand Up @@ -486,12 +452,6 @@ struct GNENetHelper {
*/
GNEDemandElement* retrieveDemandElements(const std::vector<SumoXMLTag> types, const std::string& id, bool hardFail = true) const;

/**@brief Returns the named demand element
* @param[in] id The attribute carrier related with the demand element
* @param[in] hardFail Whether attempts to retrieve a nonexisting demand element should result in an exception
*/
GNEDemandElement* retrieveDemandElement(GNEAttributeCarrier* AC, bool hardFail = true) const;

/**@brief Returns the named demand
* @param[in] id The GLObject related with the demand element
* @param[in] hardFail Whether attempts to retrieve a nonexisting demand should result in an exception
Expand Down Expand Up @@ -559,19 +519,12 @@ struct GNENetHelper {

/// @name function for data sets
/// @{

/**@brief Returns the named data set
* @param[in] id The id of the data set to return.
* @param[in] hardFail Whether attempts to retrieve a nonexisting data set should result in an exception
*/
GNEDataSet* retrieveDataSet(const std::string& id, bool hardFail = true) const;

/**@brief Returns the named data set
* @param[in] id The attribute carrier related with the dataSet element
* @param[in] hardFail Whether attempts to retrieve a nonexisting data set should result in an exception
*/
GNEDataSet* retrieveDataSet(GNEAttributeCarrier* AC, bool hardFail = true) const;

/// @brief get demand elements
const std::set<GNEDataSet*>& getDataSets() const;

Expand Down Expand Up @@ -653,12 +606,6 @@ struct GNENetHelper {
*/
GNEMeanData* retrieveMeanData(SumoXMLTag type, const std::string& id, bool hardFail = true) const;

/**@brief Returns the named meanData
* @param[in] id The attribute carrier related with the meanData element
* @param[in] hardFail Whether attempts to retrieve a nonexisting meanData should result in an exception
*/
GNEMeanData* retrieveMeanData(GNEAttributeCarrier* AC, bool hardFail = true) const;

/// @brief get meanDatas
const std::map<SumoXMLTag, std::set<GNEMeanData*> >& getMeanDatas() const;

Expand Down
12 changes: 6 additions & 6 deletions src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5136,7 +5136,7 @@ GNEViewNet::deleteNetworkAttributeCarriers(const std::vector<GNEAttributeCarrier
}
} else if (AC->getTagProperty().getTag() == SUMO_TAG_CROSSING) {
// get crossing (note: could be already removed if is a child, then hardfail=false)
GNECrossing* crossing = myNet->getAttributeCarriers()->retrieveCrossing(AC, false);
GNECrossing* crossing = myNet->getAttributeCarriers()->retrieveCrossingGL(AC->getGUIGlObject(), false);
// if exist, remove it
if (crossing) {
myNet->deleteCrossing(crossing, myUndoList);
Expand All @@ -5150,21 +5150,21 @@ GNEViewNet::deleteNetworkAttributeCarriers(const std::vector<GNEAttributeCarrier
}
} else if (AC->getTagProperty().getTag() == SUMO_TAG_LANE) {
// get lane (note: could be already removed if is a child, then hardfail=false)
GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(AC, false);
GNELane* lane = myNet->getAttributeCarriers()->retrieveLaneGL(AC->getGUIGlObject(), false);
// if exist, remove it
if (lane) {
myNet->deleteLane(lane, myUndoList, false);
}
} else if (AC->getTagProperty().getTag() == SUMO_TAG_CONNECTION) {
// get connection (note: could be already removed if is a child, then hardfail=false)
GNEConnection* connection = myNet->getAttributeCarriers()->retrieveConnection(AC, false);
GNEConnection* connection = myNet->getAttributeCarriers()->retrieveConnectionGL(AC->getGUIGlObject(), false);
// if exist, remove it
if (connection) {
myNet->deleteConnection(connection, myUndoList);
}
} else if (AC->getTagProperty().isAdditionalElement()) {
// get additional Element (note: could be already removed if is a child, then hardfail=false)
GNEAdditional* additionalElement = myNet->getAttributeCarriers()->retrieveAdditional(AC, false);
GNEAdditional* additionalElement = myNet->getAttributeCarriers()->retrieveAdditionalGL(AC->getGUIGlObject(), false);
// if exist, remove it
if (additionalElement) {
myNet->deleteAdditional(additionalElement, myUndoList);
Expand All @@ -5179,7 +5179,7 @@ GNEViewNet::deleteDemandAttributeCarriers(const std::vector<GNEAttributeCarrier*
// iterate over ACs and delete it
for (const auto& AC : ACs) {
// get demand Element (note: could be already removed if is a child, then hardfail=false)
GNEDemandElement* demandElement = myNet->getAttributeCarriers()->retrieveDemandElement(AC, false);
GNEDemandElement* demandElement = myNet->getAttributeCarriers()->retrieveDemandElementGL(AC->getGUIGlObject(), false);
// if exist, remove it
if (demandElement) {
myNet->deleteDemandElement(demandElement, myUndoList);
Expand All @@ -5194,7 +5194,7 @@ GNEViewNet::deleteDataAttributeCarriers(const std::vector<GNEAttributeCarrier*>
for (const auto& AC : ACs) {
if (AC->getTagProperty().getTag() == SUMO_TAG_DATASET) {
// get data set (note: could be already removed if is a child, then hardfail=false)
GNEDataSet* dataSet = myNet->getAttributeCarriers()->retrieveDataSet(AC, false);
GNEDataSet* dataSet = myNet->getAttributeCarriers()->retrieveDataSet(AC->getID(), false);
// if exist, remove it
if (dataSet) {
myNet->deleteDataSet(dataSet, myUndoList);
Expand Down

0 comments on commit 5751320

Please sign in to comment.