CPlaylistItem::CPlaylistItem(uint32_t mediaItemHash, uint32_t plID ) :IContentItem(0, 0, CItemType::E_PLAYLISTITEM), m_mediaitem_hash(mediaItemHash) { if(plID == 0) { m_hash = getNextFreeID(); } else { m_hash = plID; if( getNextFreeID() <= m_hash) { setNextFreeID( m_hash + 1 ); } } assembleText(); }
CPlaylistItem::CPlaylistItem(CRootItem *root_item, CCategoryItem* parent, int posInParent) : IContentItem( root_item, parent, CItemType::E_PLAYLISTITEM ) { m_hash = getNextFreeID(); m_root_item->setContentPtr(CItemType(CItemType::E_PLAYLISTITEM), this, m_hash ); assembleText(); }
void NGNet::createSpiderWeb(int numRadDiv, int numCircles, SUMOReal spaceRad, bool hasCenter) { if (numRadDiv < 3) { numRadDiv = 3; } if (numCircles < 1) { numCircles = 1; } int ir, ic; SUMOReal angle = (SUMOReal)(2 * M_PI / numRadDiv); // angle between radial divisions NGNode* Node; for (ir = 1; ir < numRadDiv + 1; ir++) { for (ic = 1; ic < numCircles + 1; ic++) { // create Node Node = new NGNode( toString<int>(ir) + "/" + toString<int>(ic), ir, ic); Node->setX(radialToX((ic) * spaceRad, (ir - 1) * angle)); Node->setY(radialToY((ic) * spaceRad, (ir - 1) * angle)); myNodeList.push_back(Node); // create Links if (ir > 1) { connect(Node, findNode(ir - 1, ic)); } if (ic > 1) { connect(Node, findNode(ir, ic - 1)); } if (ir == numRadDiv) { connect(Node, findNode(1, ic)); } } } if (hasCenter) { // node Node = new NGNode(getNextFreeID(), 0, 0, true); Node->setX(0); Node->setY(0); myNodeList.push_back(Node); // links for (ir = 1; ir < numRadDiv + 1; ir++) { connect(Node, findNode(ir, 1)); } } }
CPlaylistItem::CPlaylistItem(CRootItem *root_item, std::string text, CCategoryItem* parent, int posInParent) throw(ExMalformedPatch) : IContentItem( root_item, parent, CItemType::E_PLAYLISTITEM ) { bool serialisationNeeded = true; // first section is handled by CItemBase size_t lpos, rpos; // lpos = m_text.find('\t', 1) + 1; lpos = 0; try { rpos = text.find('\t', lpos); if( rpos != string::npos ) { string typeStr = text.substr(lpos, rpos - lpos); if(typeStr.compare(CItemType::getString(m_item_type)) == 0 ) { // serialisation started with type string 'P' -> input string is suitable for m_text lpos = rpos + 1; m_text = text; serialisationNeeded = false; } } else { throw ExMalformedPatch("error parsing first field (expecting type string or 'media item hash'): terminating tab char is missing." ,-1); } rpos = text.find('\t', lpos); if( rpos != string::npos ) { string mediaitemHashStr = text.substr(lpos, rpos - lpos); m_mediaitem_hash = CUtils::str2uint32(mediaitemHashStr.c_str()); lpos = rpos + 1; } else { throw ExMalformedPatch("error parsing 'media item hash' field, terminating tab char is missing." ,-1); } string hashStr; rpos = text.find_first_of("\t\n", lpos); if( rpos != string::npos ) { hashStr = text.substr(lpos, rpos - lpos); lpos = rpos + 1; } else { hashStr = text.substr(lpos); } m_hash = CUtils::str2uint32(hashStr.c_str()); if(m_hash == 0){ m_hash = getNextFreeID(); } if(serialisationNeeded) { assembleText(); // from here on "m_text" ist surely valid } if(m_parent) { m_parent->addChild(this, posInParent); } if(m_text.rfind('\n') == string::npos ) { m_text.append("\n"); } // for CPlaylistItem, m_hash is an index number that never changes during // livetime of an object. m_root_item->setContentPtr(CItemType(CItemType::E_PLAYLISTITEM), this, m_hash ); } catch(std::invalid_argument& ex) { throw ExMalformedPatch(ex.what(), -1); } }