~ubuntu-branches/ubuntu/precise/shotwell/precise-updates

« back to all changes in this revision

Viewing changes to src/alien_db/DiscoveredAlienDatabase.vala

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-02-21 13:52:58 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20120221135258-uffg1nm9ifpy2yoh
Tags: 0.11.92-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2011 Yorba Foundation
2
 
 *
3
 
 * This software is licensed under the GNU Lesser General Public License
4
 
 * (version 2.1 or later).  See the COPYING file in this distribution. 
5
 
 */
6
 
 
7
 
namespace AlienDb {
8
 
 
9
 
/**
10
 
 * A light-weight wrapper that contains enough information to display the
11
 
 * database entry in the library window but can delay instantiating the
12
 
 * actual database instance until it is actually needed.
13
 
 */
14
 
public class DiscoveredAlienDatabase : Object {
15
 
    private AlienDatabaseID id;
16
 
    private AlienDatabaseDriver driver;
17
 
    private AlienDatabase database;
18
 
    
19
 
    public DiscoveredAlienDatabase(AlienDatabaseID id) {
20
 
        this.id = id;
21
 
        driver = AlienDatabaseHandler.get_instance().get_driver(id.driver_id);
22
 
    }
23
 
    
24
 
    public AlienDatabaseID get_id() {
25
 
        return id;
26
 
    }
27
 
    
28
 
    public string get_uri() {
29
 
        return id.to_uri();
30
 
    }
31
 
    
32
 
    /**
33
 
     * This method creates an actual instance of the database interface.
34
 
     * It is called when the application is ready to present the database
35
 
     * to the user as a page in the main library window.
36
 
     */
37
 
    public AlienDatabase get_database() throws DatabaseError, AlienDatabaseError {
38
 
        if (database == null) {
39
 
            database = driver.open_database(id);
40
 
        }
41
 
        return database;
42
 
    }
43
 
    
44
 
    /**
45
 
     * Release the underlying database object.
46
 
     */
47
 
    public void release_database() {
48
 
        database = null;
49
 
    }
50
 
}
51
 
 
52
 
}
53