summaryrefslogtreecommitdiff
path: root/cpp/demo/Freeze/library/LibraryI.h
blob: 2a51f77c168bf6a4524f9b660a9c20a016012425 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// **********************************************************************
//
// Copyright (c) 2003 - 2004
// ZeroC, Inc.
// North Palm Beach, FL, USA
//
// All Rights Reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************


#ifndef LIBRARY_I_H
#define LIBRARY_I_H

#include <IceUtil/RWRecMutex.h>
#include <Freeze/Evictor.h>
#include <Library.h>
#include <LibraryTypes.h>
#include <IceUtil/AbstractMutex.h>

class LibraryI : public Library, public IceUtil::RWRecMutex
{
public:

    LibraryI(const Ice::CommunicatorPtr& communicator,
	     const std::string& envName, const std::string& dbName,
	     const Freeze::EvictorPtr& evictor);
    virtual ~LibraryI();

    virtual ::BookPrx createBook(const ::BookDescription&, const Ice::Current&);
    virtual ::BookPrx findByIsbn(const ::std::string&, const Ice::Current&) const;
    virtual ::BookPrxSeq findByAuthors(const ::std::string&, const Ice::Current&) const;
    virtual void setEvictorSize(::Ice::Int, const Ice::Current&);
    virtual void shutdown(const Ice::Current&);

    void remove(const BookDescription&);

private:

    Freeze::EvictorPtr _evictor;

    Freeze::ConnectionPtr _connection;
    //
    // This is a dictionary of authors to a sequence of isbn numbers
    // for efficient lookup of books by authors.
    //
    StringIsbnSeqDict _authors;
};

typedef IceUtil::Handle<LibraryI> LibraryIPtr;

class BookI : public Book, public IceUtil::AbstractMutexReadI<IceUtil::RWRecMutex>
{
public:

    BookI(const LibraryIPtr&);
    virtual ~BookI();

    virtual ::BookDescription getBookDescription(const Ice::Current&) const;
    virtual void destroy(const Ice::Current&);
    virtual void rentBook(const ::std::string&, const Ice::Current&);
    virtual ::std::string getRenterName(const Ice::Current&) const;
    virtual void returnBook(const Ice::Current&);

private:

    LibraryIPtr _library;
    bool _destroyed;
};

#endif