473,810 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Static Class configuration

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(fieldHead Idx 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<fie ld> message;

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

void msgmap::msgmap( ) {
headercf.push_b ack(field(A, "A",
H, 1, 0, false, 0, none));
headercf.push_b ack(field(B, "B",
H, 1, 1, false, 1, none));
headercf.push_b ack(field(C, "C",
I16, 2, 2, false, 2, none));
headercf.push_b ack(field(D, "D",
TX5, 5, 4, false, 3, none));
headercf.push_b ack(field(E, "E
ion", C, 22, 9, false, 4, none));
headercf.push_b ack(field(F, "F",
BCDX, 33, 31, false, 5, none));
headercf.push_b ack(field(H, "H",
C, 8, 64, false, 6, none));
headercf.push_b ack(field(J, "J",
H, 1, 72, false, 7, none));
headercf.push_b ack(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

Feb 20 '06 #1
2 1557
Michael wrote:
Hi,

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

void msgmap::msgmap( ) {
headercf.push_b ack(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<fie ld>& 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
--
I'm not just a number. To many, I'm known as a string...
Feb 20 '06 #2

"Michael" <ch******@evolv ing.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
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-
Feb 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1451
by: K | last post by:
Hi all; I don't think this is a VC compiler question, so I am asking this here. I did hunt around the web and Stroustrup before posting, but found no references to this problem. I have a base class (BasePort) that defines an interface for subclasses (LPort, NPort). Each implementation of BasePort as LPort or NPort requires a default configuration, which is currently obtained via a static method, GetDefaultConfiguration() (henceforth,...
4
2538
by: marvind | last post by:
I think I am running into the static initialization problem but I do not understand why. I am trying to parse a configuration file. To make this parser generic I register callbacks for various section keywords in the configuration file. I want to share this map of callbacks across multiple instances of the config file (for example, when I merge two files). Whenever I introduce a new section in the configuration file, I define a new class...
4
1532
by: Steve | last post by:
I'm currently running into a problem, and I have no idea what to make of it. I have a class with nested clases and static properties that I'm using to store configuration information using a custom configuration section. When my code accesses one of the static properties the static constructors are fired, and the code goes in and pulls the data from the configuration section. In the current instance, I'm getting a connection string....
1
3095
by: wenqiang.zhou | last post by:
i only kown that static members doesnt blong to any object and it have to initialize outside class, inline is near the same as define it will replace in code.but i was puzze by the following codes. // the first example is the one i predigest from <<the c++ program language>> written by Bjarne Stroustrup #include <iostream> using namespace std; class Date
5
7243
by: Timothy Madden | last post by:
Hy static members of non-integral type need to be declared in the class, but defined (and constructed or initialized) outside the class. Like this class SystemName { public:
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10124
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.