Skip to content

Commit 5066fc7

Browse files
committed
Enh 37170238 - [37059890->14.1.1.0.20] Port UniversalExtractor and UniversalUpdater to C++ and .NET (main.cpp cl's 111343, 111476, 111478, 111517 --> 14.1.1.0)
[git-p4: depot-paths = "//dev/release.cpp/coherence-cpp-v14.1.1.0/": change = 111936]
1 parent f4a39f1 commit 5066fc7

File tree

6 files changed

+501
-0
lines changed

6 files changed

+501
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown at
5+
* https://oss.oracle.com/licenses/upl.
6+
*/
7+
#ifndef COH_UNIVERSAL_EXTRACTOR_HPP
8+
#define COH_UNIVERSAL_EXTRACTOR_HPP
9+
10+
#include "coherence/lang.ns"
11+
12+
#include "coherence/io/pof/PofReader.hpp"
13+
#include "coherence/io/pof/PofWriter.hpp"
14+
15+
#include "coherence/util/extractor/AbstractExtractor.hpp"
16+
17+
COH_OPEN_NAMESPACE3(coherence,util,extractor)
18+
19+
using coherence::io::pof::PofReader;
20+
using coherence::io::pof::PofWriter;
21+
22+
/**
23+
* Universal ValueExtractor implementation.
24+
*
25+
* UniversalExtractor can only run within the Coherence cluster.
26+
*
27+
* Refer to the Coherence for Java documentation for more information.
28+
*
29+
* @author cp/gg 2002.11.01, ew 2007.02.01, jf 2017.11.20, phf 2024.09.13
30+
*
31+
* @since 14.1.2.0.0
32+
*/
33+
class COH_EXPORT UniversalExtractor
34+
: public cloneable_spec<UniversalExtractor,
35+
extends<AbstractExtractor> >
36+
{
37+
friend class factory<UniversalExtractor>;
38+
39+
// ----- constructors ---------------------------------------------------
40+
41+
protected:
42+
/**
43+
* Construct an empty UniversalExtractor
44+
* (necessary for the PortableObject interface).
45+
*/
46+
UniversalExtractor();
47+
48+
/**
49+
* Construct a UniversalExtractor based on a name, optional
50+
* parameters and the entry extraction target.
51+
*
52+
* @param vsName a method or property name
53+
* @param vaParam the array of arguments to be used in the method
54+
* invocation; may be null
55+
* @param nTarget one of the {@link #value} or {@link #key} values
56+
*/
57+
UniversalExtractor(String::View vsName, ObjectArray::View vaParam = NULL,
58+
int32_t nTarget = value);
59+
60+
/**
61+
* Copy constructor.
62+
*/
63+
UniversalExtractor(const UniversalExtractor& that);
64+
65+
// ----- PortableObject interface ---------------------------------------
66+
67+
public:
68+
/**
69+
* {@inheritDoc}
70+
*/
71+
virtual void readExternal(PofReader::Handle hIn);
72+
73+
/**
74+
* {@inheritDoc}
75+
*/
76+
virtual void writeExternal(PofWriter::Handle hOut) const;
77+
78+
// ----- Object interface -----------------------------------------------
79+
80+
public:
81+
/**
82+
* {@inheritDoc}
83+
*/
84+
virtual TypedHandle<const String> toString() const;
85+
86+
// ----- data member accessors ------------------------------------------
87+
88+
public:
89+
/**
90+
* Return the name passed into UniversalExtractor(String).
91+
*
92+
* @return the name of extraction attribute
93+
*/
94+
virtual String::View getName() const;
95+
96+
/**
97+
* Return the array of arguments used to invoke the method.
98+
*
99+
* @return the array of arguments used to invoke the method
100+
*/
101+
virtual ObjectArray::View getParameters() const;
102+
103+
// ----- data members ---------------------------------------------------
104+
105+
protected:
106+
/**
107+
* A method or property name.
108+
*/
109+
FinalView<String> f_vsName;
110+
111+
/**
112+
* The parameter array. Must be null or zero length for a property based extractor.
113+
*/
114+
FinalView<ObjectArray> f_vaParam;
115+
116+
// ----- constants ------------------------------------------------------
117+
118+
public:
119+
/**
120+
* If f_vsName ends with this suffix, it represents a method name.
121+
*/
122+
static String::View getMethodSuffix();
123+
};
124+
125+
COH_CLOSE_NAMESPACE3
126+
127+
#endif // COH_UNIVERSAL_EXTRACTOR_HPP
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown at
5+
* https://oss.oracle.com/licenses/upl.
6+
*/
7+
#ifndef COH_UNIVERSAL_UPDATER_HPP
8+
#define COH_UNIVERSAL_UPDATER_HPP
9+
10+
#include "coherence/lang.ns"
11+
12+
#include "coherence/io/pof/PofReader.hpp"
13+
#include "coherence/io/pof/PofWriter.hpp"
14+
#include "coherence/io/pof/PortableObject.hpp"
15+
16+
#include "coherence/util/extractor/AbstractUpdater.hpp"
17+
18+
COH_OPEN_NAMESPACE3(coherence,util,extractor)
19+
20+
using coherence::io::pof::PofReader;
21+
using coherence::io::pof::PofWriter;
22+
using coherence::io::pof::PortableObject;
23+
24+
/**
25+
* Universal ValueUpdater implementation.
26+
*
27+
* UniversalUpdater can only run within the Coherence cluster.
28+
*
29+
* Refer to the Coherence for Java documentation for more information.
30+
*
31+
* @author gg 2005.10.27, jf 2017.11.28, phf 2024.09.23
32+
*
33+
* @see CompositeUpdater
34+
*
35+
* @since 14.1.2.0.0
36+
*/
37+
class COH_EXPORT UniversalUpdater
38+
: public cloneable_spec<UniversalUpdater,
39+
extends<AbstractUpdater>,
40+
implements<PortableObject> >
41+
{
42+
friend class factory<UniversalUpdater>;
43+
44+
// ----- constructors ---------------------------------------------------
45+
46+
protected:
47+
/**
48+
* Construct an empty UniversalUpdater
49+
* (necessary for the PortableObject interface).
50+
*/
51+
UniversalUpdater();
52+
53+
/**
54+
* Construct a UniversalUpdater for the provided name.
55+
*
56+
* @param vsName a method or property name
57+
*/
58+
UniversalUpdater(String::View vsName);
59+
60+
/**
61+
* Copy constructor.
62+
*/
63+
UniversalUpdater(const UniversalUpdater& that);
64+
65+
// ----- PortableObject interface ---------------------------------------
66+
67+
public:
68+
/**
69+
* {@inheritDoc}
70+
*/
71+
virtual void readExternal(PofReader::Handle hIn);
72+
73+
/**
74+
* {@inheritDoc}
75+
*/
76+
virtual void writeExternal(PofWriter::Handle hOut) const;
77+
78+
// ----- Object interface -----------------------------------------------
79+
80+
public:
81+
/**
82+
* {@inheritDoc}
83+
*/
84+
virtual TypedHandle<const String> toString() const;
85+
86+
// ----- data members ---------------------------------------------------
87+
88+
protected:
89+
/**
90+
* A method name, or a property name.
91+
*/
92+
FinalView<String> f_vsName;
93+
};
94+
95+
COH_CLOSE_NAMESPACE3
96+
97+
#endif // COH_UNIVERSAL_UPDATER_HPP
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown at
5+
* https://oss.oracle.com/licenses/upl.
6+
*/
7+
#include "coherence/util/extractor/UniversalExtractor.hpp"
8+
9+
COH_OPEN_NAMESPACE3(coherence,util,extractor)
10+
11+
COH_REGISTER_PORTABLE_CLASS(192, UniversalExtractor);
12+
13+
// ----- constructors -------------------------------------------------------
14+
15+
UniversalExtractor::UniversalExtractor()
16+
: f_vsName(self()), f_vaParam(self())
17+
{
18+
m_nTarget = value;
19+
}
20+
21+
UniversalExtractor::UniversalExtractor(String::View vsName,
22+
ObjectArray::View vaParam, int32_t nTarget)
23+
: f_vsName(self(), vsName), f_vaParam(self(), vaParam)
24+
{
25+
COH_ENSURE_PARAM(vsName);
26+
if (vaParam != NULL && vaParam->length > 0 && !vsName->endsWith(getMethodSuffix()))
27+
{
28+
COH_THROW_STREAM(IllegalArgumentException, "UniversalExtractor constructor: parameter vsName[value:"
29+
<< vsName << "] must end with method suffix \"" << getMethodSuffix()
30+
<< "\" when optional parameters provided");
31+
}
32+
m_nTarget = nTarget;
33+
}
34+
35+
UniversalExtractor::UniversalExtractor(const UniversalExtractor& that)
36+
: f_vsName(self(), that.f_vsName),
37+
f_vaParam(self(), cast<ObjectArray::View>(Object::clone(that.f_vaParam)))
38+
{
39+
// UniversalExtractor is cloneable only because MSVC tries to generate
40+
// a copy constructor for it, which blows up as MemberHandles do not
41+
// support automatic copy construction
42+
}
43+
44+
// ----- PortableObject interface -------------------------------------------
45+
46+
void UniversalExtractor::readExternal(PofReader::Handle hIn)
47+
{
48+
initialize(f_vsName, hIn->readString(0));
49+
initialize(f_vaParam, hIn->readObjectArray(1));
50+
m_nTarget = hIn->readInt32(2);
51+
}
52+
53+
void UniversalExtractor::writeExternal(PofWriter::Handle hOut) const
54+
{
55+
hOut->writeString(0, f_vsName);
56+
hOut->writeObjectArray(1, f_vaParam);
57+
hOut->writeInt32(2, m_nTarget);
58+
}
59+
60+
// ----- Object interface ---------------------------------------------------
61+
62+
TypedHandle<const String> UniversalExtractor::toString() const
63+
{
64+
String::View vs = "";
65+
66+
if (m_nTarget == key)
67+
{
68+
vs = COH_TO_STRING(vs << ".getKey()");
69+
}
70+
71+
return COH_TO_STRING(vs << '.' << getName() << ' ' << getParameters());
72+
}
73+
74+
// ----- data member accessors ----------------------------------------------
75+
76+
String::View UniversalExtractor::getName() const
77+
{
78+
return f_vsName;
79+
}
80+
81+
ObjectArray::View UniversalExtractor::getParameters() const
82+
{
83+
return f_vaParam;
84+
}
85+
86+
// ----- constants ----------------------------------------------------------
87+
88+
String::View UniversalExtractor::getMethodSuffix()
89+
{
90+
static FinalView<String> vsMethodSuffix(System::common(), String::create("()"));
91+
92+
return vsMethodSuffix;
93+
}
94+
COH_STATIC_INIT(UniversalExtractor::getMethodSuffix());
95+
96+
COH_CLOSE_NAMESPACE3
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown at
5+
* https://oss.oracle.com/licenses/upl.
6+
*/
7+
#include "coherence/util/extractor/UniversalUpdater.hpp"
8+
9+
COH_OPEN_NAMESPACE3(coherence,util,extractor)
10+
11+
COH_REGISTER_PORTABLE_CLASS(193, UniversalUpdater);
12+
13+
// ----- constructors -------------------------------------------------------
14+
15+
UniversalUpdater::UniversalUpdater()
16+
: f_vsName(self())
17+
{
18+
}
19+
20+
UniversalUpdater::UniversalUpdater(String::View vsName)
21+
: f_vsName(self(), vsName)
22+
{
23+
COH_ENSURE_PARAM(vsName);
24+
}
25+
26+
UniversalUpdater::UniversalUpdater(const UniversalUpdater& that)
27+
: f_vsName(self(), that.f_vsName)
28+
{
29+
// UniversalUpdater is cloneable only because MSVC tries to generate
30+
// a copy constructor for it, which blows up as MemberHandles do not
31+
// support automatic copy construction
32+
}
33+
34+
// ----- PortableObject interface -------------------------------------------
35+
36+
void UniversalUpdater::readExternal(PofReader::Handle hIn)
37+
{
38+
initialize(f_vsName, hIn->readString(0));
39+
}
40+
41+
void UniversalUpdater:: writeExternal(PofWriter::Handle hOut) const
42+
{
43+
hOut->writeString(0, f_vsName);
44+
}
45+
46+
// ----- Object interface ---------------------------------------------------
47+
48+
TypedHandle<const String> UniversalUpdater::toString() const
49+
{
50+
return f_vsName;
51+
}
52+
53+
COH_CLOSE_NAMESPACE3

0 commit comments

Comments
 (0)