Static Class configuration

M

Michael

Hi,

I have defined this class to hold configuration for each field of a
message:

class field {
public:
int fieldno;
std::string name;
rtypes type;
rtypes vtype;
int length;
bool optional;
int obitmap;
ftranslation trans;
int roffset; // Configured record offset. -1 means it is
calulated
int vfp; // specifies which index for contains the length of this
field

field(fieldHeadIdx fn, char * s, rtypes t, int l, int ro, bool o,
int bp
ftranslation tl) {
fieldno = (int)fn, name = s; type = t; length = l; roffset=
ro; optio
l=o; obitmap = bp; trans = tl, vfp=-1;
}
......
}

Then hold the configuration for each field in a vector.
std::vector<field> message;

When the class is created I set the contents of the vector in the
constructor:

void msgmap::msgmap() {
headercf.push_back(field(A, "A",
H, 1, 0, false, 0, none));
headercf.push_back(field(B, "B",
H, 1, 1, false, 1, none));
headercf.push_back(field(C, "C",
I16, 2, 2, false, 2, none));
headercf.push_back(field(D, "D",
TX5, 5, 4, false, 3, none));
headercf.push_back(field(E, "E
ion", C, 22, 9, false, 4, none));
headercf.push_back(field(F, "F",
BCDX, 33, 31, false, 5, none));
headercf.push_back(field(H, "H",
C, 8, 64, false, 6, none));
headercf.push_back(field(J, "J",
H, 1, 72, false, 7, none));
headercf.push_back(field(K, "K",
H, 18, 73, false, 8, none));
.....
}

The when decoding I use the iterator to go through each field.

My question is, can I make the configuration static (compiled)? If so
how can I do it?

Thanks
Michael
 
B

Ben Pope

Michael said:
Hi,

When the class is created I set the contents of the vector in the
constructor:

void msgmap::msgmap() {
headercf.push_back(field(A, "A",

// etc.
My question is, can I make the configuration static (compiled)? If so
how can I do it?

Create a function that takes a std::vector<field>& and populates the
vector. Compile it into a ".lib".

Now, you can call that function from your constructor and pass to it,
headercf, and link against the lib.

I don't see the point, though.

Ben Pope
 
S

Sukumar Raghavan

Michael said:
Hi,

I have defined this class to hold configuration for each field of a
message:

My question is, can I make the configuration static (compiled)? If so
how can I do it?

What is static class? What is the use of it?

-rSukumar-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top