C++ :: Selecting Design Pattern For Validation

Jan 21, 2015

I am looking into some design pattern which works for validation.

I thought about using strategy but not sure whether its correct or not

View 3 Replies


ADVERTISEMENT

C++ :: Design Pattern For Function Operation

Dec 11, 2014

Any design pattern allows to describe operation like the following.

MyFunctionObject f;
//Init f...
MyFunctionObject g;
//Init g...
MyFunctionObject h = f(g) + g;

[Code] .....

I'm interested in design pattern which permits to model this kind of structure, if there's of course...

View 7 Replies View Related

C++ :: Design Pattern For Dynamic Function Parameter

Oct 26, 2014

I need to design an interface(a function prototype) that takes an argument which is used to pass information.
The information can be passed by independent modules and third party softwares and hence can vary today and in future.

Basically, the function interface(arg1, info)caters a niche service to many independent applications and needs to process based on requirements passed by applications in the argument(info, in example).

I am looking for a design pattern for the function parameter - info.

Should I use a void pointer that can be casted to respective application specific class in the function ? will this be a good C++ design ?

or should I take this parameter to be a pointer to a generic abstract class that points to the respective application specific specialization ?

Do we have some design pattern to address this so as to handle other unforeseen challenges ?

View 1 Replies View Related

C/C++ :: Design Pattern For Extensible Function Parameter

Oct 26, 2014

I need to design an interface(a function prototype) that takes an argument which is used to pass information.

The information can be passed by independent modules and third party softwares and hence can vary today and in future.

Basically, the function interface(arg1, info) caters a niche service to many independent applications and needs to process based on requirements passed by applications in the argument(info, in example).

I am looking for a design pattern for the function parameter - info.

Should I use a void pointer that can be casted to respective application specific class in the function ? will this be a good C++ design ?

or should I take this parameter to be a pointer to a generic abstract class that points to the respective application specific specialization ?

Do we have some design pattern to address this so as to handle other unforeseen challenges ?

View 3 Replies View Related

C# :: Design Pattern For Task Notification System

Feb 24, 2014

I am looking a good design pattern that takes a combination of a Observer Design Pattern and Command Design Pattern.

Observer Design Pattern:

Subject - ISystem
ConcreteSubject - "Different Types of Systems"
Observer - INotifier
ConcreteObserver - "Different Types of Notifier's"

Command Design Pattern: Used to create a task. "Different Types of Task" ....

View 4 Replies View Related

C++ :: Display Triangular Pattern - infinite Loops From Input Validation

Mar 1, 2014

I am writing a program to display a triangular pattern using nested loops and user input for the size of the base and character used to generate the image. 99% of the program runs fine. However I am having trouble with some of my input validation.

When given an integer value for the base I can verify if it is within a certain range (0-80). However, when the user inters a "char" instead of an "int" the program enters an infinite loop.

Here is the piece of code giving me trouble. (I wont bother you with the entire chunk of code, I have commented out everything else to narrow down the problem bit)

// Pattern Displays
// program that asks user for the size of the base of a triangle and then generates it in a character the user chooses

