|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78605 - in sandbox/icl/libs/xplore/br1/sqlbrowser: . gen
From: afojgo_at_[hidden]
Date: 2012-05-25 03:24:32
Author: jofaber
Date: 2012-05-25 03:24:27 EDT (Fri, 25 May 2012)
New Revision: 78605
URL: http://svn.boost.org/trac/boost/changeset/78605
Log:
Additions on the DbGenerator
Binary files modified:
sandbox/icl/libs/xplore/br1/sqlbrowser/Generatic1.db
Text files modified:
sandbox/icl/libs/xplore/br1/sqlbrowser/gen/DbGenerator.cpp | 122 +++++++++++++++++++++++++++++----------
sandbox/icl/libs/xplore/br1/sqlbrowser/gen/DbGenerator.h | 15 +++
sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro | 4
3 files changed, 103 insertions(+), 38 deletions(-)
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/Generatic1.db
==============================================================================
Binary files. No diff available.
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/gen/DbGenerator.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/gen/DbGenerator.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/gen/DbGenerator.cpp 2012-05-25 03:24:27 EDT (Fri, 25 May 2012)
@@ -194,7 +194,10 @@
//------------------------------------------------------------------------------
void DbGenerator::generateRelationships()
{
- generateArtistComposedTitle();
+ generateEdges_ArtistComposedTitle();
+ generateEdges_TitleRecordedAsRecording();
+ generateEdges_AlbumContainsRecording();
+ generateEdges_ArtistPerformedOnRecording();
}
@@ -311,7 +314,9 @@
if(idx % albumRate == 0)
++aAlbumKey;
- m_aRecordings.add(generateRecording(aAlbumKey, aTitleKey));
+ tKey dbg_Recording = generateRecording(aAlbumKey, aTitleKey);
+ m_aRecordings.add(dbg_Recording);
+ //m_aRecordings.add(generateRecording(aAlbumKey, aTitleKey));
}
}
@@ -326,7 +331,7 @@
//------------------------------------------------------------------------------
//- Relationships (Edges)
//------------------------------------------------------------------------------
-void DbGenerator::generateArtistComposedTitle()
+void DbGenerator::generateEdges_ArtistComposedTitle()
{
makeComposersRange();
@@ -386,16 +391,51 @@
//------------------------------------------------------------------------------
-void DbGenerator::generateTitleRecordedAsRecording()
+void DbGenerator::generateEdges_TitleRecordedAsRecording()
{
- //Every recording needs at least one title that it is a recording of
- for( tInterKeySet::element_iterator it = elements_begin(m_aRecordings)
- ; it != elements_end(m_aRecordings); ++it)
+ int count = m_aRecordings.size();
+
+ int titleCount = m_aTitles.size();
+ int coverRate = count / titleCount;
+ int coverRest = count % titleCount;
+ tKey aTitleKey = first(m_aTitles);
+ tKey aRecKey = first(m_aRecordings);
+
+ for( int idx=1
+ ; idx <= count && contains(m_aTitles, aTitleKey)
+ && contains(m_aRecordings, aRecKey)
+ ; idx++, aRecKey++)
+ {
+ if(idx % coverRate == 0)
+ ++aTitleKey;
+
+ insertEdge_TitleRecoredAsRecording(aTitleKey, aRecKey);
+ }
+}
+
+void DbGenerator::generateEdges_AlbumContainsRecording()
+{
+ int count = m_aRecordings.size();
+
+ int albumCount = m_aAlbums.size();
+ int albumRate = count / albumCount;
+ int albumRest = count % albumCount;
+ tKey aAlbumKey = first(m_aAlbums);
+ tKey aRecKey = first(m_aRecordings);
+
+ for( int idx=1
+ ; idx <= count && contains(m_aAlbums, aAlbumKey)
+ && contains(m_aRecordings, aRecKey)
+ ; idx++, aRecKey++)
{
- assignTitle(*it);
+ if(idx % albumRate == 0)
+ ++aAlbumKey;
+
+ insertEdge_AlbumContainsRecording(aAlbumKey, aRecKey);
}
+}
- /*
+ /*TODO
//Most recordings are part of an album
for( tInterKeySet::element_iterator it = elements_begin(m_aRecordings)
; it != elements_end(m_aRecordings); ++it)
@@ -410,44 +450,60 @@
assignArtists(*it);
}
*/
-}
+
// composer -> { titles }
// title -> { composers }
-void DbGenerator::assignTitle(tKey aRecordingKey)
-{
- gen::IntGenerator someTitle(hull(m_aTitles));
- tKey aTitleKey = someTitle();
- //JODO Make the construction of entities more realistic
- //tKey aComposerKey = getComposer(aTitleKey);
- //tKey aSomeAlbumKey = getSomeComposerAlbum();
+void DbGenerator::generateEdges_ArtistPerformedOnRecording()
+{
+ //Every title needs at least one composer.
+ for( tInterKeySet::element_iterator it = elements_begin(m_aRecordings)
+ ; it != elements_end(m_aRecordings); ++it)
+ {
+ assignPerformers(*it);
+ }
- tKey aEdgeKey = insertObject();
- insertEdge(aEdgeKey, R_title_recorded_as_record, aTitleKey, aRecordingKey);
}
-void DbGenerator::assignAlbum(tKey aRecordingKey)
+void DbGenerator::assignPerformers(tKey aRecording)
{
- gen::IntGenerator someAlbum(hull(m_aAlbums));
- tKey aAlbumKey = someAlbum();
+ tKey2Key::iterator title_ = m_aRecording2Title.find(aRecording);
+ if(title_ != m_aRecording2Title.end())
+ {
+ tKey aTitleKey = (*title_).second;
+ bool dbg_inTitleRange = contains(m_aTitles, aTitleKey);
+ tKey2Keys::iterator title2comps_ = m_aTitle2Composers.find(aTitleKey);
+ if(title2comps_ != m_aTitle2Composers.end())
+ {
+ tKeySet composers = (*title2comps_).second;
+ for( tKeySet::iterator composer_ = composers.begin()
+ ; composer_ != composers.end(); ++composer_)
+ insertEdge_ArtistPerformedOnRecording(*composer_, aRecording);
+ }
- tKey aEdgeKey = insertObject();
- insertEdge(aEdgeKey, R_album_contains_record, aAlbumKey, aRecordingKey);
+ }
}
+//------------------------------------------------------------------------------
+void DbGenerator::insertEdge_TitleRecoredAsRecording(tKey aTitleKey, tKey aRecKey)
+{
+ tKey aEdgeKey = insertObject();
+ insertEdge(aEdgeKey, R_title_recorded_as_record, aTitleKey, aRecKey);
+ m_aRecording2Title.add(tKey2Key::value_type(aRecKey, aTitleKey));
+}
-/*
-void DbGenerator::generateAlbumContainsRecording()
+void DbGenerator::insertEdge_AlbumContainsRecording(tKey aAlbumKey, tKey aRecKey)
{
- //Every title needs at least one composer.
- for( tInterKeySet::element_iterator it = elements_begin(m_aTitles)
- ; it != elements_end(m_aTitles); ++it)
- {
- assignComposers(*it);
- }
+ tKey aEdgeKey = insertObject();
+ insertEdge(aEdgeKey, R_album_contains_record, aAlbumKey, aRecKey);
+}
+void DbGenerator::insertEdge_ArtistPerformedOnRecording(tKey aArtistKey, tKey aRecKey)
+{
+ tKey aEdgeKey = insertObject();
+ insertEdge(aEdgeKey, R_artist_performed_record, aArtistKey, aRecKey);
}
-*/
+
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/gen/DbGenerator.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/gen/DbGenerator.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/gen/DbGenerator.h 2012-05-25 03:24:27 EDT (Fri, 25 May 2012)
@@ -26,6 +26,7 @@
typedef unsigned int tObjectType;
typedef unsigned int tAttribute;
typedef std::set<tKey> tKeySet;
+ typedef boost::icl::map<tKey, tKey> tKey2Key;
typedef boost::icl::map<tKey, tKeySet> tKey2Keys;
typedef boost::icl::map<tKey, tString> tKey2Name;
@@ -91,9 +92,11 @@
void generateRecordings(int);
void generateAlbums(int);
- void generateArtistComposedTitle();
- void generateTitleRecordedAsRecording();
- void generateAlbumContainsRecording();
+ void generateEdges_ArtistComposedTitle();
+ void generateEdges_TitleRecordedAsRecording();
+ void generateEdges_AlbumContainsRecording();
+ void generateEdges_ArtistPerformedOnRecording();
+
private:
void configure();
@@ -125,8 +128,13 @@
void assignTitle(tKey aRecordingKey);
void assignAlbum(tKey aRecordingKey);
+ void assignPerformers(tKey aRecKey);
tString makeRecordingName(tKey aAlbumKey, tKey aTitleKey);
+ void insertEdge_TitleRecoredAsRecording(tKey aTitleKey, tKey aRecKey);
+ void insertEdge_AlbumContainsRecording(tKey aAlbumKey, tKey aRecKey);
+ void insertEdge_ArtistPerformedOnRecording(tKey aArtistKey, tKey aRecKey);
+
private:
int m_iArtists;
int m_iTitles;
@@ -148,6 +156,7 @@
tKey2Keys m_aComposer2Titles;
tKey2Keys m_aTitle2Composers;
+ tKey2Key m_aRecording2Title;
tKey2Name m_aTitleNames;
tKey2Name m_aAlbumNames;
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro 2012-05-25 03:24:27 EDT (Fri, 25 May 2012)
@@ -3,8 +3,8 @@
QT += sql
-#INCLUDEPATH += /cygwin/home/jofa/dev/boost/branches/release
-INCLUDEPATH += C:\NIBuild\3rdparty\boost-1.48.0
+INCLUDEPATH += /cygwin/home/jofa/dev/boost/branches/release
+#INCLUDEPATH += C:\NIBuild\3rdparty\boost-1.48.0
HEADERS = browser.h connectionwidget.h qsqlconnectiondialog.h \
exttableview.h \
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk