1016 std::ostream::fmtflags outFlags = out.flags();
1019 const DimensionSet& dims = m.getDimensionSet();
1020 bool bOnlyDimFound =
false;
1022 using std::operator<<;
1024 std::stringstream osDimHead(std::stringstream::out);
1025 bool bTimeIsIn =
false;
1026 const auto dimsEnd = dims.end();
1027 for (
auto it = dims.begin(); it != dimsEnd; ++it) {
1029 if (pOnlyDim && *it == *pOnlyDim) {
1031 bOnlyDimFound = pOnlyDim !=
nullptr;
1033 else if (!pOnlyDim) {
1036 if (!osDimHead.str().empty())
1043 if (bTimeIsIn || !osDimHead.str().empty()) {
1044 out <<
"Mapping domain: ";
1047 if (!osDimHead.str().empty())
1050 out << osDimHead.str() << endl;
1053 ConstMappingIterator *it = m.createConstIterator();
1055 if (!it->inRange()) {
1056 out <<
"Mapping is empty." << endl;
1057 out.flags(outFlags);
1062 Argument
min = it->getPosition();
1063 Argument
max = it->getPosition();
1065 typedef std::set<simtime_t> t_time_container_type;
1066 typedef std::set<argument_value_t> t_value_container_type;
1068 t_time_container_type timePositions;
1069 t_value_container_type otherPositions;
1070 std::size_t iMaxHeaderItemLen = m.toString(it->getPosition().getTime() * lTimeScale, 2).length();
1071 std::size_t iMaxLeftItemLen = 5 > sTableHead.length() ? 5 : sTableHead.length();
1072 const bool bIs2Dim = dims.size() == 2;
1074 if (bIs2Dim && bOnlyDimFound)
1075 bOnlyDimFound =
false;
1076 timePositions.insert(it->getPosition().getTime());
1077 if (bIs2Dim || bOnlyDimFound) {
1079 if (bOnlyDimFound && (posValIt = it->getPosition().find(otherDim)) != it->getPosition().end()) {
1080 otherPositions.insert(it->getPosition().getArgValue(otherDim));
1081 iMaxLeftItemLen =
std::max(iMaxLeftItemLen, m.toString(posValIt->second * lLeftColScale, 2).length());
1083 else if (!bOnlyDimFound) {
1084 otherPositions.insert(it->getPosition().begin()->second);
1085 iMaxLeftItemLen =
std::max(iMaxLeftItemLen, m.toString(it->getPosition().begin()->second * lLeftColScale, 2).length());
1089 while (it->hasNext()) {
1091 const Argument& pos = it->getPosition();
1095 min.setTime(
std::min(min.getTime(), pos.getTime()));
1096 max.setTime(
std::max(max.getTime(), pos.getTime()));
1098 timePositions.insert(pos.getTime());
1100 iMaxHeaderItemLen =
std::max(iMaxHeaderItemLen, m.toString(pos.getTime() * lTimeScale, 2).length());
1102 if (bOnlyDimFound && (posValIt = pos.find(otherDim)) != posValItEnd) {
1103 iMaxLeftItemLen =
std::max(iMaxLeftItemLen, m.toString(posValIt->second * lLeftColScale, 2).length());
1106 if (bIs2Dim || bOnlyDimFound) {
1107 if (!bOnlyDimFound || itA->first == otherDim) {
1108 otherPositions.insert(itA->second);
1109 iMaxLeftItemLen =
std::max(iMaxLeftItemLen, m.toString(itA->second * lLeftColScale, 2).length());
1112 min.setArgValue(itA->first,
std::min(min.getArgValue(itA->first), itA->second));
1113 max.setArgValue(itA->first,
std::max(max.getArgValue(itA->first), itA->second));
1118 if (!bIs2Dim && !bOnlyDimFound) {
1119 if (!bOnlyDimFound && pOnlyDim !=
nullptr) {
1120 out <<
"map contains no " << pOnlyDim->getName() <<
" dimension!" << endl;
1121 out.flags(outFlags);
1125 out <<
"domain - min=" << min <<
" max=" << max << endl;
1127 if (bOnlyDimFound && otherPositions.empty()) {
1128 out <<
"Defines no own key entries for " << pOnlyDim->getName() <<
" dimension! That does NOT mean it doesn't define any attenuation." << endl;
1129 out.flags(outFlags);
1133 t_time_container_type::const_iterator tIt;
1134 const t_time_container_type::const_iterator tItEnd = timePositions.end();
1135 std::stringstream osBorder(std::stringstream::out);
1136 std::stringstream osHeader(std::stringstream::out);
1137 mixim::math::mW2dBm<argument_value_t> fctor2dBm;
1139 for (tIt = timePositions.begin(); tIt != tItEnd; ++tIt) {
1140 osHeader << m.toString(*tIt * lTimeScale, iMaxHeaderItemLen) << osHeader.fill();
1143 osBorder << std::setw(iMaxLeftItemLen) <<
"" << osBorder.fill() <<
"+" << osBorder.fill() << std::setw(osHeader.str().length()) <<
"";
1145 out << osBorder.str() << std::endl;
1146 out << std::setw(iMaxLeftItemLen) << std::left << sTableHead << out.fill() <<
"|" << out.fill();
1147 out << osHeader.str() << std::endl;
1148 out << osBorder.str() << std::endl;
1150 it = m.createConstIterator();
1152 if (dims.size() == 1) {
1153 out << std::setw(iMaxLeftItemLen) <<
"value" << out.fill() <<
"|" << out.fill();
1154 while (it->inRange()) {
1155 out << m.toString(fctor2dBm(it->getValue()), iMaxHeaderItemLen) << out.fill();
1156 if (!it->hasNext()) {
1163 t_value_container_type::const_iterator fIt = otherPositions.begin();
1165 tIt = timePositions.begin();
1166 out << m.toString((*fIt) * lLeftColScale, iMaxLeftItemLen) << out.fill() <<
"|" << out.fill();
1167 while (it->inRange()) {
1168 if (*fIt != it->getPosition().getArgValue(otherDim)) {
1170 out << std::endl << m.toString((*fIt) * lLeftColScale, iMaxLeftItemLen) << out.fill() <<
"|" << out.fill();
1171 tIt = timePositions.begin();
1172 assert(*fIt == it->getPosition().getArgValue(otherDim));
1175 while (tIt != tItEnd && *tIt < it->getPosition().getTime()) {
1178 out << std::setw(iMaxHeaderItemLen + 1) <<
"";
1180 if (tIt != tItEnd) {
1185 out << m.toString(fctor2dBm(it->getValue()), iMaxHeaderItemLen) << out.fill();
1187 if (!it->hasNext()) {
1194 out << std::endl << osBorder.str() << std::endl;
1195 out.flags(outFlags);
static const Dimension time
Shortcut to the time Dimension, same as 'Dimension("time")', but spares the parsing of a string...
Definition: MappingBase.h:64
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
container_type::const_iterator const_iterator
Const-iterator type for this set.
Definition: MappingBase.h:444
ConstMapping()
Initializes the ConstMapping with a the time dimension as domain.
Definition: MappingBase.h:935
_Base::value_type value_type
Definition: MappingBase.h:149
value< double, units::m > m
Definition: Units.h:1047