Jump to content

  • Log In with Google      Sign In   
  • Create Account

Cosmic314

Member Since 25 Jul 2003
Offline Last Active Yesterday, 04:27 PM

Topics I've Started

typedef template parameters

02 October 2013 - 11:34 AM

I create a type:

typedef std::map<std::string,std::string> StringMap;

Later I create a function template declared as:

template<typename K, typename V>
void function_name(std::map<K,V> *map_object);

I go to use the function_name as so:

function_name<StringMap>(&some_map_object);

The compiler complains with:

error:  no matching function for call to 'function_name(StringMap*)'

When I supply both types to the template arguments (std::string,std::string) in this case, everything is fine.  I would have thought that the compiler might be able to infer that StringMap = std::string,std::string but it looks like I'm wrong.  

 

Is this mainly because the compiler cannot mismatch on number of type arguments supplied in a template?


Server output to clients

12 September 2013 - 10:55 AM

I have a server that uses sockets to connect with clients.  These connections are not persistent.  The typical usage pattern is to submit 'work' to the server.  It receives the job, checks as best as it can that it can actually satisfy requirements, notifies the user, and then disconnects the client.  The workload can be queued behind an arbitrary number of tasks, so the time the server starts to perform a specific job is not easily predictable.  When it goes to perform a task it could encounter an error.

 

My question is:  How can I let a user know information about the error it receives?  In my case, jobs typically create their own work area where they produce results on a shared filesystem.  I can, and do, report errors here.  However, a certain class of errors can occur before an appropriate directory structure is created.  If I can't place them into a file under this structure how will I report them?

 

Some of my ideas:

 

1)  Allow the client to retrieve job results through a separate communication with the server.  This will require the server to record the status of failed workloads.  I could start consuming memory pretty quickly if I keep this data around for too long.  I supposed I could store the results in a file in a general location and retrieve on demand.

 

2)  Require that each client have a pre-defined workspace prior to submitting the job.  The server will require that this directory exist and be writable before it will accept jobs.

 

3)  Email every failure.  However, this doesn't appear too attractive to me.  A tool which creates automated dispatches might make the same error on a large number of jobs.  When the user goes to read email -- disaster!

 

Anyways, do any of these solutions seem reasonable?  What other ways might I consider?

 

Thanks!


Any interest in ARM CPU pipeline / programming article?

09 September 2013 - 11:51 AM

I want to write an article but first I wanted to solicit my idea to see if it would get any interest.  I already read the article about the CPU pipeline, which focuses on the Intel architecture.  Would there be any interest in a similar article about the ARM pipeline and processor?  Mobile devices are heavy users of this architecture so it does have some direct relevance to Gamedev.net.  I work with ARM processors and know enough to convey the basics.

 

Anyways, I'm just putting some feelers out to see what people think.


Seeking Advice on Windows IDEs, Cygwin, Windows versions, et. al.

08 September 2013 - 11:13 AM

I am trying to write hobby games for Windows / PC.  When I used Visual Studio Express 2010, I am frustrated with restrictions placed on being able to add IDE customizations.  For example, the code snippets tool doesn't natively support C++ unless I upgrade to Pro.  For the same reason I can't add 3rd party extensions, like Snip2Code, unless I shell out some cash.  From what I've read, and I certainly can be wrong, is that if I wanted Visual Studio with C++11 my best route is to install either Windows 7 or Windows 8 ($100-$200).  But would I need to get Pro and shell out another $500?  Does anyone have opinions and experience here?  Like I said, I'm currently only a hobbyist.  Spending $100 for a new OS is non-ideal but doable, but spending another $500 for a license on software that might be replaced a year later is asking too much.  If I upgrade to a new tool is there typically a savings involved?  Are add-ons difficult to code up?  Are 3rd party applications typically expensive?

 

I do enjoy the features of the IDE, especially the Intellisense and pre-compilation error detection.  However, I do not enjoy hunting through GUI menus to add libraries, include paths, etc.  Maybe my experience would be a little better if I could control all of these build options from a text file and command prompt instead.  I feel I'm giving up some control by just letting the IDE handle the build flow.  I see CMake is touted in these forums so I may head that way.  Is Powershell a worthwhile way of running on the command line?

 

In exploring alternatives I ran across Cygwin.  Since I program on Linux for my day job this discovery was serendipitous.  I've download the environment, copied source code from one of my Windows projects, created a Makefile, and after a bit of tinkering I got a natively compiled Windows program working without using any Cygwin DLLs.  I use Xemacs / Emacs and I also uncovered CEDET:  http://cedet.sourceforge.net/.  Maybe I can have the best of both worlds?

 

Is using Cygwin a dangerous path to travel for programming Windows applications?  Is there anything to be wary of?  I'm looking for other user experiences.

 

Thanks!


Design recommendations for multiple map<> of objects

19 December 2012 - 02:28 PM

In my current C++ project I have a Device object. From this Device object I subclass a great number of devices. I store all of these devices in separate std::map objects with one map per subclass. The subclassed devices are produced by a factory. In the base class I have several routines to set various states of each device. Each device must have a unique ID upon creation. How would you implement this scenario?

Some ideas I had:

(1) Store all devices in one map<string,IDevice *>. Store type information and cast to the appropriate subclass. The main advantage here is that I maintain one master list of all devices. However, the devil on my shoulder says this practice is frowned upon because of the casting.

(2) Make a separate map for each subclass but have no centralized list. The main advantage here is that no casts are needed. A big disadvantage is that I have as many lists as I do device types. If I want to add a device I have to check against all lists to see if the device already exists.

(3) Like (2) but I have an additional map that does nothing but record existing ID names. When a device is added/removed two maps need updating. Updating two locations to maintain state could be problematic if code complexity increases. I could add an interface which wraps the action of adding/removing objects to both lists.

(4) Something like (1) and (2) combined. Have a master list of IDevice* and also maintain specific subclassed lists. If I need to perform a base class operation I just use the main device list. However, now I have two pointers and I worry about leaks and/or dangling pointers.

(5) Have some sort of nested map or multi_map structure.

I'm guessing there's a stronger solution than the above. What would you recommend?

Thanks!

PARTNERS