Skip to content

Commit

Permalink
make some pointer constants. Refs #15834
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Feb 5, 2025
1 parent 89b9f34 commit 67058e7
Show file tree
Hide file tree
Showing 26 changed files with 79 additions and 76 deletions.
4 changes: 2 additions & 2 deletions src/netedit/GNEApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ FXIMPLEMENT(GNEApplicationWindow, FXMainWindow, GNEApplicationWindowMap, ARRAYNU
// GNEApplicationWindow method definitions
// ===========================================================================

GNEApplicationWindow::GNEApplicationWindow(FXApp* app, GNETagPropertiesDatabase* tagPropertiesDatabase, const std::string& configPattern) :
GNEApplicationWindow::GNEApplicationWindow(FXApp* app, const GNETagPropertiesDatabase* tagPropertiesDatabase, const std::string& configPattern) :
GUIMainWindow(app),
myTagPropertiesDatabase(tagPropertiesDatabase),
myUndoList(new GNEUndoList(this)),
Expand Down Expand Up @@ -1505,7 +1505,7 @@ GNEApplicationWindow::getTrackerInterval() const {
}


GNETagPropertiesDatabase*
const GNETagPropertiesDatabase*
GNEApplicationWindow::getTagPropertiesDatabase() const {
return myTagPropertiesDatabase;
}
Expand Down
6 changes: 3 additions & 3 deletions src/netedit/GNEApplicationWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GNEApplicationWindow : public GUIMainWindow, public MFXInterThreadEventCli
* @param[in] tagPropertiesDatabase pointer to tag properties database
* @param[in] configPattern The pattern used for loading configurations
*/
GNEApplicationWindow(FXApp* app, GNETagPropertiesDatabase* tagPropertiesDatabase, const std::string& configPattern);
GNEApplicationWindow(FXApp* app, const GNETagPropertiesDatabase* tagPropertiesDatabase, const std::string& configPattern);

/// @brief Destructor
~GNEApplicationWindow();
Expand Down Expand Up @@ -549,7 +549,7 @@ class GNEApplicationWindow : public GUIMainWindow, public MFXInterThreadEventCli
FXCursor* getDefaultCursor();

/// @brief get tag properties database
GNETagPropertiesDatabase* getTagPropertiesDatabase() const;
const GNETagPropertiesDatabase* getTagPropertiesDatabase() const;

/// @brief get pointer to undoList
GNEUndoList* getUndoList();
Expand Down Expand Up @@ -702,7 +702,7 @@ class GNEApplicationWindow : public GUIMainWindow, public MFXInterThreadEventCli
bool myHadDependentBuild = false;

/// @brief tagProperties database
GNETagPropertiesDatabase* myTagPropertiesDatabase = nullptr;
const GNETagPropertiesDatabase* myTagPropertiesDatabase = nullptr;

/// @brief we are responsible for the net
GNENet* myNet = nullptr;
Expand Down
31 changes: 19 additions & 12 deletions src/netedit/GNENet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ const std::map<SumoXMLAttr, std::string> GNENet::EMPTY_HEADER;
// member method definitions
// ===========================================================================

GNENet::GNENet(NBNetBuilder* netBuilder, GNETagPropertiesDatabase* tagPropertiesDatabase) :
GNENet::GNENet(NBNetBuilder* netBuilder, const GNETagPropertiesDatabase* tagPropertiesDatabase) :
GUIGlObject(GLO_NETWORK, "", nullptr),
myNetBuilder(netBuilder),
myAttributeCarriers(new GNENetHelper::AttributeCarriers(this, tagPropertiesDatabase)),
myTagPropertiesDatabase(tagPropertiesDatabase),
myAttributeCarriers(new GNENetHelper::AttributeCarriers(this)),
mySavingStatus(new GNENetHelper::SavingStatus(this)),
myNetworkPathManager(new GNEPathManager(this)),
myDemandPathManager(new GNEPathManager(this)),
Expand Down Expand Up @@ -121,6 +122,12 @@ GNENet::~GNENet() {
}


const GNETagPropertiesDatabase*
GNENet::getTagPropertiesDatabase() const {
return myTagPropertiesDatabase;
}


GNENetHelper::AttributeCarriers*
GNENet::getAttributeCarriers() const {
return myAttributeCarriers;
Expand Down Expand Up @@ -2633,7 +2640,7 @@ GNENet::writeRouteProbeComment(OutputDevice& device) const {
bool
GNENet::writeCalibratorComment(OutputDevice& device) const {
for (const auto& additionals : myAttributeCarriers->getAdditionals()) {
if (myViewNet->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isCalibrator() && (additionals.second.size() > 0)) {
if (myViewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isCalibrator() && (additionals.second.size() > 0)) {
device << (" <!-- Calibrators -->\n");
return true;
}
Expand All @@ -2645,7 +2652,7 @@ GNENet::writeCalibratorComment(OutputDevice& device) const {
bool
GNENet::writeStoppingPlaceComment(OutputDevice& device) const {
for (const auto& additionals : myAttributeCarriers->getAdditionals()) {
if (myViewNet->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isStoppingPlace() && (additionals.second.size() > 0)) {
if (myViewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isStoppingPlace() && (additionals.second.size() > 0)) {
device << (" <!-- StoppingPlaces -->\n");
return true;
}
Expand All @@ -2657,7 +2664,7 @@ GNENet::writeStoppingPlaceComment(OutputDevice& device) const {
bool
GNENet::writeDetectorComment(OutputDevice& device) const {
for (const auto& additionals : myAttributeCarriers->getAdditionals()) {
if (myViewNet->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isDetector() && (additionals.second.size() > 0)) {
if (myViewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isDetector() && (additionals.second.size() > 0)) {
device << (" <!-- Detectors -->\n");
return true;
}
Expand All @@ -2669,10 +2676,10 @@ GNENet::writeDetectorComment(OutputDevice& device) const {
bool
GNENet::writeOtherAdditionalsComment(OutputDevice& device) const {
for (const auto& additionals : myAttributeCarriers->getAdditionals()) {
if (myViewNet->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isAdditionalPureElement() &&
!myViewNet->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isStoppingPlace() &&
!myViewNet->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isDetector() &&
!myViewNet->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isCalibrator() &&
if (myViewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isAdditionalPureElement() &&
!myViewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isStoppingPlace() &&
!myViewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isDetector() &&
!myViewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isCalibrator() &&
(additionals.first != SUMO_TAG_ROUTEPROBE) && (additionals.first != SUMO_TAG_ACCESS) &&
(additionals.first != SUMO_TAG_PARKING_SPACE) && (additionals.second.size() > 0)) {
device << (" <!-- Other additionals -->\n");
Expand All @@ -2686,8 +2693,8 @@ GNENet::writeOtherAdditionalsComment(OutputDevice& device) const {
bool
GNENet::writeShapesComment(OutputDevice& device) const {
for (const auto& additionals : myAttributeCarriers->getAdditionals()) {
if (myViewNet->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isShapeElement() &&
!myViewNet->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isJuPedSimElement() &&
if (myViewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isShapeElement() &&
!myViewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isJuPedSimElement() &&
(additionals.second.size() > 0)) {
device << (" <!-- Shapes -->\n");
return true;
Expand All @@ -2700,7 +2707,7 @@ GNENet::writeShapesComment(OutputDevice& device) const {
bool
GNENet::writeJuPedSimComment(OutputDevice& device) const {
for (const auto& additionals : myAttributeCarriers->getAdditionals()) {
if (myViewNet->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isJuPedSimElement() && (additionals.second.size() > 0)) {
if (myViewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionals.first)->isJuPedSimElement() && (additionals.second.size() > 0)) {
device << (" <!-- JuPedSim elements -->\n");
return true;
}
Expand Down
8 changes: 7 additions & 1 deletion src/netedit/GNENet.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ class GNENet : public GUIGlObject {

public:
/// @brief constructor
GNENet(NBNetBuilder* netBuilder, GNETagPropertiesDatabase* tagPropertiesDatabase);
GNENet(NBNetBuilder* netBuilder, const GNETagPropertiesDatabase* tagPropertiesDatabase);

/// @brief Destructor
~GNENet();

/// @brief get tag properties database
const GNETagPropertiesDatabase* getTagPropertiesDatabase() const;

/// @brief get all attribute carriers used in this net
GNENetHelper::AttributeCarriers* getAttributeCarriers() const;

Expand Down Expand Up @@ -501,6 +504,9 @@ class GNENet : public GUIGlObject {
/// @brief The net to be notified of about changes
GNEViewNet* myViewNet = nullptr;

/// @brief pointer to tagProperties database
const GNETagPropertiesDatabase* myTagPropertiesDatabase = nullptr;

/// @brief AttributeCarriers of net
GNENetHelper::AttributeCarriers* myAttributeCarriers = nullptr;

Expand Down
24 changes: 12 additions & 12 deletions src/netedit/GNENetHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@
// GNENetHelper::AttributeCarriers - methods
// ---------------------------------------------------------------------------

GNENetHelper::AttributeCarriers::AttributeCarriers(GNENet* net, GNETagPropertiesDatabase* tagPropertiesDatabase) :
GNENetHelper::AttributeCarriers::AttributeCarriers(GNENet* net) :
myNet(net),
myStopIndex(0) {
// fill additionals with tags
auto additionalTagProperties = tagPropertiesDatabase->getTagPropertiesByType(GNETagProperties::TagType::ADDITIONALELEMENT |
auto additionalTagProperties = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::TagType::ADDITIONALELEMENT |
GNETagProperties::TagType::SHAPE | GNETagProperties::TagType::TAZELEMENT | GNETagProperties::TagType::WIRE, false);
for (const auto& additionalTagProperty : additionalTagProperties) {
myAdditionals.insert(std::make_pair(additionalTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEAdditional*>()));
Expand All @@ -68,24 +68,24 @@ GNENetHelper::AttributeCarriers::AttributeCarriers(GNENet* net, GNETagProperties
}
}
// fill demand elements with tags
auto demandElementTagProperties = tagPropertiesDatabase->getTagPropertiesByType(GNETagProperties::TagType::DEMANDELEMENT, false);
auto demandElementTagProperties = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::TagType::DEMANDELEMENT, false);
for (const auto& demandElementTagProperty : demandElementTagProperties) {
myDemandElements.insert(std::make_pair(demandElementTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEDemandElement*>()));
if (demandElementTagProperty->hasAttribute(SUMO_ATTR_ID)) {
myDemandElementIDs.insert(std::make_pair(demandElementTagProperty->getTag(), std::map<const std::string, GNEDemandElement*>()));
}
}
auto stopTagProperties = tagPropertiesDatabase->getTagPropertiesByType(GNETagProperties::TagType::VEHICLESTOP, false);
auto stopTagProperties = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::TagType::VEHICLESTOP, false);
for (const auto& stopTagProperty : stopTagProperties) {
myDemandElements.insert(std::make_pair(stopTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEDemandElement*>()));
}
// fill data elements with tags
auto genericDataElementTagProperties = tagPropertiesDatabase->getTagPropertiesByType(GNETagProperties::TagType::GENERICDATA, false);
auto genericDataElementTagProperties = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::TagType::GENERICDATA, false);
for (const auto& genericDataElementTagProperty : genericDataElementTagProperties) {
myGenericDatas.insert(std::make_pair(genericDataElementTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEGenericData*>()));
}
// fill meanDatas with tags
auto meanDataTagProperties = tagPropertiesDatabase->getTagPropertiesByType(GNETagProperties::TagType::MEANDATA, false);
auto meanDataTagProperties = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::TagType::MEANDATA, false);
for (const auto& meanDataTagProperty : meanDataTagProperties) {
myMeanDatas.insert(std::make_pair(meanDataTagProperty->getTag(), std::map<const std::string, GNEMeanData*>()));
}
Expand Down Expand Up @@ -269,12 +269,12 @@ GNENetHelper::AttributeCarriers::retrieveAttributeCarriers(SumoXMLTag tag) {
for (const auto& walkingArea : myWalkingAreas) {
result.push_back(walkingArea.second);
}
} else if ((tag == SUMO_TAG_NOTHING) || (myNet->getViewNet()->getTagPropertiesDatabase()->getTagProperty(tag)->isAdditionalElement())) {
} else if ((tag == SUMO_TAG_NOTHING) || (myNet->getTagPropertiesDatabase()->getTagProperty(tag)->isAdditionalElement())) {
for (const auto& additional : myAdditionals.at(tag)) {
result.push_back(additional.second);
}
} else if ((tag == SUMO_TAG_NOTHING) || (myNet->getViewNet()->getTagPropertiesDatabase()->getTagProperty(tag)->isDemandElement())) {
auto mergingPlans = myNet->getViewNet()->getTagPropertiesDatabase()->getTagPropertiesByMergingTag(tag);
} else if ((tag == SUMO_TAG_NOTHING) || (myNet->getTagPropertiesDatabase()->getTagProperty(tag)->isDemandElement())) {
auto mergingPlans = myNet->getTagPropertiesDatabase()->getTagPropertiesByMergingTag(tag);
if (mergingPlans.size() > 0) {
for (const auto& mergingPlan : mergingPlans) {
for (const auto& demandElemet : myDemandElements.at(mergingPlan->getTag())) {
Expand All @@ -294,11 +294,11 @@ GNENetHelper::AttributeCarriers::retrieveAttributeCarriers(SumoXMLTag tag) {
for (const auto& dataInterval : myDataIntervals) {
result.push_back(dataInterval.second);
}
} else if ((tag == SUMO_TAG_NOTHING) || (myNet->getViewNet()->getTagPropertiesDatabase()->getTagProperty(tag)->isGenericData())) {
} else if ((tag == SUMO_TAG_NOTHING) || (myNet->getTagPropertiesDatabase()->getTagProperty(tag)->isGenericData())) {
for (const auto& genericData : myGenericDatas.at(tag)) {
result.push_back(genericData.second);
}
} else if ((tag == SUMO_TAG_NOTHING) || (myNet->getViewNet()->getTagPropertiesDatabase()->getTagProperty(tag)->isMeanData())) {
} else if ((tag == SUMO_TAG_NOTHING) || (myNet->getTagPropertiesDatabase()->getTagProperty(tag)->isMeanData())) {
for (const auto& meanData : myMeanDatas.at(tag)) {
result.push_back(meanData.second);
}
Expand Down Expand Up @@ -1411,7 +1411,7 @@ GNENetHelper::AttributeCarriers::generateDemandElementID(SumoXMLTag tag) const {
// obtain option container
const auto& neteditOptions = OptionsCont::getOptions();
// get tag property
const auto tagProperty = myNet->getViewNet()->getTagPropertiesDatabase()->getTagProperty(tag);
const auto tagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(tag);
// get prefix
std::string prefix;
if (tag == SUMO_TAG_ROUTE) {
Expand Down
3 changes: 1 addition & 2 deletions src/netedit/GNENetHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class GNENet;
class GNENetworkElement;
class GNEPOI;
class GNEPoly;
class GNETagPropertiesDatabase;
class GNEUndoList;
class GNEViewNet;
class GNEWalkingArea;
Expand Down Expand Up @@ -102,7 +101,7 @@ struct GNENetHelper {

public:
/// @brief constructor
AttributeCarriers(GNENet* net, GNETagPropertiesDatabase* tagPropertiesDatabase);
AttributeCarriers(GNENet* net);

/// @brief destructor
~AttributeCarriers();
Expand Down
8 changes: 4 additions & 4 deletions src/netedit/GNETagPropertiesDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ GNETagPropertiesDatabase::~GNETagPropertiesDatabase() {


GNETagProperties*
GNETagPropertiesDatabase::getTagProperty(SumoXMLTag tag) {
GNETagPropertiesDatabase::getTagProperty(SumoXMLTag tag) const {
// check that tag is defined
if (myTagProperties.count(tag) == 0) {
if (myMergedPlanTagProperties.count(tag) == 0) {
Expand All @@ -92,7 +92,7 @@ GNETagPropertiesDatabase::getTagProperty(SumoXMLTag tag) {


const std::vector<const GNETagProperties*>
GNETagPropertiesDatabase::getTagPropertiesByType(const int tagPropertyCategory, const bool mergeCommonPlans) {
GNETagPropertiesDatabase::getTagPropertiesByType(const int tagPropertyCategory, const bool mergeCommonPlans) const {
std::vector<const GNETagProperties*> allowedTags;
if (tagPropertyCategory & GNETagProperties::TagType::NETWORKELEMENT) {
// fill networkElements tags
Expand Down Expand Up @@ -310,7 +310,7 @@ GNETagPropertiesDatabase::getTagPropertiesByType(const int tagPropertyCategory,


const std::vector<const GNETagProperties*>
GNETagPropertiesDatabase::getTagPropertiesByMergingTag(SumoXMLTag mergingTag) {
GNETagPropertiesDatabase::getTagPropertiesByMergingTag(SumoXMLTag mergingTag) const {
std::vector<const GNETagProperties*> result;
// fill tags
for (const auto& tagProperty : myTagProperties) {
Expand Down Expand Up @@ -359,7 +359,7 @@ GNETagPropertiesDatabase::getMaxNumberOfNeteditAttributes() const {


void
GNETagPropertiesDatabase::writeAttributeHelp() {
GNETagPropertiesDatabase::writeAttributeHelp() const {
// merge "virtual" netedit tags like '<walk: edge->edge'
static std::map<SumoXMLTag, GNETagProperties*> mergedAttributeProperties;
for (const auto& tagPropertyItem : myTagProperties) {
Expand Down
8 changes: 4 additions & 4 deletions src/netedit/GNETagPropertiesDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class GNETagPropertiesDatabase {
~GNETagPropertiesDatabase();

/// @brief get tagProperty associated to the given tag
GNETagProperties* getTagProperty(SumoXMLTag tag);
GNETagProperties* getTagProperty(SumoXMLTag tag) const;

/// @brief get tagProperties associated to the given GNETagProperties::TagType (NETWORKELEMENT, ADDITIONALELEMENT, VEHICLE, etc.)
const std::vector<const GNETagProperties*> getTagPropertiesByType(const int tagPropertyCategory, const bool mergeCommonPlans);
const std::vector<const GNETagProperties*> getTagPropertiesByType(const int tagPropertyCategory, const bool mergeCommonPlans) const;

/// @brief get tagProperties associated to the given merging tag
const std::vector<const GNETagProperties*> getTagPropertiesByMergingTag(SumoXMLTag mergingTag);
const std::vector<const GNETagProperties*> getTagPropertiesByMergingTag(SumoXMLTag mergingTag) const;

/// @brief max number of editable (non extended) attributes
int getMaxNumberOfEditableAttributes() const;
Expand All @@ -66,7 +66,7 @@ class GNETagPropertiesDatabase {
int getMaxNumberOfNeteditAttributes() const;

/// @brief write machine readable attribute help to file
void writeAttributeHelp();
void writeAttributeHelp() const;

protected:
/// @brief fill network elements
Expand Down
6 changes: 0 additions & 6 deletions src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1849,12 +1849,6 @@ GNEViewNet::getNet() const {
}


GNETagPropertiesDatabase*
GNEViewNet::getTagPropertiesDatabase() const {
return myViewParent->getGNEAppWindows()->getTagPropertiesDatabase();
}


GNEUndoList*
GNEViewNet::getUndoList() const {
return myUndoList;
Expand Down
3 changes: 0 additions & 3 deletions src/netedit/GNEViewNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,6 @@ class GNEViewNet : public GUISUMOAbstractView {
/// @brief get the net object
GNENet* getNet() const;

/// @brief get tag properties database (Shortcut)
GNETagPropertiesDatabase* getTagPropertiesDatabase() const;

/// @brief get the undoList object
GNEUndoList* getUndoList() const;

Expand Down
2 changes: 1 addition & 1 deletion src/netedit/GNEViewParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
chooserLoc = &myACChoosers.ACChooserAdditional;
locateTitle = TL("Additional Chooser");
for (const auto& additionalTag : viewNet->getNet()->getAttributeCarriers()->getAdditionals()) {
const auto tagProperty = viewNet->getTagPropertiesDatabase()->getTagProperty(additionalTag.first);
const auto tagProperty = viewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionalTag.first);
// avoid shapes and TAZs
if (!tagProperty->isShapeElement() && !tagProperty->isTAZElement()) {
for (const auto& additional : additionalTag.second) {
Expand Down
Loading

0 comments on commit 67058e7

Please sign in to comment.