Consider two classes: foo and bar

Assignment Help C/C++ Programming
Reference no: EM13938507

Consider two classes: Foo and Bar, where Foo is a sender, and Bar the receiver.
Foo allocates 3-1 megabyte chunks of memory. The first chunk is filled with the value 0xA5, the next chunk with value 0xB5 and the third - 0xC5.

In a header file, that Foo will transmit to Bar. The struct _order_ will advise Bar of the order in which to exepct the 3 1 MiB chunks.
So now:
chunk_id size
0 1 megabyte
1 1 megabyte
2 1 megabyte

struct order { unsigned int chunk_id; unsigned int size; };
struct process{ unsigned int chunk_id; unsigned int step; };

struct header_info
{
order co[3];
process po[3];
};
header_info hdr;
hdr.co[0].chunk_id = 0;
hdr.co[0].size = 0x100000;
hdr.co[1].chunk_id = 1;
hdr.co[1].size = 0x100000;
hdr.co[2].chunk_id = 2;
hdr.co[3].size = 0x100000;

Similarily, Foo will fill out the processing order via the process struct. The process struct will advise Bar of when to 'start processing'.
So now - assume the order is as follows:

chunk_id steps
1 2
0 1
2 1

hdr.po[0].chunk_id = 1;
hdr.po[0].step = 2;
hdr.po[1].chunk_id = 0;
hdr.po[1].step = 1;
hdr.po[2].chunk_id = 2;
hdr.po[3].step = 1;

So the header - header_info (first) gets transmitted from Foo to Bar.
Upon receipt of this header Bar is aware of the order the information will arrive based on the struct _order_. Bar also knows the order to start processing based on the struct process.

So now - Foo transmits the data to Bar. i.e 1 megabyte of 0xA5. Upon receipt of the data, Bar will 'store the data', then check the initial chunk_id of order (0) versus the chunk_id of process (1). In this case, both id's aren't equivalent so Bar is available for more data. To do this. Bar informs Foo of it's availability to receive more data.

Foo then transmits the next chunk corresponding to chunk_id 1. Data values 0xB5. Upon receipt of the data, Bar - yet again, 'stores the data', then checks the chunk_id of order (1) versus the chunk_id of process (1). It's a match. Bar will now start processing. Processing here is simple. Bar will multiply the data - in this case - 0xB5 by 2. Bar will do this twice since the parameter 'step is set to 2'. Bar will 'move to the next processing chunk_id'. Per the example the id is 0. Since Bar has already received chunk_id 0 (Bar will need to do housekeeping to keep track of chunk_id's received based on the order struct), Bar will process the data. Processing here is multiplying 0xA5 by 3. We'll do this once, since step is 1.

At this point Bar informs Foo of it's availabilty to receive more data.

At this point Foo transmits data value 0xC5 to Bar. Bar will once again validate (always validate to ensure we didn't receive a bogus chunk_id) the chunk_id of 'order' with the chunk_id of 'process'. In this case both id's are 2 (recall that we're -i.e Bar - told in advance the order the data will arrive - via the order struct. That said it's up to Bar to do all the housekeeping when to start processing and if it's ok to continue processing based on previously received data). Bar once again does processing. i.e multiplies 0xC5 by 4 and doing so once (step 1)

My question: I'm interested in an implementation (working source) that'll capture the information above.

Strict C++ is required. i.e operator new (no malloc) and where necessary C++ STL containers is preferred over C style arrays.

Reference no: EM13938507

Questions Cloud

Write a main function that declares an array of 10 grocery : Write a main() function that declares an array of 10 GroceryItem objects. Assign values to all 10 items and display them.
According to the capital asset pricing model : According to the Capital Asset Pricing Model, the introduction of a risk-free asset renders the efficient frontier of efficient portfolios linear. How many portfolios of risky assets (portfolios of only risky assets) lie on the resulting Capital Mark..
Exposure stage-interaction stage-e-commerce stage : Determine whether it is in the exposure stage, interaction stage, e-commerce stage or e-business stage. Provide reasons for your answer.
What is market price of stock if market rate of return : The Extreme Reaches Corp. last paid a $1.50 per share annual dividend. The company is planning on paying $3.00, $5.00, $7.50, and $10.00 a share over the next four years, respectively. After that the dividend will be a constant $2.50 per share per ye..
Consider two classes: foo and bar : Consider two classes: Foo and Bar, where Foo is a sender, and Bar the receiver.Foo allocates 3-1 megabyte chunks of memory. The first chunk is filled with the value 0xA5, the next chunk with value 0xB5 and the third - 0xC5.
Returns on crash-n-burn computer’s stock over past five year : You’ve observed the following returns on Crash-n-Burn Computer’s stock over the past five years: 5 percent, -11 percent, 24 percent, 18 percent, and 17 percent. What was the arithmetic average return on Crash-n-Burn’s stock over this five year period..
What physically connects, or bridges, the two parts : The entire process of coordinated, voluntary, muscle contraction is summed up as excitation-contraction coupling. Why are these two things coupled, and what, specifically, is responsible for bring excitation and contraction together in the muscle ..
Why would that cause a physiological change : Why would administering bicarbonate to a patient be advisable if his blood pH was too low? What is the bicarbonate going to do to adjust the pH of the blood?
You report statistical data in this article : The article should follow similar headings to your abstract (the first four only) though you may have additional subheadings specific to your topic. It is not expected that you report statistical data in this article. You can however provide a cri..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd