Saturday Jul 13, 2013

Upgrading to Coherence for C++ 12.1.2 and The "Ambiguous Compilation Error" in Types Derived From AbstractAggregator

This weekend, I started the migration of some old C++ applications built on top of Coherence for C++ 3.7.1 API to its newest and refreshed version, released a few days ago. Version 12.1.2 introduces a lot of cool changes and features in the Coherence product, not mentioning the improvements done in different areas like installation, WebLogic integration, TCMP, Exabus, REST and Coherence*Extend. If you got yourself interested about those changes and improvements, check out the documentation at the following link, and please join us for the live virtual launch event on July 31st. Registration here.

After a couple hours migrating my projects from the oldest version to the newest, I got surprised with the following compiler message when trying to build the code:

call of overloaded 'Float64Sum(const coherence::lang::TypedHandle<coherence::util::extractor::ReflectionExtractor &)' is ambiguous 

If you are experiencing the same compiler message... don't worry. There is a quick and clean solution for this. This compiler error happens because in the 12.1.2 version of Coherence for C++ API, an overloaded version of the create() factory method was introduced in the types derived from the coherence::util::aggregator::AbstractAggregator class.

Until 3.7.1 version, the only way to instantiate an AbstractAggregator object was passing an instance of an coherence::util::ValueExtractor to its factory method. Now you also have the option to pass an instance of an coherence::lang::String::View. This object should contain the name of the attribute that will be aggregated. Automatically and behind the scenes, the Coherence for C++ API will fabricate an coherence::util::ValueExtractor for you.

In my case, I've changed my code from this:

Float64Sum::Handle scoreAggregator = Float64Sum::create(ReflectionExtractor::create("getScore")); 

To this:

Float64Sum::Handle scoreAggregator = Float64Sum::create("getScore"); 

And my project was able to be completely compiled again, both using the GNU Linux G++ and MS Visual Studio for C++ compilers.

Hope this blog helps you eliminate some hours of code debugging :-)

About

Ricardo Ferreira is just a regular person that lives in Brazil and is passionate for technology, movies and his whole family. Currently is working at Oracle Corporation.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
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
   
       
Today