#include <iostream>
#include <istream>
#include <string>
#include <cstdlib>
using namespace std;
int main () {
char escape;

[Code] ....

View 2 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# :: MVP Design Pattern On Simple Windows Form Application

Nov 1, 2014

I'm building a Windows Form Application using MVP Design Pattern; the application is quite simple, it just calculates the sum of two number; So I have a form in which are located tree textbox: number1 number2 and result, plus a button to perform the action.

interface ICalcView {
string firstN { get; set; }
string firstN {get; set;}
string result { get; set; }

[Code] ....

Do you think that is a good base to start? Any code example to understand the execution flow and how to handle events?

View 7 Replies View Related

C++ :: Singleton Design Pattern - Not All Control Paths Return A Value

Jan 17, 2013

I have the following code where I use the singleton design pattern, but I get the warning:

warning C4715: 'CM::Instance' : not all control paths return a value

Code:
CM& CM::Instance() {
DWORD dwWaitResult = WaitForSingleObject(mutex, INFINITE);
switch(dwWaitResult) {
case WAIT_OBJECT_0:

[Code] ....

How can I fix this warning?

View 4 Replies View Related

C++ :: Singleton Design Pattern - Why Copy Constructor Not Made As Private

Jul 9, 2014

I was going through Singleton design pattern and get to know that objects can be created only by static function of that class and constructors are make private.

My question is, why assignment operators are not made private through which we can create a copy of already existing object.

I tried below code and assignment works, so I have new object sc3. I know that its referring to memory of sc1 but finally I was able to create object without using static function.

Also, why copy constructor not made as private.

Below is code:

#include <iostream>
using namespace std;
class Singleton {
private:
static bool instanceFlag;

[Code] .....

View 3 Replies View Related

C++ :: Selecting Elements From A Group?

Jul 16, 2013

I have N vectors which look like this:

[1→m] [m+1→2m] [2m+1→3m] [3m+1→4m] [4m+1→5m]..... [{(N-1)m}+1→Nm]

I want to select 1 element from each vector without duplication of any combinations.

Essentially only when all combinations are done with 1st element in first vector ,only then it should move to next element in first vector say i have elements :[123] [456] [789]

my combinations should be like

147
148
149
157
158
159
167
168
169
247….

Also, i need no repetitions and only after all combinations of 1 are done only then the loop has to move to next combination ie 247 combination and so on.

i tried NCK (n choose k) command but it gave me random combinations.how should i go about it with using minimal for loops

View 1 Replies View Related

C :: Selecting The Highest Occurrence Char

Dec 14, 2014

it's not my primary language, so my code variables are in my language.

Code:

FILE *eng;
eng = fopen("eng.txt", "r");
if(eng == NULL){

[Code]....

fclose(eng); It's a piece of my code. Some explanation: From file, where is full of words under selves. I cut it on word and from word i'm printing:

1) word
2) how many letters in the word
3) word backwards and
4) viz. problem is down

For first: There i have warning: while(feof(eng) == NULL); like (comparison between pointer and integer) i don't get it. For second i have a big problem. I must from every word print the most recurring character.

For example: nondeterministically -> the most are N and I. And if, there is more then one most reccuring char, you choose one of them.

View 5 Replies View Related

C++ :: Selecting Random Color From Array

Jul 14, 2014

I have to write a program that selects a random color from an array. I used the srand (time(0)); statement but it still gives me the same color each time. Here is my code.

// Color.cpp
#include <ctime>
#include <iostream>
using namespace std;
#include <string>
#include <cstdlib>
#include "Color.h"

[Code] .....

View 7 Replies View Related

C++ ::  Selecting Arrays With Maximum Number Of Elements

Sep 10, 2013

Supposing you have a 3 or more overlapping arrays (arrays having elements in common), and you wish to select 2 or more of the arrays with the maximum number of elements but less overlap as compared to the rest of the overlapping arrays.

Eg. A[4],B[6],C[5]. A+B contains 10 elements but say the overlapping element is 3, meaning it has 7 unique element.

Also B+C=11 elements , but supposing it has 5 overlaps, it would mean it has only 6 unique elements. A+B+C=15. Supposing the overlaps are 11 then it means the unique elements are 4. Ect. So per the example, the best array options with most unique element would be A+B .

View 4 Replies View Related

C# :: Hotel Management App - Selecting Multiple Items

Jan 27, 2014

I'm writing a Hotel magmt app. I'm having difficulty on how to implement a hotel attendant selecting/secure multiple rooms(with nos) for a Customer using combobox or listbox or something. How my interface will look like and techniques.

View 1 Replies View Related

C Sharp :: Datagrid Error When Selecting A Header

Jun 5, 2012

I have the following code in the cellmouse event to get information from a selected row.

private void dt_Grid_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
datagrid.Rows[0][0] = dt_Grid.Rows[e.RowIndex].Cells[0].Value.ToString();
datagrid.Rows[0][1] = dt_Grid.Rows[e.RowIndex].Cells[1].Value.ToString();
datagrid.Rows[0][2] = dt_Grid.Rows[e.RowIndex].Cells[2].Value.ToString();

[Code]...

but when i select a collumn, i recive an error because i'm selecting a cell with the mouse and i dont have code for that selection. My question is how can i put an "if" on the beguining of the event so that he can determine if it's a header or not.

View 1 Replies View Related

Visual C++ :: Selecting Subitem In A List View Control?

Aug 7, 2013

How would I go about selecting a subitem in a listview control with just pure Win32 API? I know it's possible with MFC... but I can't use MFC for this project. Right now, when you click on a subitem , it selects only the first column of the row . I used the following by referring internet. But its not working.

HTML Code:
iSlected=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED|LVNI_SELECTED);
ListView_SetItemState(hList,iSlected,LVIS_FOCUSED|LVIS_SELECTED,0x000F);

View 5 Replies View Related

Visual C++ :: Selecting 1 Element From Each Vector Without Duplication Of Any Combination

Jul 15, 2013

I have N vectors which look like this:

[1→m] [m+1→2m] [2m+1→3m] [3m+1→4m] [4m+1→5m]..... [{(N-1)m}+1→Nm]

I want to select 1 element from each vector without duplication of any combinations. Essentially only when all combinations are done with 1st element in first vector ,only then it should move to next element in first vector.

Say i have elements :[123] [456] [789]

my combinations should be like
147
148
149
157
158
159
167
168
169
247....

Also, I cant have any repetitions and only after all combinations of 1 are done only then the loop has to move to next combination ie 247 combination and so on.

I tried NCK (n choose k) command but it gave me random combinations. How should i go about it with using minimal for loops?

View 2 Replies View Related

C# :: Overwrite Text In Masked Textbox Without Selecting Or Deleting Content?

Aug 23, 2012

I was wondering if there is a -> simple <- way to overwrite existing text in a masked texbox...

Example: I have a masked textbox, where you can insert dates. That means that you can enter only numbers for the day, month and year.

If I have to do it programmatically, there is no problem... I already have some ideas how I could do something like that, but I would like to know if VS has any parameter or any option I only have to activate.

View 6 Replies View Related

Visual C++ :: CFileDialog - Overriding Default Behavior Of Selecting Initial Directory

Oct 31, 2013

There was an "impovement" since Windows 7 in algorithm for selecting the initial directory, which is described here OPENFILENAME structure. Briefly:

Windows 7:

If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save As dialog box, the path most recently selected by the user is used as the initial directory. Otherwise, if lpstrFile contains a path, that path is the initial directory.

Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory. If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory. Otherwise, the initial directory is the personal files directory of the current user. Otherwise, the initial directory is the Desktop folder.

The problem that this behavior is not what users of my program expect. Another constraint is that I need to use old CFileDialog dialog, not Common File Dialogs. I've tried to use advises described on StackOverflow and on MSDN. This solution by EllisMiller works perfectly:

Specifying a full path (including filename) in lpstrFile. The filename of course shows up in the filename box which is annoying. I ended up using a filename of "." and adding a bit of code to clear the filename combobox once the dialog is open.

BUT I can't figure how to clear the filename combobox. I've tried to add hook procedure, enumerate windows and clear text, but this didn't work for me. So, my question is: how can I clear text in the filename combobox of CFileDialog?

View 12 Replies View Related

C++ :: Input Validation For Date?

Jul 19, 2013

How do you do the input validation for date? I used:

char rec.date[SIZE];
cout<<"date"<<endl;
cin.getline(date,SIZE);

I want the user to write in this format (mm/dd/yy)

View 3 Replies View Related

C++ :: Input Validation In For Loop

Aug 14, 2014

// PROBLEM - Use INPUT VALIDATION so number entered is positive. I can't get it to work

#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, const char * argv[]) {
// SUM OF NUMBERS
// Enter a positive integer

[Code] ....

View 2 Replies View Related

C/C++ :: Input Validation With Strings And Int

Apr 15, 2014

I am having a problem with my "void Validation :: getId()" function its suppose to get the id number from the user but when I try and type a letter to see if it catches it, it goes into this continuous loop. Also with my "string Validation :: getName(string name)" function it suppose to catch the comma in the user input for their last name , first name but doesn't catch it and still returns the name back to main function.

#include "InputValidation.h"
#include <iostream>
using namespace std;
Validation :: Validation() {
name = " ";
id = 0;

[Code] ....

View 1 Replies View Related

C++ :: Program To Check Validation Of Functions

Apr 12, 2013

I'm writing a program to check whether codes from a file are invalid, valid, inactive, or valid and active, but can't get it to work properly. The invalid codes are being found, but the other three are not. I think it may have something to do with my "active" function.

#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
using namespace std;

struct ActiveCodes {
string code;
bool flag;

[Code] ....

View 19 Replies View Related

C++ :: Email Validation Without Using Regular Expressions?

Dec 11, 2013

writing a program for "Validating the e-mail id without using regular expressions in c/c++"?

View 4 Replies View Related

C++ :: Cin Input Validation Returns Wrong

Jul 11, 2014

I have this function that is supposed to take a float as a parameter and then call the getLine() method to accept the users input. The function basically just checks to see if what the user input was of the same data type, if it is it returns the input value, if not then it keeps looping through taking new input until its correct. The problem is no matter what number you put in the output always returns as 140734799803512.

float InputValidation(){
float num;
string strInput;
while (true){
getline(cin, strInput);

[Code] ....

You also need to include <string> and <sstream>.

View 3 Replies View Related







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