// linesegment.h // // Class to hold line segment information (that is, the section of line // between two station nodes) #ifndef _LINESEGMENT_H_ #define _LINESEGMENT_H_ #include "stationnode.h" class LineSegment : public mcThing { private: CString name; // artificial really, but still StationNode *from; StationNode *to; BOOL peakOnly; int direction; // uses quadrant values CString toName; // temporary storage int toOrdinal; // temporary storage public: // Constructor for perfect knowledge LineSegment(mcContext *mgr, StationNode *a_from, StationNode *a_to, BOOL a_peakOnly, int a_direction) : mcThing(mgr) ,from(a_from) ,to(a_to) ,peakOnly(a_peakOnly) ,direction(a_direction) { name = from->getName() + "->" + to->getName(); } // Constructor for partial knowledge LineSegment(mcContext *mgr, StationNode *a_from, CString a_toName, int a_toOrdinal, BOOL a_peakOnly, int a_direction) : mcThing(mgr) ,from(a_from) ,to(0) ,toName(a_toName) ,toOrdinal(a_toOrdinal) ,peakOnly(a_peakOnly) ,direction(a_direction) { name = from->getName() + "->" + toName + ":" + CNumString(toOrdinal) + " (unresolved)"; } // Accessors - get accessors only! CString getName() { return name; } StationNode *getFromNode() { return from; } StationNode *getToNode() { return to; } BOOL getPeakOnly() { return peakOnly; } int getDirection() { return direction; } // Access to unresolved destination information CString getToName() { return toName; } int getToOrdinal() { return toOrdinal; } // Method to set resolved destination node mapping // No effect if mapping already set void setToNode(StationNode *a_toNode) { if (to == 0) { CString oldName(name); to = a_toNode; name = from->getName() + "->" + to->getName(); mgr->remapThingName(oldName, this); } } mcThing::type getType() { return mcThing::LINE_SEGMENT; } // SQL members CString getSqlTable() { return "LINE_SEGMENT"; } CString getSqlInsertData() { // LINE_SEGMENTS := ID, FROM_NODE_ID, TO_NODE_ID, PEAK_ONLY, DIRECTION return CNumString(getId()) + ", " + CNumString(from->getId()) + ", " + CNumString(to->getId()) + ", " + literal(peakOnly ? "Y" : "N") + ", " + literal(StationNode::quadToString(direction)); } }; #endif // _LINESEGMENT_H_