MyString.h and MyString.C
#ifndef _MY_STRING_H__
#define _MY_STRING_H__
#include < hpcxx_rts.h>
#include
class MyString {
private:
string stringValue;
string type;
string key;
long seqNum;
string details;
public:
MyString();
MyString(string stringValue, string type, string key, long seqNum, string details);
MyString(MyString &myString);
string getValue() const;
void setValue(string _source);
string getType() const;
void setType(string _type);
string getKey() const;
void setKey(string _key);
long getSequenceNum() const;
void setSequenceNum(long _seqNum);
string getDetails() const;
void setDetails(string _details);
friend std::ostream& operator<<(std::ostream &out, MyString &myString);
friend void hpcxx_pack(HPCxx_Buffer& b, MyString* myString, int count);
friend void hpcxx_unpack(HPCxx_Buffer& b, MyString* myString, int count);
};
#endif // _MY_STRING_H__
The implementation of the class MyString is provided in the file
MyString.C. The relevant code is as follows:
#include "MyString.h"
#include "../../util/HPCxx_String.h"
// empty constructor. Has to be
// provided for every objec that
// you want to serialize
MyString::MyString() {
value = string("DEFAULT");
type = string("DEFAULT");
key = string("DEFAULT");
details = string("DEFAULT");
seqNum = 0;
}
MyString::MyString(string _value, string _type, string _key, long _seqNum, string _details) {
value = _value;
type = _type;
key = _key;
seqNum = _seqNum;
details = _details;
}
// copy constructor.
// This will be called from the
// stub/skeleton
MyString::MyString(MyString &val) {
value = val.value;
type = val.type;
key = val.key;
seqNum = val.seqNum;
details = val.details;
}
string MyString::getValue() const {
return value;
}
void MyString::setSource(string _source) {
source = _source;
}
string MyString::getType() const {
return type;
}
void MyString:: setType(string _type) {
type = _type;
}
string MyString::getKey() const {
return key;
}
void MyString::setKey(string _key) {
key = _key;
}
long MyString:: getSequenceNum() const {
return seqNum;
}
void MyString:: setSequenceNum(long _seqNum) {
seqNum = _seqNum;
}
string MyString:: getDetails() const {
return details;
}
void MyString:: setDetails(String _details) {
_details = details;
}
std::ostream& operator <<(std::ostream &out, MyString &e) {
out << " < details "
<< e.getDetails()
<< " > "
<< std::endl;
return out;
}
void hpcxx_pack(HPCxx_Buffer& b, MyString* p, int count){
for(int i = 0; i < count; i++){
// pack the string value
HPCxx_String valueName((char *) p[i].getSource().c_str());
hpcxx_pack(b, &valueName, 1);
// pack the string typeName
HPCxx_String typeName((char *) p[i].getType().c_str());
hpcxx_pack(b, &typeName, 1);
// pack the key (type long)
HPCxx_String keyName((char *) p[i].getType().c_str());
hpcxx_pack(b, &keyName, 1);
// pack the sequenceNum (type long)
long seqNum = p[i].getSequenceNum();
hpcxx_pack(b, &seqNum, 1);
//pack the string details
HPCxx_String detailsName((char *) p[i].getDetails().c_str());
hpcxx_pack(b, &detailsName, 1);
}
}
void hpcxx_unpack(HPCxx_Buffer& b, MyString* p, int count){
for(int i = 0; i < count; i++){
HPCxx_String valueName;
HPCxx_String typeName;
HPCxx_String keyName;
HPCxx_String detailsName;
long seqNum;
hpcxx_unpack(b, &valueName, 1);
hpcxx_unpack(b, &typeName, 1);
hpcxx_unpack(b, &keyName, 1);
hpcxx_unpack(b, &seqNum, 1);
hpcxx_unpack(b, detailsName);
string name((char *) valueName);
string type((char *) typeName);
string key((char *) keyName);
string details((char *) detailsName);
p->setValue(name);
p->setType(type);
p->setKey(key);
p->setSequenceNum(seqNum);
p->setDetails(details);
}
}
Back to CCA Compliant HPC++
based CCAT Components
mgovinda@cs.indiana.edu
Last modified: Tue Jan 25 17:19:15 EST 2000