473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Channel List

Joe
I'm quite new to object oriented programming, so this is probably a really
basic problem that there is an obvious solution to, but anyway...

I am looking for a little advice on a good way of storing a list of channels
for a video capture application. I have a channel class that contains
information such as the tuning frequency and the channel name. I then want
to have a channel list class which is used to store the channels and their
associated channel numbers (as defined by the user).

The ChannelList class will provide functionality such as:

bool RetrieveChannel (int ChanNumber, channel &Chan) - Finds the channel
specified by the number or returns false if there is no channel in that
position.
bool AddChannel (int ChanNumber, channel Chan) - Adds the given channel
in the specified position or returns false if there is already one there
bool MoveChannel (int OldChanNumber, int NewChannelNumber) - Moves the
channel from one position to another.

I also need some way of listing all the channels and this is where I start
to get stuck. How do I actually "store" each channel object in the
ChannelList? How should I associate the channel number with each channel
object? I suppose I could add a channel number entry to the channel class,
but this doesn't seem quite right to me (in terms of keeping a strict class
heirarchy) or am I wrong?

Any help is appreciated.

TIA,
Joe.


Jul 22 '05 #1
2 2091

"Joe" <an**@anon.com> wrote in message news:t_p_b.87$bJ1.16@newsfe1-win...
I'm quite new to object oriented programming, so this is probably a really
basic problem that there is an obvious solution to, but anyway...

I am looking for a little advice on a good way of storing a list of channels for a video capture application. I have a channel class that contains
information such as the tuning frequency and the channel name. I then want
to have a channel list class which is used to store the channels and their
associated channel numbers (as defined by the user).

The ChannelList class will provide functionality such as:

bool RetrieveChannel (int ChanNumber, channel &Chan) - Finds the channel
specified by the number or returns false if there is no channel in that
position.
bool AddChannel (int ChanNumber, channel Chan) - Adds the given channel
in the specified position or returns false if there is already one there
bool MoveChannel (int OldChanNumber, int NewChannelNumber) - Moves the
channel from one position to another.

I also need some way of listing all the channels and this is where I start
to get stuck. How do I actually "store" each channel object in the
ChannelList? How should I associate the channel number with each channel
object? I suppose I could add a channel number entry to the channel class,
but this doesn't seem quite right to me (in terms of keeping a strict class heirarchy) or am I wrong?

Any help is appreciated.

TIA,
Joe.


I would suggest that you use the std::map class, it seems tailor made for
your application.

#include <map>

std::map<int, Chan> channel_map;

// adding a channel
Chan some_channel;
channel_map.insert(make_pair(123, some_channel));

// finding a channel
Chan some_channel = channel_map.find(123);

Moving a channel is slightly more complex but not too difficult. Any good
book will tell you about the std::map class which is part of the C++
standard library (aka the STL).

john
Jul 22 '05 #2

"Joe" <an**@anon.com> wrote in message news:t_p_b.87$bJ1.16@newsfe1-win...
I'm quite new to object oriented programming, so this is probably a really
basic problem that there is an obvious solution to, but anyway...

I am looking for a little advice on a good way of storing a list of channels for a video capture application. I have a channel class that contains
information such as the tuning frequency and the channel name. I then want
to have a channel list class which is used to store the channels and their
associated channel numbers (as defined by the user).

The ChannelList class will provide functionality such as:

bool RetrieveChannel (int ChanNumber, channel &Chan) - Finds the channel
specified by the number or returns false if there is no channel in that
position.
bool AddChannel (int ChanNumber, channel Chan) - Adds the given channel
in the specified position or returns false if there is already one there
bool MoveChannel (int OldChanNumber, int NewChannelNumber) - Moves the
channel from one position to another.

I also need some way of listing all the channels and this is where I start
to get stuck. How do I actually "store" each channel object in the
ChannelList? How should I associate the channel number with each channel
object? I suppose I could add a channel number entry to the channel class,
but this doesn't seem quite right to me (in terms of keeping a strict class heirarchy) or am I wrong?

Any help is appreciated.


Sounds like a job for a std::map.

For listing, see std::map::const_iterator.

-Mike
Jul 22 '05 #3

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

Similar topics

5
by: EdgarBM | last post by:
Hi, I'm working with .NET Remoting. I have a problem unregistering the server channel when I try to reuse it closing and reopening it in the same application. The second time I try to get an...
0
by: Derfel | last post by:
Hi you all I need some help with .NET remote I'm using remote service wiht TCP channel To do it, i register a client channel and a server channel like this //Client channel ChannelClient=new...
0
by: jmjacquel | last post by:
Hi all ! A new IRC Channel for the dotNet community has been created and registred tofay and is totally free. You can access this IRC channel, using any IRC client software like mIRC,...
0
by: jmjacquel | last post by:
Hi all, I new IRC Channel has been created to help Windows and macintosh developers, in any language, tool or technology. You can access this IRC channel, using any IRC client software like...
0
by: Feng | last post by:
Hi, I need my remoting server to callback to my client and I am trying to do that using delegate. While the client invoking the server OK, I am getting the following error when the server trying...
0
by: Mark | last post by:
Hi. I am using remoting to communicate between a client and server. The server remotes an object. The client calls GetObject to get the proxy to the server remoted object. The client registers...
4
by: John A Grandy | last post by:
When constructing an RSS 2.0 XML doc , should the <channel><link> element's value be 1. the url of the page the displays the content that the RSS feed describes : fox example:...
1
by: RadSurfer | last post by:
IRC Server: Freenode IRC Channel: #moderncalcs Purpose: #moderncalcs created December 2005 is intended as a real-time chat channel for anyone using any model of...
0
by: sactiw | last post by:
Hi Friends, I am trying to create a file on remote machine and then setting its file permissions to remote only thus now this file will act as a lock for me and as any body else now can't create...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
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...

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.