ICnvSvc.hpp 7.12 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/******************************************************************************
 *                      ICnvSvc.hpp
 *
 * This file is part of the Castor project.
 * See http://castor.web.cern.ch/castor
 *
 * Copyright (C) 2003  CERN
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
20
 * @(#)$RCSfile: ICnvSvc.hpp,v $ $Revision: 1.10 $ $Release$ $Date: 2004/10/14 16:34:43 $ $Author: sponcec3 $
21
22
23
24
25
26
27
28
29
30
31
 *
 *
 *
 * @author Sebastien Ponce
 *****************************************************************************/

#ifndef CASTOR_ICNVSVC_HPP
#define CASTOR_ICNVSVC_HPP 1

// Include Files
#include "IService.hpp"
32
#include "Constants.hpp"
33
#include "castor/exception/Exception.hpp"
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

namespace castor {

  // Forward Declaration
  class IConverter;
  class IAddress;
  class IObject;

  /**
   * Abstract interface for services dealing with conversion
   */
  class ICnvSvc : public virtual IService {

  public:
    /** Add converter object to conversion service.
     *  @param pConverter Pointer to converter object
     *  @return boolean indicating success or failure.
     */
    virtual bool addConverter(IConverter* pConverter) = 0;

    /** Remove converter object from conversion service (if present).
     *  The converter is defined by the class type of the objects created.
     *  @param id ID of the converter
     *  @return boolean indicating success or failure.
     */
    virtual bool removeConverter(const unsigned int id) = 0;

    /** Retrieve converter from list
     *  @param id the id of the converter
     *  @return the converter corresponding to id or 0 if non was found
     */
    virtual IConverter* converter(const unsigned int id) = 0;

    /**
68
     * create foreign representation from a C++ Object.
69
70
71
72
73
     * @param address where to store the representation of
     * the object
     * @param object the object to deal with
     * @param autocommit whether the changes to the database
     * should be commited or not
74
75
76
     * @param type if not OBJ_INVALID, the ids representing
     * the links to objects of this type will not set to 0
     * as is the default.
77
     * @exception Exception throws an Exception in case of error
78
79
80
     */
    virtual void createRep(IAddress* address,
                           IObject* object,
81
82
                           bool autocommit,
                           unsigned int type = OBJ_INVALID)
83
      throw (castor::exception::Exception) = 0;
84
85
86
87
88
89
90
91

    /**
     * Updates foreign representation from a C++ Object.
     * @param address where the representation of
     * the object is stored
     * @param object the object to deal with
     * @param autocommit whether the changes to the database
     * should be commited or not
92
     * @exception Exception throws an Exception in case of error
93
94
95
     */
    virtual void updateRep(IAddress* address,
                           IObject* object,
96
                           bool autocommit)
97
      throw (castor::exception::Exception) = 0;
98
99
100
101
102
103
104
105

    /**
     * Deletes foreign representation of a C++ Object.
     * @param address where the representation of
     * the object is stored
     * @param object the object to deal with
     * @param autocommit whether the changes to the database
     * should be commited or not
106
     * @exception Exception throws an Exception in case of error
107
108
109
110
     */
    virtual void deleteRep(castor::IAddress* address,
                           castor::IObject* object,
                           bool autocommit = true)
111
      throw (castor::exception::Exception) = 0;
112
113
114
115
116
117
118
119

    /**
     * create C++ object from foreign representation
     * @param address the place where to find the foreign
     * representation
     * @return the C++ object created from its reprensentation
     * or 0 if unsuccessful. Note that the caller is responsible
     * for the deallocation of the newly created object
120
     * @exception Exception throws an Exception in case of error
121
     */
122
    virtual IObject* createObj (IAddress* address)
123
      throw (castor::exception::Exception) = 0;
124

125
126
127
128
129
    /**
     * Updates C++ object from its foreign representation.
     * @param object the object to deal with
     * @exception Exception throws an Exception in case of error
     */
130
    virtual void updateObj(IObject* object)
131
132
      throw (castor::exception::Exception) = 0;

133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
    /**
     * Fill the foreign representation with some of the objects
     * refered by a given C++ object.
     * @param address the place where to find the foreign representation
     * @param object the original C++ object
     * @param type the type of the refered objects to store
     * @param autocommit whether the changes to the database
     * should be commited or not
     * @exception Exception throws an Exception in case of error
     */
    virtual void fillRep(castor::IAddress* address,
                         castor::IObject* object,
                         unsigned int type,
                         bool autocommit)
      throw (castor::exception::Exception) = 0;
    
    /**
     * Retrieve from the foreign representation some of the
     * objects refered by a given C++ object.
     * @param address the place where to find the foreign representation
     * @param object the original object
     * @param type the type of the refered objects to retrieve
     * @exception Exception throws an Exception in case of error
     */
    virtual void fillObj(castor::IAddress* address,
                         castor::IObject* object,
                         unsigned int type)
      throw (castor::exception::Exception) = 0;

162
163
164
165
166
167
168
169
170
171
172
173
174
175
    /**
     * Forces the commit of the last changes.
     * @exception Exception throws an Exception in case of error
     */
    virtual void commit()
      throw (castor::exception::Exception) = 0;

    /**
     * Forces the rollback of the last changes
     * @exception Exception throws an Exception in case of error
     */
    virtual void rollback()
      throw (castor::exception::Exception) = 0;

176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
    /**
     * Deletes foreign representation of a C++ Object without
     * needing the object. The cost of this method is higher
     * than the cost of deleteRep since it needs to call
     * createObj first
     * @param address where the representation of
     * the object is stored
     * @param autocommit whether the changes to the database
     * should be commited or not
     * @exception Exception throws an Exception in cas of error
     */
    virtual void deleteRepByAddress (IAddress* address,
                                     bool autocommit = true)
      throw (castor::exception::Exception) = 0;

191
192
193
194
195
  };

} // end of namespace castor

#endif // CASTOR_ICNVSVC_HPP