Search Results

Search found 9771 results on 391 pages for 'equivalence classes'.

Page 40/391 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • Will this static class break in a multi user scenario ?

    - by Perpetualcoder
    Say I make a static class like following with an extension method: public static class MyStaticExtensionClass { private static readonly Dictionary<int, SomeClass> AlgoMgmtDict = new Dictionary<int, SomeClass>(); public static OutputClass ToOutput(this InputClass input) { // clears up the dict // does some kind of transform over the input class // return an OutputClass object } } In a multi user system, will the state management dictionary fail to provide correct values for the transform algorithm? Will a regular class be a better design or shoving the Dictionary inside the method a better design?

    Read the article

  • Should I call class destructor in this code?

    - by peterg
    I am using this sample to decode/encode some data I am retrieving/sending from/to a web server, and I want to use it like this: BOOL HandleMessage(UINT uMsg,WPARAM wParam,LPARAM lParam,LRESULT* r) { if(uMsg == WM_DESTROY) { PostQuitMessage(0); return TRUE; } else if(uMsg == WM_CREATE) { // Start timer StartTimer(); return TRUE; } else if(uMsg == WM_TIMER) { //get data from server char * test = "test data"; Base64 base64; char *temp = base64.decode(test); MessageBox(TEXT(temp), 0, 0); } } The timer is set every 5 minutes. Should I use delete base64 at the end? Does delete deallocates everything used by base64?

    Read the article

  • Java/MySQL: Working with data in classes

    - by skiwi
    What is the best way to deal with accessing/modifying tables in a database? I have read about the Data Access Object approach, but none of the resources I have found so far indicate a clear implementation of it. So assume you have a database with a table called accounts that has columns id, name, password and email. How would you properly access it within Java? I mean most people know how to do SQL statements, but that is not really the point. I hope people here can be of help. Regards.

    Read the article

  • Right way to return proxy model instance from a base model instance in Django ?

    - by sotangochips
    Say I have models: class Animal(models.Model): type = models.CharField(max_length=255) class Dog(Animal): def make_sound(self): print "Woof!" class Meta: proxy = True class Cat(Animal): def make_sound(self): print "Meow!" class Meta: proxy = True Let's say I want to do: animals = Animal.objects.all() for animal in animals: animal.make_sound() I want to get back a series of Woofs and Meows. Clearly, I could just define a make_sound in the original model that forks based on animal_type, but then every time I add a new animal type (imagine they're in different apps), I'd have to go in and edit that make_sound function. I'd rather just define proxy models and have them define the behavior themselves. From what I can tell, there's no way of returning mixed Cat or Dog instances, but I figured maybe I could define a "get_proxy_model" method on the main class that returns a cat or a dog model. Surely you could do this, and pass something like the primary key and then just do Cat.objects.get(pk = passed_in_primary_key). But that'd mean doing an extra query for data you already have which seems redundant. Is there any way to turn an animal into a cat or a dog instance in an efficient way? What's the right way to do what I want to achieve?

    Read the article

  • Eclipse outline of Prototype javascript classes

    - by Rob Agar
    Is there a way to show the structure of a javascript class declared using Prototype's Class.create function in the Eclipse outline view? The declarations look like: var Foo = Class.create({ bar: function() { ... }, baz: function() { ... }, }); At the moment all I get is "Foo:". (A google search turned up http://marketplace.eclipse.org/content/prototypewtp, but the link to the plugin homepage is dead)

    Read the article

  • Dynamic Operator Overloading on dict classes in Python

    - by Ishpeck
    I have a class that dynamically overloads basic arithmetic operators like so... import operator class IshyNum: def __init__(self, n): self.num=n self.buildArith() def arithmetic(self, other, o): return o(self.num, other) def buildArith(self): map(lambda o: setattr(self, "__%s__"%o,lambda f: self.arithmetic(f, getattr(operator, o))), ["add", "sub", "mul", "div"]) if __name__=="__main__": number=IshyNum(5) print number+5 print number/2 print number*3 print number-3 But if I change the class to inherit from the dictionary (class IshyNum(dict):) it doesn't work. I need to explicitly def __add__(self, other) or whatever in order for this to work. Why?

    Read the article

  • Testing for the existence of a field in a class

    - by Brett
    Hi, i have a quick question. I have a 2D array that stores an instance of a class. The elements of the array are assigned a particular class based on a text file that is read earlier in the program. Since i do not know without looking in the file what class is stored at a particular element i could refer to a field that doesn't exist at that index (referring to appearance when an instance of temp is stored in that index). i have come up with a method of testing this, but it is long winded and requires a second matrix. Is there a function to test for the existence of a field in a class? class temp(): name = "default" class temp1(): appearance = "@"

    Read the article

  • Help with psudo classes in CSS

    - by Anil Namde
    <a class="success" href="javascript:void(0)"></a> //CSS for setting background for above link a.success:hover{ //set background image } What my intent is to change the class of link on server side based on success/fail and set icon for the link accordingly. But above CSS is not working as expected. Can someone plz help with this.

    Read the article

  • Making Global Struct in C++ Program

    - by mosg
    Hello world! I am trying to make global structure, which will be seen from any part of the source code. I need it for my big Qt project, where some global variables needed. Here it is: 3 files (global.h, dialog.h & main.cpp). For compilation I use Visual Studio (Visual C++). global.h #ifndef GLOBAL_H_ #define GLOBAL_H_ typedef struct TNumber { int g_nNumber; } TNum; TNum Num; #endif dialog.h #ifndef DIALOG_H_ #define DIALOG_H_ #include <iostream> #include "global.h" using namespace std; class ClassB { public: ClassB() {}; void showNumber() { Num.g_nNumber = 82; cout << "[ClassB][Change Number]: " << Num.g_nNumber << endl; } }; #endif and main.cpp #include <iostream> #include "global.h" #include "dialog.h" using namespace std; class ClassA { public: ClassA() { cout << "Hello from class A!\n"; }; void showNumber() { cout << "[ClassA]: " << Num.g_nNumber << endl; } }; int main(int argc, char **argv) { ClassA ca; ClassB cb; ca.showNumber(); cb.showNumber(); ca.showNumber(); cout << "Exit.\n"; return 0; } When I`m trying to build this little application, compilation works fine, but the linker gives me back an error: 1>dialog.obj : error LNK2005: "struct TNumber Num" (?Num@@3UTNumber@@A) already defined in main.obj Is there exists any solution? Thanks.

    Read the article

  • Define the base class or base functionality of a dynamic proxy (e.g. Castle, LinFu)

    - by Graham
    Hi, I've asked this in the NHibernate forumns but I think this is more of a general question. NHibernate uses proxy generators (e.g. Castle) to create its proxy. What I'd like to do is to extend the proxy generated so that it implements some of my own custom behaviour (i.e. a comparer). I need this because the following standard .NET behaviour fails to produce the correct results: //object AC is a concrete class collection.Contains(AC) = true //object AP is a proxy with the SAME id and therefore represents the same instance as concrete AC collection.Contains(AP) = false If my comparer was implemented by AP (i.e. do id's match) then collection.Contains(AP) would return true, as I'd expect if proxies were implicit. (NB: For those who say NH inherits from your base class, then yes it does, but NH can also inherit from an interface - which is what we're doing) I'm not at all sure this is possible or where to start. Is this something that can be done in any of the common proxy generators that NH uses?

    Read the article

  • CakePHP: Interaction between different files/classes

    - by Alexx Hardt
    Hey, I'm cloning a commercial student management system. Students use the frontend to apply for lectures, uni staff can modify events (time, room, etc). The core of the app will be the algortihm which distributes the seats to students. I already asked about it here: How to implement a seat distribution algorithm for uni lectures Now, I found a class for that algorithm here: http://www.phpclasses.org/browse/file/10779.html I put the 'class GA' into app/vendors. I need to write a 'class Solution', which represents one object (a child, and later a parent for the evolutionary process). I'll also have to write functions mutate(), crossover() and fitness(). fitness calculates a score of a solution, based on if there are overbooked courses etc; crossover() is the crazy monkey sex function which produces a child from two parents, and mutate() modifies a child after crossover. Now, the fitness()-function needs to access a few related models, and their find()-functions. It evaluates a solution's fitness by checking e.g. if there are overbooked courses, or unfulfilled wishes, and penalizes that. Where would I put the ga.php, solution.php and the three functions? ga.php has to access the functions, but the functions have to access the models. I also don't want to call any App::import()'s from within the fitness()-function, because it gets called many thousand times when the algorithm runs. Hope someone can help me. Thanks in advance =)

    Read the article

  • C++ converting back and forth from derived and base classes

    - by user127817
    I was wondering if there is a way in C++ to accomplish the following: I have a base class called ResultBase and two class that are Derived from it, Variable and Expression. I have a few methods that do work on vector<ResultBase> . I want to be able to pass in vectors of Variable and Expression into these methods. I can achieve this by creating a vector<ResultBase> and using static_cast to fill it with the members from my vector of Variable/Expression. However, once the vector has run through the methods, I want to be able to get it back as the vector of Result/Expression. I'll know for sure which one I want back. static_cast won't work here as there isn't a method to reconstruct a Variable/Expression from a ResultBase, and more importantly I wouldn't have the original properties of the Variables/Expressions The methods modify some of the properties of the ResultBase and I need those changes to be reflected in the original vectors. (i.e. ResultBase has a property called IsLive, and one of the methods will modify this property. I want this IsLive value to be reflected in the derived class used to create the ResultBase Whats the easiest way to accomplish this?

    Read the article

  • get_by_id method on Model classes in Google App Engine Datastore

    - by tarn
    I'm unable to workout how you can get objects from the Google App Engine Datastore using get_by_id. Here is the model from google.appengine.ext import db class Address(db.Model): description = db.StringProperty(multiline=True) latitude = db.FloatProperty() longitdue = db.FloatProperty() date = db.DateTimeProperty(auto_now_add=True) I can create them, put them, and retrieve them with gql. address = Address() address.description = self.request.get('name') address.latitude = float(self.request.get('latitude')) address.longitude = float(self.request.get('longitude')) address.put() A saved address has values for >> address.key() aglndWVzdGJvb2tyDQsSB0FkZHJlc3MYDQw >> address.key().id() 14 I can find them using the key from google.appengine.ext import db address = db.get('aglndWVzdGJvb2tyDQsSB0FkZHJlc3MYDQw') But can't find them by id >> from google.appengine.ext import db >> address = db.Model.get_by_id(14) The address is None, when I try >> Address.get_by_id(14) AttributeError: type object 'Address' has no attribute 'get_by_id' How can I find by id? EDIT: It turns out I'm an idiot and was trying find an Address Model in a function called Address. Thanks for your answers, I've marked Brandon as the correct answer as he got in first and demonstrated it should all work.

    Read the article

  • Continuing JavaScript "classes" - enums within

    - by espais
    From a previous question, I have the following: So I have implemented a resource class, now I'd like to continue extending it and add all my constants and enums (or as far as JS will allow...). This is what I currently have: var resources = { // images player : new c_resource("res/player.png"), enemies : new c_resource("res/enemies.png"), tilemap : new c_resource("res/tilemap.png") }; And this is what I would like to continue to extend it to: var resources = { // images player : new c_resource("res/player.png"), enemies : new c_resource("res/enemies.png"), tilemap : new c_resource("res/tilemap.png"), // enums directions : {up:0, right:1, down:2, left:3}, speeds : {slow: 1, medium: 3, fast: 5} }; ... function enemies() { this.dir = resources.directions.down; // initialize to down } When I attempt to access resources.directions.up, my JS script goes down in a flaming pile of burning code. Are enums allowed in this context, and if not, how can I properly insert them to be used outside of a normal function? I have also tried defining them as global to a similar effect. edits: fixed the comma...that was just an error in transcribing it. When I run it in Firefox and watch the console, I get an error that says resources is undefined. The resources 'class' is defined at the top of my script, and function enemies() directly follows...so from what I understand it should still be in scope...

    Read the article

  • Am I trying to Implement Multiple Inheritance. How can I do this.

    - by Shantanu Gupta
    I have created a class say A which has some functions defined as protected. Now Class B inherits A and class C inherits B. Class A has private default constructor and protected parameterized constructor. I want Class B to be able to access all the protected functions defined in Class A but class C can have access on some of the functions only not all the functions and class C is inheriting class B. How can I restrict access to some of the functions of Class A from Class C ? EDIT: namespace Db { public Class A { private A(){} protected A(string con){assign this value} protected DataTable getTable(){return Table;} protected Sqlparameters setParameters(){return parameter;} } } namespace Data { public Class B:A { protected B():base("constring"){} protected DataTable output(){return getTable();} protected sqlparameter values(param IDataParameter[] parameter){} } } namespace Bsns { public Class C:B { protected C():base(){} protected DataTable show() {return values(setparameter());} } } EDIT I think what I am trying to do here is Multiple inheritance. Please check. Class A { //suppose 10 functions are declared } Class B:A { //5 functions declared which are using A's function in internal body } Class C:B { //using all functions of B but require only 4 functions of A to be accessible by C. }

    Read the article

  • Implementing implicitly shared classes outside of Qt

    - by Timothy Baldridge
    I'm familiar with the way Qt uses D-pointers for managing data. How do I do this in my code? I tried this method: 1) move all data into a struct 2) add a QAtomicInt to the struct 3) implement a = operator and change my constructor/deconstructor to check-up on the reference count. The issue is, when I go to do a shallow copy of the object, I get an error about QObject declaring = as private. How then do I accomplish this? Here's an example of my copy operator: HttpRequest & HttpRequest::operator=(const HttpRequest &other) { other.d->ref.ref(); if (!d->ref.deref()) delete d; d = other.d; return *this; } Am I going about this the wrong way?

    Read the article

  • XSD.exe question about include files and code generation

    - by Roger Willcocks
    If you have an XSD with an includes reference. Is it possible to generate 2 separate class files. 1 for the XSD, and 1 for the included XSD? My Scenario 4 XSDs, each of which share 15-20 element definitions in common. Rather than maintaining, I'd like to end up with the 4 XSDs all referencing a fifth file with the common definitions, and code generating 5 .cs files to use.

    Read the article

  • Haskell type classes and type families (cont'd)

    - by Giuseppe Maggiore
    I need some help in figuring a compiler error which is really driving me nuts... I have the following type class: infixl 7 --> class Selectable a s b where type Res a s b :: * (-->) :: (CNum n) => (Reference s a) -> (n,(a->b),(a->b->a)) -> Res a s b which I instance twice. First time goes like a charm: instance Selectable a s b where type Res a s b = Reference s b (-->) (Reference get set) (_,read,write) = (Reference (\s -> let (v,s') = get s in (read v,s')) (\s -> \x -> let (v,s') = get s v' = write v x (_,s'') = set s' v' in (x,s''))) since the type checker infers (-->) :: Reference s a -> (n,a->b,a->b->a) -> Reference s b and this signature matches with the class signature for (--) since Res a s b = Reference s b Now I add a second instance and everything breaks: instance (Recursive a, Rec a ~ reca) => Selectable a s (Method reca b c) where type Res a s (Method reca b c) = b -> Reference s c (-->) (Reference get set) (_,read,write) = \(x :: b) -> from_constant( Constant(\(s :: s)-> let (v,s') = get s :: (a,s) m = read v ry = m x :: Reference (reca) c (y,v') = getter ry (cons v) :: (c,reca) v'' = elim v' (_,s'') = set s' v'' in (y,s''))) :: Reference s c the compiler complains that Couldn't match expected type `Res a s (Method reca b c)' against inferred type `b -> Reference s c' The lambda expression `\ (x :: b) -> ...' has one argument, which does not match its type In the expression: \ (x :: b) -> from_constant (Constant (\ (s :: s) -> let ... in ...)) :: Reference s c In the definition of `-->': --> (Reference get set) (_, read, write) = \ (x :: b) -> from_constant (Constant (\ (s :: s) -> ...)) :: Reference s c reading carefully the compiler is telling me that it has inferred the type of (--) thusly: (-->) :: Reference s a -> (n,a->(Method reca b c),a->(Method reca b c)->a) -> (b -> Reference s c) which is correct since Res a s (Method reca b c) = b -> Reference s c but why can't it match the two definitions? Sorry for not offering a more succint and standalone example, but in this case I cannot figure how to do it...

    Read the article

  • .NET Deployment of Interface/Classes for Command Pattern Question

    - by Jonno
    In theory I would like to produce 2 projects: 1) Asp.net (Sever A) 2) DAL running (Server B) I would like to utilise command objects to comunicate with the DAL. ASP.net instantiates a command class e.g. CmdGetAllUsers which impliments IMyCommand interface and sends it to the DAL (using ASMX or WCF). My question is: Would the class definition of CmdGetAllUsers need to exist on the DAL server? Or would having the interface definition be enough? My goal is to reduce the need to redeploy the DAL code, and have it as a fairly simple pass-through layer. Many thanks for your time.

    Read the article

  • Python:How to override inner class methods if the inner class is defined as a property of the top cl

    - by Maddy
    I have a code snippet like this class A(object): class b: def print_hello(self): print "Hello world" b = property(b) And I want to override the inner class 'b'(please dont worry about the lowercase name) behaviour. Say, I want to add a new method or I want to change an existing method, like: class C(A): class b(A.b): def print_hello(self): print "Inner Class: Hello world" b = property(b) Now if I create C's object as c = C(), and call c.b I get TypeError: 'property' object is not callable error. How would I get pass this and call print_hello of the extended inner class? Disclaimer: I dont want to change the code for A class.

    Read the article

  • Android: passing paramters between classes

    - by Yang
    I have a class2 which is involved by class1 when clicks are made. I have to pass some parameters/objects from class1 to class2. I only know the standard way which does not have an option of passing parameters. // launch the full article Intent i = new Intent(this, Class2.class); startActivity(i);

    Read the article

  • Accessing non-related entities in LinqToSql entity classes

    - by Chris Johnson
    In LinqToSql, if I want to access a non-related entity in an entity partial class, how do I do this without creating a new DataContext? Here's the scenario: I have the tables Client, IssueType and ClientIssueType. A Client may specify a list of IssueTypes if they do not want to use the default IssueTypes. I have the default IssueTypes in the ClientIssueType table with a ClientId of null. In my Client partial I'd like to try to retrieve all IssueTypes, and if none are found, return all default IssueTypes. The only way I can see of accessing the IssueTypes with a null ClientId is by accessing the table through a new DataContext, which is problematic once I want to start assigning them to Issues. Where am I going wrong?

    Read the article

  • transfering a container of data to different classes

    - by user340699
    I am passing a vector of bids from Trader class to Simulator class.which class then passes it on to the auctioneer class.something seems messed up, can anyone spot it please. Below is part of the code: Error: 199 expected primary-expression before '&' token //Class of Origin of the vector. class Trader { private: int nextBidId; public: Trader(); ~Trader(){}; Bid getNextBid(); Bid getNextBid(int trdId, int qty, int price, char type); void loadRange( vector <Bid> & bids ) {} ; void loadRange(BidList &, int trdId, int qty, int price, char type, int size); }; //To be received by the Simulator class Simulator { vector <Bid> list; Trader trader; Auctioneer auctioneer; public: void run(); }; // Passing the vector into a function in simulator Simulator::accept_bids(bid_vector::const_iterator begin, bid_vector::const_iterator end){ vector<Bid>::iterator itr; } //Its journey should end with the Auctioneer. who displays the data class Auctioneer { public: vector <Bid>v2;// created a new vector to hold the objects void accept_bids(vector<Bid> & bids); void displayBids(){return bids} };

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >