Visual C++ :: Design Class Objects To Support Outlining Of Collection Of Items

Sep 9, 2013

I am struggling with how to efficiently design my class objects to support the outlining of a collection of items. The collection would be sorted but would also have the ability to indent and outdent individual items representing a Parent and Child relationship (see attached).

An item could indent up to 5 levels deep. A summary level would be considered a Parent while items below the summary level would be consider as children.

View 6 Replies


ADVERTISEMENT

C++ :: OpenGL - Outlining Functions Incorrectly When Used With Overlapping Objects

Oct 26, 2013

[URL] This program is creating an outline for each of the tall rectangular prisms that will eventually make up terrain in a game I am making. As you can see in the middle of the picture, the line is not fully connected, and it has smaller lines making up the bigger line like a dotted line. However, this only occurs when two objects overlap (in the part with the dotted lines, the two prisms are touching, as two of their vertices are the same).

How would I make the dotted line go a away and give me a solid line?

Here is my rendering code:
[spoiler]
glDepthFunc(GL_LESS);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_QUADS);

[Code].....

View 1 Replies View Related

C# :: Foreach And Modifying Objects In Collection

May 8, 2014

I have a class that loads the contents of a XML file into their respective object types and stores those objects in a list. Each object has its own list of objects with properties the program will later modify.

The problem I am currently having is that after looping through the objects and modifying the necessary properties the modifications do not persist. This leads me to believe I am modifying a copy of the object rather than the object I think I am modifying. I am not sure why this is happening as I believe I should be modifying the object that is referenced in the collection.

What I have tried, I started using LINQ to get the object I am looking to modify. After a little more research I don't think this can work properly due to the LINQ query returning a new object(copy of the object). Currently I am using nested foreach loops which still are not behaving the way I expect as the properties I am setting are not making their way back to the original object.

The PopulateLogSheet() in the following class is where the problem loop is.

