templates

Display hierarchical XML data using DataGrid

I have an XML file such as the one shown below <root> <child1> <grandchild1> <greatgrandchild1> </greatgrandchild1> <greatgrandchild2> </greatgrandchild2> ... </grandchild1> <grandchild2> </grandchild2> <grandchild3> </grandchild3> ... </child1> <child2> <grandchil...

How to draw line of ten thousands of points with WPF within 0.5 second?

I am writing WPF code to show a real-time plot which is a connected line containing about 10,000 points. It takes about 5 seconds to show a picture in my computer. Does anyone have an idea to make it quicker and within 0.5 second? class eee : FrameworkElement { public eee() { _children = new VisualCollection(this); ...

Best way to use a server side language for development, but deploy to static HTML

We have a client for whom we build a lot of template based sites. Ideally we would use something like kohana (http://www.kohanaphp.com/) to handle the templating and make doing site wide changes a breeze. Unfortunately our client cannot (and will not) host any server side code (and before you ask, this will not change and hosting the f...

Ruby Template Module

Assume I have a family of related modules: module Has_Chocolate def has_chocolate? true end end module Has_Cake def has_cake? true end end . . . How would I construct a template module Has_*Something* where Something would be a parameter to the module? ...

How could I print the contents of any container in a generic way ?

I am trying to write a piece of code for fun using C++ templates. #include <iostream> #include <vector> template <class Container> std::ostream& operator<<(std::ostream& o, const Container& container) { typename Container::const_iterator beg = container.begin(); o << "["; // 1 while(beg != container.end()) { o <<...

Can you declare <canvas> methods within a template in javascript?

Not entirely sure I posed the question in the best way but here goes... I have been playing around with the HTML5 canvas API and have got as far as drawing a shape in the canvas and getting it to move around with the arrow keys. I then tried to move my various variables and functions to a template so I could spawn multiple shapes (that...

Constructor of class in template

I have a object cache class like this: #include "boost/thread/mutex.hpp" #include "boost/unordered_map.hpp" template <typename type1, typename type2> class objectCache { public: objectCache() { IDCounter = 0; } ~objectCache() { for ( it=free_objects.begin() ; it != free_objects.end(); it++ ) delete (...

Is it possible to access values of non-type template parameters in specialized template class?

Is it possible to access values of non-type template parameters in specialized template class? If I have template class with specialization: template <int major, int minor> struct A { void f() { cout << major << endl; } } template <> struct A<4,0> { void f() { cout << ??? << endl; } } I know it the above ca...

c++ standard practice: virtual interface classes vs. templates

I have to make a decision regarding generalization vs polymorphism. Well the scenario is standard: I want to make my monolithic interdependent code to be more modular, clean and extensible. It is still in a stage where the change of design principle is doable, and, as I look at it, highly desirable. Will I introduce purely virtual base...

ambiguous template wierdness

I have the following code (sorry for the large code chunk, but I could not narrow it down any more) template <bool B> struct enable_if_c { typedef void type; }; template <> struct enable_if_c<false> {}; template <class Cond> struct enable_if : public enable_if_c<Cond::value> {}; template <typename X> struct Base { enum { value ...

Update base template and apply to all sites who reference it - MOSS 2007

Hello! More SharePoint questions from me again today! I thank everyone that has helped thus far! Here is my situation: I have to create a custom application inside of sharepoint. I am using a document library which hosts web part pages and i am using Web User Controls to do all the manipluating and displaying of data. Once I build the...

How can I use templates to determine the appropriate argument passing method?

As I understand it, when passing an object to a function that's larger than a register, it's preferable to pass it as a (const) reference, e.g.: void foo(const std::string& bar) { ... } This avoids having to perform a potentially expensive copy of the argument. However, when passing a type that fits into a register, passing it as...

Problem compiling C++ template code

I have the following template: template<class Matrix> Matrix horizontal_join (const Matrix& m1, const Matrix& m2) { ASSERT (rows (m1) == rows (m2), "unequal number of rows"); typedef typename Matrix::value_type Scalar; Matrix r (rows (m1), nbcol (m1) + nbcol (m2)); for (unsigned i=0; i<nbrow(m1); i++) { for (unsigned j=0; j<nb...

How to make this template code work ?

the template code is like this: template <class type1> struct DefaultInstanceCreator { type1 * operator ()() { return new type1; } }; template < class type1 , class InstanceCreator = DefaultInstanceCreator<type1> > class objectCache { public: objectCache (InstanceCreator & instCreator) :instCreator_ (...

Forward declaration in multiple source directory; template instantation

Hi, I am looking for a nice book, reference material which deals with forward declaration of classes esp. when sources are in multiple directories, eg. class A in dirA is forward declared in class B in dirB ? How is this done ? Also, any material for template issues, advanced uses and instantation problems, highly appreicated ? Thanks...

WPF : using a designed vector image as a control template in WPF

Hi, I am exploring the idea of using professionally designed vector images as the ControlTemplates in my WPF application. The idea is to make several types of controls, each with a different visual design, which can then be dragged and dropped. This is exactly the same use-case as a visual designer (a'la visio) I have the following XAM...

function passed as template argument

I'm looking for the rules involving passing C++ templates functions as arguments. This is supported by C++ as shown by an example here: #include <iostream> void add1(int &v) { v+=1; } void add2(int &v) { v+=2; } template <void (*T)(int &)> void doOperation() { int temp=0; T(temp); std::cout << "Result is " << temp << std::e...

C# code generation / removing redundant code

I have some simple code in a class: private ITemplate _content1 = null; [TemplateContainer(typeof(ContentContainer))] public ITemplate Content1 { get { return _content1; } set { _content1 = value; } } I need about 15 of these content containers. I could just copy and paste this block 15 times and change the number, but...

Is this a good way to use controllers and views in CodeIgniter?

What is the best way to use controllers/views in CodeIgniter? Is the following a bad way to go about making my pages? function index() { $this->load->library('carabiner'); $this->load->view('include/head'); $this->load->view('include/home'); $this->load->view('top'); $this->load->view('featured'); $this->l...

Can I cast std::vector<Animal*> to std::vector<Dog*> without looking at each element?

I have a base class with several classes extending it. I have some generic library utilities that creates a vector containing pointers to the base class so that any of the subclasses will work. How can I cast all of the elements of the vector to a specific child class? // A method is called that assumes that a vector containing // Dogs ...