Help: use of “().” and “()[].”

Hello Everyone,

I am trying to understand the programming of Siemens scanner using C++ and given that my C++ skills are limited, I am having problems in understanding many parts of the code provided by the vendor.
I would appreciate some help from C++ experts like you guys.
=====Problem 1 ====================
For instance, the code uses reference (rMrProt) to object MrProt and notations (such as the use of “().” and “()[].”) are very confusing to me.
For instance:
ImageSamples = rMrProt.kSpace().baseResolution()
ImageSize = rMrProt.sliceSeries()[0].readoutFOV()
Some explanation of these statements would be appreciated.

All information regarding object MrProt are in “MrProt.h”, “MrProt.dll”, “MrProt.lib”. All these files have been shared at:
https://docs.google.com/open?id=0B0Ah9soYnrlIYWZkNDU2M2EtYTNmNC00YTc5LTllMzItYzIyMWU4M2ZhY2Fi
===============Problem 2 ==================================
Also, I have been trying to read MrProt.dll and MrProt.lib without any success. Only now, I came to know of dumpbin. Any help would be appreciated.


==========Problem 3 ========================================================
Another confusion that I have is related to some part of MrProt.h itself. There is a statement in MrProt.h:

class __IMP_EXP MrProt: public MrProtocolData::MrProtDataDelegate
{
typedef MrProtocolData::MrProtDataDelegate BasicImplementation;
public:
MrProt();
MrProt(const MrProt& rSource);

….
}

Here, “__IMP_EXP”, I guess that it’s some compiler specific stuff.. some decoration etc. But, I still have no idea what to make of this.

Thanks in advance,
DK
I'm assuming that the member function kSpace returns an object instance that in turn has a member function baseResolution(). The example below is no different yet perhaps more simplistic:

1
2
std::string s = "abc123";
const char *numeric = s.substr(0,s.find("123")).c_str();


I'm also guessing __IMP_EXP is a typedef somewhere in another header file. Probably declspec() which you can read about here:

http://msdn.microsoft.com/en-us/library/dabb5z75(v=vs.80).aspx
() is a function call. If something is happening after the (), it's working on the returned object (variable), not the original object. [] is the accessor operator. It (should) return an element.

Adding it all together:
ImageSize = rMrProt.sliceSeries()[0].readoutFOV();
For a certain object "rMrProt", call "sliceSeries", access the 0'th element of the return series and call readoutFOV() on it.

Possibly the easiest example to explain is if sliceSeries returned a C++ string:
1
2
3
4
5
6
class Person {
   string name;
public::
   string getName() { return name; }
};
char myChar = ++myPerson.getName()[0];

This would take the first letter of the name of myPerson, and increase it by one. It looks very confusing because the "++" is glued to myPerson, but it's actually equivalent to ++(myPerson.getName()[0]);
Thanks a lot guys.

I can not tell you how much I appreciate your help.

Could you also point me to relevant resources so that I can read interface given in .lib ?
Topic archived. No new replies allowed.