class ChillerCheckCollection {
public List<Chiller> chillers = new List<Chiller>();
public void LoadChillers(string filePath) {
var availableChillers = (from chiller in Xdocument.Load(filePath).Descendants("chiller")
select new Chiller

[Code] ....

And here are the other classes referenced in the above class.

class Chiller {
public IEnumerable<LogSheet> chillerLogSheet = new List<LogSheet>();
public int chillerID;

[Code] ....

View 2 Replies View Related

C++ :: Delegate Class - Support Void Class Function With No Parameters

Jun 22, 2013

I'm trying to write a simple Delegate class with a Bind() and Invoke() function. For now it only needs to support a void class function with no parameters. I've searched around and found quite a few exmaples, though, those class are heavily templated and I lose track trying to simplify it.

So far my code is following:

Code:
#include <windows.h>
class Test {
public:
void DoSomething() {
MessageBox(NULL, L"Test::DoSomething!", NULL, 0);

[Code] ....

The part I am having difficulty with is assigning &Test::DoSomething to the m_Callback variable.

&tObject::DoSomething works, yet _Callback which I pass &Test::DoSomething to does not work.

Also, why does the following line work:

Code:
m_Callback = &Wrapper<tObject, &tObject::DoSomething>;

When wrapper is like:

Code:
template<class tObject, void (tObject::*Func)()>
void Wrapper(void* Object)

Should it not be Wrapper<class-typename, parameter-1>(parameter-2) // This currently creates an error

View 2 Replies View Related

C# :: WPF Collection Not Updating With Observable-collection?

Mar 19, 2014

I have a WPF project where I am using the entity framework. I have switched all my collection types to ObservableCollection and I am also using the PropertyChanged event. The only way my collections update is if I close the application then restart it. I got to the point where I just created a new application with 1 entity and 1 combobox to display a collection and I still can't get the collection to update. In my code below I am calling the AddCustomer method to add a customer name to the Customers ObservableCollection without success.

class ViewModel:INotifyPropertyChanged {
Model1Container context = new Model1Container();
public ViewModel() {
Customers = new ObservableCollection<Customer>();
UpDate();

[code]....

View 9 Replies View Related

C# :: Get Collection Of Data From Database Through SQL Class?

Apr 26, 2015

In my WPF application i have a SQL class which i am trying to use to store all of my SQL queries so far this is working fine for when i want to return one piece of data like this:

public string GetEnquiry_ContactName(int EnquiryID) {
string ContactName = null;
//Try to do the following if not then show the error message.
try {
//Create the SQL Connection
SqlConnection cn = new SqlConnection(Models.M_GlobalVariables.GetConnection);

[Code] ....

But if i want to return a collection of data like this:

public ObservableCollection<CompanyNames> GetCompanyNames () {
public class CompanyNames {
public string CompanyName { get; set; }
public CompanyNames(string name) {
CompanyName = name;

[Code] ....

It does not work and i get 'Not all code paths return a value' and ''List_CompanyNames' is a 'property' but is used like a 'type''. But if i have it in my ViewModel like this:

//Code for the 'Company Names' dropdown box
public class CompanyNames {
public string CompanyName { get; set; }
public CompanyNames(string name) {
CompanyName = name;

[Code] ....

It works absolutely fine but the whole point of my SQL class is to have all my SQL code in that class instead of some of it in the ViewModel.

View 14 Replies View Related

Visual C++ :: Use CFormView As Main View Without Using Document Support?

Jul 17, 2013

Is it possible to use a CFormView as the main view without using document support. IE pointing CWinApps m_pMainWnd to the CFrameWnd derived MainFrame and attaching the CFormView from there. It does not seem to be working and I was wondering before I waste any more time on the solution if it is even possible. I know it is an easy solution if I create a true SDI application however I have no use for documents in this application.

View 9 Replies View Related

C++ :: Game Design Practice For Accessing Container Of Game Objects

Dec 21, 2014

I'm working on my first video game. So far I have a few classes in the game starting with the Game class which includes a list of GameObjects (another class). There are several classes that inherit from GameObjects used to implement things like bullets, explosions, various enemy types, etc.

The game essentially iterates through the list of GameObjects to update/render them. I would like to provide access to the Game's list of GameObjects inside another class (like the Bullet class) so I can put new objects on the list. For example, when a bullet hits, I want to add an explosion to the Game's GameObject list it can be updated/rendered.

How this should be setup? I was considering adding a pointer to the Game or GameObject list to the GameObject class (and methods to access it), but I was wondering if there is a better way to set this up?

View 4 Replies View Related

C++ :: How To Design Optimal Style Class

Jun 8, 2014

I want to write a command line parsing library that is very flexible in terms of parsing style but I'm not able to design a mechanism that satisfies this requirements.

Generally i want to have a class that contains all the necessary information about how the command line has to be parsed.

Code:
// draft
class style {
public:
enum class type { // the basic style type

[Code] ....

Need completing the draft shown above, because for every basic style type there is an own set of extensions that applies only to this one specific style type.

Code:
// how a style object should be created
style parsing_style(style::type::posix, style::extension::gnu|style::extension::subcommand);

How to design the class. (using c++11 features like std::enable_if is fine)

View 10 Replies View Related

C++ :: Design Class That Can Be Used That Can Represent A Parabola

Apr 24, 2013

The program is supposed to design a class that can be used that can represent a parabola.

Code:

#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <cstring>

using namespace std;
class Parabola {
public:
Parabola( double, double, double );

[Code] .....

View 3 Replies View Related

C++ :: How To Design A Smart Pointer Class

Nov 11, 2014

smart pointer class is the one that take in charge of release allocated resource when itself destroyed.

recently,i want design a smart pointer class, it take in charge of release resource allocated by new or new[].

my problem how to design destructor, you should determine the pointer ptr is pointer an array or a single object.

the structure of this smart point class may be:

template<class T>;
class smart_pointer{
public:
smart_pointer(T* p):ptr(p){};
~smart_pointer(){

[Code] ......

View 6 Replies View Related

C# :: Running A Class At Design Time

Aug 7, 2014

I have a Class called 'DataManager' which contains a list of my 'DataItem' objects (this are created by an XML file).

I have also created some custom controls which, among other things, has a property to link it to a "DataItem" object.

My question is, is it possible to create an instance of my DataManager class at design time (which runs all the code as it would at run time to create all the DataItems from the XML)?

I want to do this so that I can update my DataItem property in my custom controls to use a UITypeEditor which then allows me to link to a DataItem at design time.

View 4 Replies View Related

C++ :: State Design Pattern - Calling A Class Member

Oct 17, 2013

In the following code example of the State Design Pattern, in the main code at the bottom it defines an instance of class Machine, and then calls Machine::off;. Why doesn't it instead call fsm.off;?

Machine fsm;

Machine::off;

Then I tried imitating that by adding a class Abba, and then doing:

Abba a;
Abba::DoStuff();

but that didn't work. Why?

Full code example:

// StatePattern.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;
class Machine {
class State *current;

[Code] ....

View 3 Replies View Related

C++ :: Adding Items From File To Vector Of Class

Oct 10, 2013

how to add a list of information from a file to a vector of a class. Here is my code:

Champion_Info.h
#ifndef CHAMPION_INFO_H_INCLUDED
#define CHAMPION_INFO_H_INCLUDED
#include <vector>
#include <string>

[Code].....

View 6 Replies View Related

C++ :: Design A Class To Store Measurements - Unresolved Externals Error

Jul 8, 2013

Assignment: Design a class to store measurements. The class should have two data items, feet and inches, both integers. The class must make sure that the number of inches never gets below zero or above 11. If inches is outside that range, adjust feet accordingly. (Yes this means feet might be a negative number.)

Create a default constructor and one which receives one integer, a number of inches.

Overload the following operators: addition, subtraction, equality, inequality, incrementation (both pre and post) (should add one to inches), and output (in the form of: F’I”)

Code:
#include <iostream>
using namespace std;
class measurements {

private:
int inches;
double feet;

[Code] ....

I am getting a LNK2019 error and an LNK1120 errors:

Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

Error 2 error LNK1120: 1 unresolved externals

View 3 Replies View Related

C Sharp :: How To Design / Write Global Config Class That Can Be Inherited

Jan 31, 2013

I need to create a GlobalConfig class. But I want to derive from it in another class.

Here's an example:

public class BaseConfig {
 public string GlobalPath {get; set;}
}  
public class ConfigA :  BaseConfig  {
 public string pathA {get; set;}
}  
public class ConfigB :  ConfigA  {
 public string pathB {get; set;}
}

The idea behind is that I don't want to write the code multiple times and what's more important in class ConfigA I want to set GlobalPath and have access to it in ConfigB.

In other word I want class ConfigB to have a property GlobalPath which was set in class ConfigA.

To clarify I want to have only one object of Config in memory.

When I set BaseConf.GlobalPath to 'A', I want to access it from ConfigB.GlobalPath and also get 'A'.

I always design GlobalConfig as a static class, but static classes can't be inherited. So I tried to implement Singleton Pattern, but ConfigA can't find constructor of class BaseConfig because it's private.

View 1 Replies View Related

C++ :: Design Image Class Which Should Work With Various Data Types (Multidimensional)

Dec 2, 2013

I have been thinking about this all day and I am yet to come up with a good solution. So, I need to design an image class which should work with various data types (int, float, double etc.) and can also be multidimensional (2, 3, 4, 5). So, what I did was generate a template image class as follows:

Code:
template<typename T, int dimensions=3>
class Image {
private:
T * data;
};

Anyway, now I have various image formats that I want to support, so the easy thing to do is create a Factory sort of object which will call eventually generate the correct image.

So I want to create various image classes called ImageType1, ImageType2 etc. which will take the input image and generate the correct Image object. However, I do not want these objects to be templated because they need to be passed from functions and be used in a generic way.

So, at run time I will need to be able to do this…

Code:
class ImageType {
public:
ImageType() {
PolymorphicImage * image = new Image<float, 3>();
}
private:
PolymorphicImage * image;
};

So, I want my ImageType classes to contain the Image object and be able to generate it with the right template arguments at run time. Is there any way to do this without having multiple specialised definitions for ImageType?

View 2 Replies View Related

C/C++ :: Design / Implement And Test A Class That Represents Time In Minutes And Seconds

Nov 29, 2014

Design, implement, and test a class that represents an amount of time in minutes and seconds. The class should provide a constructor that sets the time to a specified number of minutes and seconds. The default constructor should create an object for a time of zero minutes and zero seconds. The class should provide observers that return the minutes and the seconds separately, and an observer that returns the total time in seconds (minutes x 60 + seconds). Boolean comparison observers should be provided that test whether two times are equal, one time is greater than the other, or one time is less than the other. (You may use RelationType and function ComparedTo if you choose). A function should be provided that adds one time to another, and another function that subtracts one time from another. The class should not allow negative times (subtraction of more time than is currently stored should result in a time of 0:00). This class should be immutable.

this is one of my main errors: Error1error C2653: 'Time' : is not a class or namespace namec:userskdesktop
oane statecisp 1610visual studioschapter 12 assignmentchapter 12 assignmentchapter 12 assignment.cpp131Chapter 12 Assignment

//The implementation file ImplFileTimeClassAsgnt.cpp:

#include "Time.h"
#include <iostream>
using namespace std;
Time::Time() {
mins = 0;
secs = 0;

[Code] ....

View 2 Replies View Related

Visual C++ :: Custom Control Library Design?

Mar 15, 2015

i want to design a custom control (Ui widget library) , this library can be used by any IDe developer to develop his UI.

how to design a custom control library and plug in.

View 11 Replies View Related

Visual C++ :: How Many Items Exist In A Dialog Box

Sep 11, 2013

I was wondering how can we know how many items exist in a dialogbox? If there any way that i can get the items ID in a dialogbox by having just the dialogbox's object or handler? Or any way that we can get a dialogbox content by coding.

View 6 Replies View Related

C++ :: Deleting Array Of Derived Class Objects Through Base Class Pointer

Mar 21, 2015

In this book, item 3 is about never treat arrays polymorphically. In the latter part of this item, the author talks about the result of deleting an array of derived class objects through a base class pointer is undefined. What does it mean? I have an example here,

Code:
class B
{
public:
B():_y(1){}
virtual ~B() {
cout<<"~B()"<<endl;

[Code] ....

This sample code does exactly what I want. So does the author mean the way I did is undefined?

View 1 Replies View Related

C++ :: Creating Array Of Pointers To Base Class To Point To Derived Class Objects Dynamically

Jan 16, 2013

Please consider the following code :

#include <iostream>
using namespace std;
class superclass;
class subclass1;
class subclass2;

[Code] ....

As you can see I want to create a dynamically allocated storage of references to a parent class each of which can then point to a child class, how ever I do not know how to extract the child class out again from that array so i may access its variable b.

View 2 Replies View Related

C++ :: Initializing Inner-objects Of Base Class From Driven-class Constructor

Jan 6, 2015

Let's say I have a Car object , and it contains inner Engine object.

Code:
struct Car{
Engine mEngine;
};

In order to initialize the engine object NOT by the default constructor (if it has any) , we use initialization semantics:

Code:
Car::Car:
mEngin(arg1,arg2,...)
{
other stuff here
}

Now it gets tricky: Let's say a Car objects has 10 inner objects, each object has about 5 variables in it . Car is a base class for , e.g. , Toyota class. you don't want the Car class to have a constructor with 50 arguments. Can the inner objects of Car be initialized from the base class , e.g. Toyota?

Code:
class Toyota:
Car(...),
mEngine(...),
mGear(..)
{
...
};

The other options are:
1) like said , create a Car constructor which gets 50 arguments, then initialize Car as whole from Toyota - the code becomes less readable and less intuitive
2) Car constructor which get built-objects as arguments and initialize the inner objects with copy constructor . the code gets more readable but then you create many excess objects .

View 5 Replies View Related

Visual C++ :: Control For Owner-drawing Items With 1 Or 2 Columns?

Jan 22, 2014

I want to show a list of graphical items in 1 or 2 columns (user selected). I will draw the items (owner-draw). I tried many hours today to find a solution with clistctrl. Is it possible to make it with clistctrl?

View 14 Replies View Related

Visual C++ :: Finding Items (strings) In Multiple Lists

Mar 12, 2013

Im working on a script compiler and i need to handle different types of data. Actually different categories of items.

Let's say i have two categories: cat's and bird's. They are different and stored in different lists. And let's say there is a simple command: GIVE_FOOD_TO(animal_type, food_type) Animal type here can be either from birds category or cat's category.

And also let's say user gives command: GIVE_FOOD_TO(cat1, fish)
and also for example: GIVE_FOOD_TO(bird1, birdfood)

Variable names could be anything, but im storing each variable name in std::map so later i can figure out with what animal current command is used.

When im parsing the script then i must know if user supplied either cat or bird. If i just would have cat's or bird's category then i would have only 2 lists and not a big problem to loop through either cats list or birds list and find out in what list the "cat1" is or in what particular list the "bird1" is. It would be in one or another.

But i have a lot of categories and looping through all of these lists (or std::maps) is slow and doesn't seem like a good. Just to find out in what list it's stored. I can't rely on variable names, they could be anything.

Big picture atm:

1) I have one BIG box which stores all of the categories

2) When i need to find out to which category the variable (animal_type) point's to i must get it quickly, dunno, std::map in std::map or something?

What i need basically is: I have different lists (each one is just a category for either birds or cats in this example) And when i have variable name, i must find out quickly in what particular category this item is stored. So i can work with it.

View 4 Replies View Related

Visual C++ :: How To Use CListCtrl For Show Multiple DialogBoxs Like Items In Icon View

Jan 15, 2014

i can write a mfc program to make a Thumbnail view with image but can not this when change image with CDialogBox.

Thumbnail view with image(chart) like this:

for (int i=0;i<10;i++) {
CChartContainer *cc = new CChartContainer();
if(cc->m_frmWin->Create(_T(""),
WS_CHILD|WS_VISIBLE|SS_BITMAP, rc,
this,idDyn)) {
}
}

how can i write mfc program to make a Thumbnail view of CDialogBoxs?

do i can use CListCtrl for show multiple DialogBoxs?

View 13 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved