Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Add new class
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tommie
New Member

8 Posts

Posted - Feb 09 2012 :  11:57:35 AM  Show Profile  Reply with Quote
Hi! I've just started using Visual Assist with VS2010 and I have been looking for some time now (with no success) for a way to add a new class to a project using VA. I basically just wish to add .hpp / .cpp files to a project containing a basic class framework, given a class name, namespace and inheritance.

I would use the VS2010 "Add Class" function (even though it isn't very good), but for some reason it doesn't work with current my solution (it creates empty files and crashes after adding :-S).

I have the feeling VA doesn't support this, or am I overlooking something? Any help or suggestion would be greatly appreciated!

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Feb 09 2012 :  1:43:40 PM  Show Profile  Reply with Quote
Well, VA can help you with this, but you will have to add the files first, manually.
After that, you can write VA snippets that will help you filling the files in seconds:

http://www.wholetomato.com/products/features/vasnippets.asp

VA Snippets are context aware, knows the filename, the date, the class, etc. at a particular caret position. If you scroll downer on the linked page, you will find the reserved words that you can use, e.g.

#ifndef $FILE_BASE_UPPER$_H
#define $FILE_BASE_UPPER$_H

class c$FILE_BASE$ : public $parentclassname$
{
    c$FILE_BASE$() {}
    ~c$FILE_BASE$() {}
};

#endif

to create a class based on filename. It will ask you the parent class' name. e.g. for the filename Listbox.h, it will generate the following, if you enter "cObject" when asked:


#ifndef LISTBOX_H
#define LISTBOX_H

class cListbox : public cObject
{
    cListbox() {}
    ~cListbox() {}
};


Using #pragma once is more practical, I just used include guard for demonstration purposes.

Hope this helps

Edited by - accord on Feb 09 2012 1:45:48 PM
Go to Top of Page

tommie
New Member

8 Posts

Posted - Feb 09 2012 :  2:21:59 PM  Show Profile  Reply with Quote
Thanks! That was indeed very helpful. Needing to only manually add the files is something I can definitely live with ;-)

Still, is some form of file creation a feature that may be included in VA at some point? Could be useful not only for creating new classes, but perhaps also for copying or moving existing classes into new files. Or is VA really designed to work only with existing files?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Feb 09 2012 :  7:14:36 PM  Show Profile  Reply with Quote
We are considering adding a new command to move an existing class into a new file:

case=62266

The more general case of just adding a new file, or pair of files to the solution raises all sorts of questions about where in the directory structure the files should be placed, etc. Often cpp and .h files are placed in different directories. If you are basing the new files on existing files then you can use the location of these existing files to help.

zen is the art of being at one with the two'ness
Go to Top of Page

tommie
New Member

8 Posts

Posted - Feb 10 2012 :  08:26:35 AM  Show Profile  Reply with Quote
Thank you for your reply. I indeed see the issue of needing to point to the right folder(s) for headers and source files.

In visual studio, you now need to manually point to the right folder for each file you add, while files for new classes are automatically stored in the project folder. It would be very handy if you could select default locations for both headers and sources once per project and add new files in pairs (or new classes).

This is especially helpful at the beginning of the development of a new library or project, when you wish to add a (large) number of new classes based on a software architecture design.

BTW, this issue aside I'm very pleased with the functionality provided in Virtual Assist
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Feb 10 2012 :  9:31:40 PM  Show Profile  Reply with Quote
For adding files, my personal solution is to copy / paste a dummy file in the target directory with a file manager, rename the files, and then add them to the solution. Drag and drop into solution explorer works well here for me.

Assuming all of the files are going to go into a single directory is often an invalid assumption.

zen is the art of being at one with the two'ness
Go to Top of Page

tommie
New Member

8 Posts

Posted - Feb 15 2012 :  05:58:53 AM  Show Profile  Reply with Quote
Thanks for that comment - the method you describe is actually very similar to how I deal with this right now.

What I probably meant was simply a way to do all these things from a single dialog (define class name, select folders & filenames, create files, generate code). The method I use now just feels like a such hassle, especially if I need to create several new classes in a row.

Please consider this as an official feature request Thanks again for the excellent support so far.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Feb 16 2012 :  8:14:13 PM  Show Profile  Reply with Quote
I am wondering how you see this working. A separate dialog is not a good place to enter a load of code, this is what the editor is for. Asking for the class name might make sense, but this assumes that this class name is then used to generate a default class. You probably have a VA Snippet for this, but different people may need more or less information for this VA Snippet to run, even assuming they have a VA Snippet for this job.

For C++ you normally need two files, but sometimes you only want a header file.
C# and VB only need one file per class.

I just want to keep this fairly clean and simple, while still making it useful.


zen is the art of being at one with the two'ness
Go to Top of Page

tommie
New Member

8 Posts

Posted - Feb 17 2012 :  07:27:05 AM  Show Profile  Reply with Quote
The way I could see it work is something like this:

There would be an option called "Add New File(s) to Project..." (or something similar), which would open up a dialog like this:



--- Name and Options ---
* [Input field] Name
* [Checkbox] Only create header file

--- Header File ---
* [Input field] Path to header file (defaults to previous selection or project folder)
* [Dropdown box] VA Snippet to run on this file (defaults to previous selection or 'none')

--- Source File ---
* [Input field] Path to source file (defaults to previous selection or project folder)
* [Dropdown box] VA Snippet to run on this file (defaults to previous selection or 'none')



Key is that the dialog remains clean and simple, while the use of VA snippets provides both power and flexibility. Remembering previous selections allows one to quickly add multiple classes in a row. If people need more information for generating classes, they can define additional input parameters in their snippets (or not use snippets at all). When not using C++, the 'source file' section could be hidden, or the 'only create header file' option could be fixed to 'true'.

Edited by - tommie on Feb 17 2012 07:29:01 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Feb 17 2012 :  3:40:45 PM  Show Profile  Reply with Quote
I like this idea, and your suggested dialog makes a lot of sense. A simple and easy dialog to use, that offers quite a bit of power if you use the VA Snippets carefully. I have put in a feature request for this to see what our developers make of it:

case=64770

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000