class

Explicit Loading of DLL

I'm trying to explicitly link with a DLL. No other resources is available except the DLL file itself and some documentation about the classes and its member functions. From the documentation, each class comes with its own member typedef example: typedef std::map<std::string,std::string> Server::KeyValueMap, typedef std::vector<std::...

How to access internal class using Reflection

Hello there, How can I access an internal class of an assembly? Say I want to access System.ComponentModel.Design.DesignerHost. Here the DesignerHost is an internal and sealed class. How can I write a code to load the assembly and the type. Thanks, Dattebayo... ...

How can I keep track of (enumerate) all classes that implement an interface

I have a situation where I have an interface that defines how a certain class behaves in order to fill a certain role in my program, but at this point in time I'm not 100% sure how many classes I will write to fill that role. However, at the same time, I know that I want the user to be able to select, from a GUI combo/list box, which con...

C# : So if a static class is bad practice for storing global state info, what's a good alternative that offers the same convenience?

Hi, I've been noticing static classes getting a lot of bad rep on SO in regards to being used to store global information. (And global variables being scorned upon in general) I'd just like to know what a good alternative is for my example below... I'm developing a WPF app, and many views of the data retrieved from my db are filtered b...

[C#] Access member of second parent (inheritance)

Hello :) Here is my current layout: (the question is the comment) class A { int foo; } class B : A {} class C : B { void bar() { //I want to access foo base.foo; // Doesn't work base.base.foo // Doesn't work, of course } } As you can see, I cannot access members of A by using base in C. H...

trying to learn the syntax and structure of cakephp

I'm trying to write a cakephp app. I need to validate input based on availability. an example would be if someone is trying to take out a book from a library. I would reference the book to see if it's currently out, and if it is report that to the user. another example would be trying to book rooms at a hotel, the user would enter a dat...

Python decorators in classes

Hi, can one write sth like: class Test(object): def _decorator(self, foo): foo() @self._decorator def bar(self): pass This fails: self in @self is unknown I also tried: @Test._decorator(self) which also fails: Test unknown If would like to temp. change some instance variables in the decorator and th...

How to call a JNI DLL from C++

I have a task to interface with a dll from a third party company using C++. The dll package comes with: the dll itself a sample Java implementation - consists of a java wrapper(library) generated using the SWIG tool and the the java source file documentation that states all the public datatypes, enumeration and member functions. My ...

Why are globals empty inside a class when the variabled are included?

What I am trying to do is have a separate PHP file containing settings for the website, and then having other pages include this file and execute code according to the settings. However, whenever I use global to reference these variables inside a class, the variables are empty. For example: settings.php: <?php $setting1 = 'on'; $settin...

Calling a base class's classmethod in Python

Consider the following code: class Base(object): @classmethod def do(cls, a): print cls, a class Derived(Base): @classmethod def do(cls, a): print 'In derived!' # Base.do(cls, a) -- can't pass `cls` Base.do(a) if __name__ == '__main__': d = Derived() d.do('hello') > $ python p...

Class naming chaos

I often struggle with deciding how to name a class. Not so much because the class's purpose is unclear, but because of names like xxx*Controller*, xxx*Manager*, xxx*Info*, xxx*Helper*, xxx*Util* etc that I see everywhere. If I have a class that uploads some stuff over HTTP, I tend to name it HttpUploader or something on those lines. ...

Base-to-derived class typecast

I have a base class: class RedBlackTreeNode { // Interface is the same as the implementation public: RedBlackTreeNode* left; RedBlackTreeNode* right; RedBlackTreeNode* parent; Color color; TreeNodeData* data; RedBlackTreeNode(): left(0), right(0), parent(0), color(Black), ...

How to force call a C# derived method

I have a class that is generated by some tool, therefore I can't change it. The generated class is very simple (no interface, no virtual methods): class GeneratedFoo { public void Write(string p) { /* do something */ } } In the C# project, we want to provide a way so that we can plug in a different implementation of MyFoo. So I'm th...

c# separate class for storage

I use more than one class and I need a... lets say Global storage for all the class and method. Is it the right way to create a static class for storage? public static class Storage { public static string filePath { get; set; } } Or is there other ways to do it? ...

c# What is the different between static class and non-static (I am talking about the class itself not the field)

The syntax maybe wrong public static class Storage { public static string filePath { get; set; } } And public class Storage { private void Storage () {}; public static string filePath { get; set; } } I got this from an example on the internet. what is the use of the second o...

Classes and file reading

Can an object of ifstream type used for file reading be a static member of a class? I want to read a file and store each line in an array of objects of a class i have created. I want the file reading object to belong to the entire array of objects instead of one single instance of the class. ...

nhibernate table pr hierarchy fetching specific class with LINQ

I have a class hierarchy mapped into one table. There is one superclass and 8 different sub classes. A lot of my queries needs to fetch e.g. 2 of the sub classes only for a specific date. The table has a discriminator column that nhibernate itself uses. But when using LINQ for querying it is not possible to use this discriminator as ther...

C++ Callbacks using Boost Functions and C++ Class Methods

Is there a non-hacky (i.e. no assembly, ...) way to use boost functions to create callbacks with non-static class methods? Currently for static methods: list<function<void (LuaState&)> > _callbacks; I was thinking something along the lines of list<tuple<function<void (void *, LuaState&)>, void*> _callbacks; but boost functions doe...

AS3 driving me nuts......

Ok here is what I am currently trying to do. I have a class called vdata.as which takes 2 paramaters both are strings sent from the main stage. Parameter one is the location for an XML file that I need to open and read. The second parameter is the name of the video I am currently looking for. Now I can get the data from the XML file and...

How to run code upon class definition (not object instantiation)

I'm looking for a way to transparently run code when a class is defined - more importantly, when the class is extended. For example, if I have: class A { function define() { echo "A has been defined!\n"; } __magicDefine { define(); } } class B extends A { } I'd like that to print "A has been defined!\n". Is this i...