summaryrefslogtreecommitdiffstats
path: root/sdo-cpp/tags/cpp-sdo-1.0.incubating-M3/runtime/core/src/commonj/sdo/Property.h
blob: 74892ca8325be7678fdbff74c8ccb85e3769945f (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/* $Rev$ $Date$ */

#ifndef _PROPERTY_H_
#define _PROPERTY_H_


#include "commonj/sdo/export.h"

#include "commonj/sdo/Type.h"
#include "commonj/sdo/SDODate.h"

namespace commonj{
namespace sdo{

class Type;
class TypeImpl;
class DataObject;

/**  
 *
 * A representation of a property in the type of a data object.
 */

class Property
{
    public:
    
    /**  getName gets the name of the property
     *
     * Returns the name of the property.
     */

  // TODO: We would like the returned value to be an SDOString but not until the internals are ready
     virtual const SDO_API char* getName() const = 0;
  // virtual const SDO_API SDOString& getName() const = 0;
  
    /**  getAlias returns the n'th alias
     *
     * This method returns a const char* corresponding to the
     * alias at index n of the list of aliases. Use getAliasCount to 
     * discover the size of the list.
     */

  // TODO: We would lke to convert the returned value to an SDOString but that means a rename for the method.
    virtual SDO_API const char* getAlias(unsigned int index = 0) const = 0;

  // virtual SDO_API const SDOString& getAlias(unsigned int index = 0) const = 0;
    
    /**  getAliasCount  returns the number of aliases
     *
     * This method returns the number of aliases for this type
     */

    virtual SDO_API unsigned int getAliasCount() const = 0;

    /**  getType returns the type of this property
     *
     * This method returns the type, which may be a DataType or a
     * DataObjectType
     */

    virtual SDO_API const Type& getType() const = 0;

    /**  getTypeEnum gets the enum for this type. 
     *
     * Each DataType has a defined value in the list of Types.
     */

    virtual SDO_API const Type::Types getTypeEnum() const = 0;

     /**  isMany is true if the property is a list 
     *
     * IsMany returns true if this property represents a list of
     * values, and should be accessed via the getList DataObjectAPI.
     */

    virtual bool SDO_API isMany() const = 0;
  
     /**  isContainment is true if the property value is contained 
     *
     * IsContainment returns true if this property represents a DataObjectType,
     * and that DataObjectType is contained. I.E the property value is not a pointer
     * to a DataObject somewhere else in the graph, it is an actual value.
     */

    virtual bool SDO_API isContainment() const = 0;

     /**  isReference is true if the property value is not contained 
     *
     * IsReference returns true if this property represents a DataObjectType,
     * and that DataObjectType is not contained. I.E the property value is a pointer
     * to a DataObject somewhere else in the graph not an actual value.
     */

    virtual bool SDO_API isReference() const = 0;
  
    /**  getContainingType give the type which holds this property.
     *
     * Although many types may have a property of the same name, any given 
     * instance of a property belongs to only one type.
     * This method returns the type which holds this proeprty.
     */

    virtual SDO_API const Type& getContainingType() const = 0;
  


    /**  isReadOnly returns true if the property is unmodifiable.
     *
     * NOT IMPLEMENTED
     * Returns true if values for this Property cannot be modified using the SDO APIs.
     * When true, DataObject.set(Property property, Object value) throws an exception.
     * Values may change due to other factors, such as services operating on DataObjects.
     */

    virtual bool SDO_API isReadOnly() const = 0;

    /**  getOpposite  returns the opposite property or zero.
     *
     * NOT IMPLEMENTED
     */

    virtual SDO_API const Property* getOpposite() const = 0;

    /**  isDefaulted is true if a default has been set.
     *
     * A property value may be set or unset. If unset, requests to the
     * data object for the value will return a default if there is one.
     * If the property is not defaulted, an un specified value will be
     * returned. (Thism value will probably be zero).
     */

    virtual SDO_API bool isDefaulted() const = 0 ;

    /**  setDefault sets the right sort of default.
     *
     * The many overrides of this method allow the setting
     * of a default value for any DataType property.
     */

    virtual SDO_API void setDefault(bool b ) = 0;
    virtual SDO_API void setDefault(char c) = 0;
    virtual SDO_API void setDefault(wchar_t c) = 0;
    virtual SDO_API void setDefault(char* c) = 0;
    virtual SDO_API void setDefault(const SDOString& c) = 0;
    virtual SDO_API void setDefault(short s) = 0;
#if __WORDSIZE !=64
    virtual SDO_API void setDefault(long l) = 0;
#endif
    virtual SDO_API void setDefault(int64_t i) = 0;
    virtual SDO_API void setDefault(float f) = 0;
    virtual SDO_API void setDefault(long double d) = 0;
    virtual SDO_API void setDefault(const SDODate d) = 0;
    virtual SDO_API void setDefault(const wchar_t* c, unsigned int len) = 0;
    virtual SDO_API void setDefault(const char* c, unsigned int len) = 0;
    virtual SDO_API void setDefault(const SDOString& c, unsigned int len) = 0;

    /**  getDefault gets the right sort of default.
     *
     * The many overrides of this method allow the getting
     * of a default value for any DataType property.
     */

    virtual SDO_API unsigned int     getStringDefault(wchar_t* val, unsigned int max) const = 0;
    virtual SDO_API unsigned int    getBytesDefault(char* val, unsigned int max) const = 0;
    virtual SDO_API unsigned int    getBytesDefault(SDOString& val, unsigned int max) const = 0;
    virtual SDO_API bool        getBooleanDefault() const = 0;
    virtual SDO_API char        getByteDefault() const = 0;
    virtual SDO_API wchar_t     getCharacterDefault() const = 0;
    virtual SDO_API short       getShortDefault() const = 0;
    virtual SDO_API long        getIntegerDefault() const = 0;
    virtual SDO_API int64_t     getLongDefault() const = 0;
    virtual SDO_API float       getFloatDefault() const = 0;
    virtual SDO_API long double getDoubleDefault() const = 0;
    virtual SDO_API const SDODate  getDateDefault() const = 0;
    virtual SDO_API const char*   getCStringDefault() const = 0;
  // TODO: Can't overload return types.
  // virtual SDO_API const SDOString& getSDOStringDefault() const = 0;
    virtual SDO_API unsigned int getDefaultLength() const = 0;


};


};
};

#endif //_PROPERTY_H_