GDICommander 54 Posting Whiz in Training

If that may help...

http://www.cplusplus.com/doc/tutorial/classes/

You shouldn't come on that site, copy/paste your homework and say "I don't understand. Please help!".

GDICommander 54 Posting Whiz in Training

If you need to wait for an amount of time and if you develop on Windows, use the Sleep function defined in <windows.h>. See this page: http://msdn.microsoft.com/en-us/library/ms686298(v=vs.85).aspx

Note that this approach is not portable on other platforms than Windows.

GDICommander 54 Posting Whiz in Training

For the string errors, do one of these solutions:

#include <string>  //You need that or any include of a C++-standard include file to make std recognized.
using std::string;
//OR
using namespace std;
//OR
std::string blabla;  //For each string variable
GDICommander 54 Posting Whiz in Training

I had this problem when I was at the university and a workaround was to restart Code::Blocks. I know it's an ugly workaround, but it may work.

The behaviour looks like a bug. Maybe you can report it on this forum: http://forums.codeblocks.org/index.php.

GDICommander 54 Posting Whiz in Training

Looks like a process is having a handle on the exe (because the exe isn't running). That's why you may need to find which of the existing processes (with Process Explorer, like I described, or any other tool) has an handle on the exe.

GDICommander 54 Posting Whiz in Training

You're using Windows, so use Process Explorer to know which program uses the .exe (In Handle\Find Handle or DLL..., enter the name of the .exe file and you'll get the process that uses the .exe and that prevents you from opening and deleting the file.

If the process can be killed, then kill him.

GDICommander 54 Posting Whiz in Training

The C++ syntax for memory allocation for array does not allow any shortcut like what's done in Java.

You can always simulate the Javs syntax by creating a function that takes a variable number of arguments and returns an allocated int array with all the values received at their correct position in the array.

I disagree with that approach, because evaluation of functions with variable arguments have the reputation to be slow.

GDICommander 54 Posting Whiz in Training

Check gSOAP. You can generate web service client or server code.

http://www.cs.fsu.edu/~engelen/soap.html

Ancient Dragon commented: thanks for that link :) +36
GDICommander 54 Posting Whiz in Training

Windows does not support POSIX threads (pthreads), if I correctly remember my multi-thread assignments at the unversity.

GDICommander 54 Posting Whiz in Training

C++ did not added any multi-thread support in their language, instead of other languages like Java (which is far younger than C/C++ and has been in the beginning of the multi-thread era).

C++0x, the next revision of C++, will add thread support as a standard, so every compiler that will respect the new standard will support multi-threading.

This site provides a implementation of the upcoming multi-thread support in C++0x. It is not free (unfortunately), but it illustrates my point: http://www.stdthread.co.uk/

GDICommander 54 Posting Whiz in Training

It depends of the paradigms you need to learn and of the languages you need to learn for a particular work. By learning a language, you'll reinforce your set of skills and you will be able to learn faster some features from other languages. For example, the foreach construct in Java represents the iterator concept that is found in C++/STL, but which much more syntax in C++.

I heard somebody in an university saying that "if you master C++, then you will easily master other languages". I don't entirely agree with that statement, because I consider some languages to be very important in a programmer's experience (like Lisp or Scheme, even if the syntax can horrify the syntax lovers). However, C++ can let you experience a lot of concepts (pointers, memory allocation, single and multiple inheritance, functional programming - if you can handle syntax of function pointers).

I insist that you experiment a lot of paradigms (functional programming, object-oriented programming, ...) instead of concentrating on programming languages alone. By using paradigms, you'll open yourself to multiple programming languages.

GDICommander 54 Posting Whiz in Training

Can you post the code that leads to this error? It looks like an import directive hasn't been written correctly.

Or, have you modified matplotlib modules to make the importing directive fail?

GDICommander 54 Posting Whiz in Training

This site will tell you all you need to answer your questions:

http://matplotlib.sourceforge.net/

For the labeling part, look at this example. Pay attention to the xlabel and ylabel functions:

http://matplotlib.sourceforge.net/plot_directive/mpl_examples/pylab_examples/bar_stacked.py

GDICommander 54 Posting Whiz in Training

Maybe the listProb lists have already an empty list inside after entering the loop. You can print their content before entering the loop.

I guess that normDistProb returns an empty list somehow.

GDICommander 54 Posting Whiz in Training

On my machine (Windows), when providing a file that contains "a b c d e", I have this output:

(1, 'a')
(1, 'c')
(1, 'b')
(1, 'e')
(1, 'd')

There is no EOL character in the output, which is expected. So, the code haven't took the EOL character on my machine.

Are you running your script on another OS?

GDICommander 54 Posting Whiz in Training

Ok... what's wrong with the actual code?

GDICommander 54 Posting Whiz in Training

Maybe you're comparing a GameObject with a Player, but I don't think so...

Have you deferenced BOTH pointers? (current AND insertedPlayer)

Note that you put overrided operators PRIVATE, so this is hidden... Try to put them PUBLIC.

GDICommander 54 Posting Whiz in Training

Can you show your implementation of the overloaded operators you mentioned?

GDICommander 54 Posting Whiz in Training

What are you trying to do with the Salary method of SalesReport? You want to modify the array passed as a parameter? Or you want to compute a total salary from the sales received? If you want to modify the array passed as a parameter, you're doing it with the code you already have...

Maybe you want to do this instead:

int SalesReport::Salary(int sales[])
{
    int arraysize = sizeof(sales);
    int i = 0;

    int total = 0;

    while (i <= arraysize)
    {
        total += (sales[i]* .09) + 200;
        i++;
    }

    return total;
}

...and the type conversion error will banish. For you information, sales is an "int array" (int[]) and you try to return an "int", so there is an incompatibility. Maybe you want to return the array (a pointer on it - int*), but I doubt that this is what you want.

For the "illegal elses", you need to put i++ at the same indent level of each line that follows "if" and "else if". But I suggest that you use a for loop and place the i increment inside, so you won't need to put i++ for each condition:

for (int i = 0; i <= arraysize; i++)
{
  //Do your conditions.
}

And for cout and endl, they belong to the std namespace, so you need to write std::cout and std::endl OR put at the beginning of your code:

using namespace std;

Hope this helps with your understanding of C++!

GDICommander 54 Posting Whiz in Training

Hello, Gribouillis.

setx.exe cannot remove environment variables from a Windows system, it can only add or modify environment variables. So, I used manipulations in the registry, like I was suggesting in my first post, to remove an environment variable.

For your information, the environment variables are at this place in the registry:

[HKEY_CURRENT_USER\Environment] #for user environment variables
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment] #for system variables

I used the _winreg module in pywin to edit the registry.

Thanks for your help.

GDICommander 54 Posting Whiz in Training

Hello, DaniWeb community!

I want to know how I can delete environment variables in Python so that I can no longer see them outside of the execution of the Python script (on Windows, in "Advanced System Settings/Environment Variables...")

This is what I tried:

os.unsetenv
deleting entries in os.environ, but it only affects the script environment...

I'm thinking of playing in the registry or modified a file called AUTOEXEC.BAT on Windows, but I hope that something in Python exists that can prevent me from using these "hardcore" methods. Remember, I need the deletion of environment variables to take effect right now.

Thanks.

GDICommander 54 Posting Whiz in Training

Thank you for your help. It works!

By the way, I edited your regular expression to match file that have . in their name (for example, tree.old.h). It gives this:

re.findall(r'[\w\.]+\.h', line)
GDICommander 54 Posting Whiz in Training

Hello! I need help to construct a regular expression in Python that will help me get the file name of a include directive in C++. I think that regular expressions are a good way to solve this problem, but I'm open to new ideas.

Consider these following includes:

#include "hello.h"
#include "d/hello.h"
#include "dir/hello.h"
#include "dir\hello.h"
#include <hello.h>
#include "a\b\c.h"
#include <ref\six\eight.h>
#include "123\456/789.h"
#include "bye.h"

In all these cases, I want the name of the included file (for example, hello.h, c.h, eight.h, 789.h and bye.h). I have written a regular expression that's not working (I think). Here it is:

fileNamePattern = re.compile(r"""
[\\/"<]  #The last part of the include file path begins with these characters."
[a-zA-Z0-9_]+
[>"]      #The end of include line must end with > or "
(\s)*     #Any whitespace character (including tabs, carriage returns)
$         #The end of the string.
""", re.VERBOSE)

I'm calling the groups() method on every match and on every string passed, it returns None (means that none of the strings match this regular expression).

Can you help me make a regular expression work with my case?

Thanks in advance.

GDICommander 54 Posting Whiz in Training

Hello, breaksand30.

I have found a solution to your problem:

while True:
    print 'New connection from %s:%d' % (addr[0], addr[1])
    data = conn.recv(BUFSIZE)
    if not data:
        break
    elif data == 'exit':
        conn.send('\0')
    else:
        # PAY ATTENTION HERE
        p = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE)
        conn.send(''.join([line for line in p.stdout.xreadlines()]))

You need to execute the command this way. I tested the "dir" command (with no arguments, with one argument) in Windows and it works.

Look at this page, it helped me and it may help you: http://stackoverflow.com/questions/36324/the-system-cannot-find-the-file-specified-when-invoking-subprocess-popen-in-pyt

GDICommander 54 Posting Whiz in Training

Have you tested all your functions with unit tests? (You can easily write unit tests in Python, see http://docs.python.org/library/unittest.html)

If you haven't tested what you wrote, then you may find a lot of bugs inside your code when you'll be using it for real.

GDICommander 54 Posting Whiz in Training

Can you tell us more details about the problem?

-Is the server receiving the command on the socket?
-Is the command really executed on the server?

Look for pipes if you want to capture the output of a command. You can capture it in a file, read it and return it to the client.

GDICommander 54 Posting Whiz in Training

I would add what is necessary to add... Who will be using your code?

GDICommander 54 Posting Whiz in Training

You can always take the part of the string before the ? character...

Look for string.split('?').

GDICommander 54 Posting Whiz in Training

Some tips about your code GDICommander's
Dont use "file" as an variable name,it`s a reseverd keyword for python.
You dont need "import string" to use split.
So it could look like this,wihout \r\n

my_file = open("example.csv", "rb")
for line in my_file:
    l = [i.strip() for i in line.split(',')]
    print l

Thanks for these tips. I really love beautiful code and I will gladly accept these comments.

GDICommander 54 Posting Whiz in Training

From the Python documentation:

exception ImportError
Raised when an import statement fails to find the module definition or when a from ... import fails to find a name that is to be imported.

In numpy/core/multiarray.py, is there a symbol named _vec_string?

Is it a version of numpy under development?
If you use a previous version of numpy, is the import error still there?
Have you contacted authors of numpy about this problem?

GDICommander 54 Posting Whiz in Training

I'm quite new to python. I've used it as a scripting language before, and i'm a C++ programmer myself, so still learning here.
Here's what i got:

#!/usr/bin/python
import csv
a = [];
i=0;

b='';

csvReader = csv.reader(open('setcubed.csv', 'rb'), delimiter=' ', quotechar='|');
for row in csvReader:
	a.append(row);
	
for i in range(0, len(a)):
	print a[i];

And here's the output:

What I want to do is be able to look at each of those cells so i can give a value to another array depending on what is in that cell.

I didn't know that Python has its own module for csv. There are a lot of modules in Python that already provides a lot of useful things for any programmer.

GDICommander 54 Posting Whiz in Training

Here is some code that may help you:

import string

file = open("example.csv", "rb")
lines = []
for line in file.xreadlines():
    print line
    lines.append(string.split(line, ','))

This method has one flaw: string.split also includes \r\n in the last string of the list.

GDICommander 54 Posting Whiz in Training

Hi, everyone!

I'm having grave difficulties with generated JAR bundles from Maven OSGI plugin in Netbeans. When running the bundle from Netbeans, all works fine. But when I'm taking the generated JAR file from Maven and I'm using it outside Netbeans from command prompt and with Felix (java -jar bin\felix.jar, start file:/...), I'm having a NoClassDefFoundError on any com.sun.* class that is used.

I think I have tried everything: importing the package, exporting the package, setting the classpath to rt.jar (where com.sun.* classes) are defined, trying to know how Maven from Netbeans launches Felix (but I haven't found it). I still don't know how to remove the NoClassDefFoundErrors I'm having.

If you have ANY advice that can help me, please say it to me. This problem has wasted A LOT of my very limited time.

g! start file:/C:/Users/Pierre-Alexandre/Documents/NetBeansProjects/Prototype1ClientOSGIBundle/target/Prototype1ClientOS
GIBundle-1.0-SNAPSHOT.jar
WSDL location is: [url]http://132.210.47.44:9595/prototype1Service?WSDL[/url]
Service name is: {http://common.prototype1/}ILocalisationService
org.osgi.framework.BundleException: Activator start error in bundle domus.usherbrooke.ca.Prototype1ClientOSGIBundle [41]
.
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1869)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1739)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:919)
        at org.apache.felix.gogo.command.Basic.start(Basic.java:758)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:458)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:384)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:79)
        at org.apache.felix.gogo.shell.Console.run(Console.java:62)
        at org.apache.felix.gogo.shell.Shell.console(Shell.java:198)
        at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:124)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:458)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:384)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:79)
        at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com.sun.xml.internal.ws.api.message.Header not found by domus.usherbrooke.ca.
Prototype1ClientOSGIBundle [41]
        at $Proxy31.<clinit>(Unknown Source)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native …
GDICommander 54 Posting Whiz in Training

I have found a solution to my problem:

DOSGI requires the IP of the local machine where the OSGI bundle is deployed to make the Web services remotely available.

GDICommander 54 Posting Whiz in Training

Hello, everyone!

I'm not able to access a WSDL file on a remote machine.

I am using DOSGI and I'm creating a service in a OSGI bundle. My container is Apache Felix. DOSGI takes care of exposing a OSGI service as Web services. DOSGI publishes a WSDL at http://localhost:9595/prototype1Service?WSDL on my machine and I can access it when a browser on my machine.

When I'm publishing the same bundle on another machine with the same configuration (DOSGI, Apache Felix), I can access the WSDL locally on the another machine with the same address: http://localhost:9595/prototype1Service?WSDL. Unfortunately, I can't access the WSDL when I'm trying remotely: http://srv-prj-05.dmi.usherb.ca:9595/prototype1Service?WSDL. Here are the things that I've checked:

-The DNS name is good. Proof: I have an Apache server running on port 8080 on the machine and I can access it with http://srv-prj-05.dmi.usherb.ca.
-I have opened the port 9595 / TCP on the remote machine. The OS of the remote machine is Windows Server 2008.

For your information, Jetty is the Web server started by DOSGI.

Can you give me suggestions to solve my problem: why I can't access http://srv-prj-05.dmi.usherb.ca:9595/prototype1Service?WSDL.

Thanks.

GDICommander 54 Posting Whiz in Training

I have found a solution to my own problem:

I changed the manifest.mf file for the following:

Bundle-Name: Prototype 1 Client
Bundle-Description: A bundle that calls a Web service published by a server.
Bundle-Vendor: Apache Felix
Bundle-Version: 1.0.0
Bundle-Activator: prototype1.client.Prototype1ClientActivator
Import-Package: org.osgi.framework,javax.xml.ws,javax.xml.namespace
Bundle-ClassPath: lib/jaxb-api.jar,
 .

Hope that this solution helps someone in the future.

GDICommander 54 Posting Whiz in Training

Hello everyone!

When I'm starting a OSGI bundle in my Apache Felix container, I have a ClassNotFoundException. This is the output that I have:

start file:/C:/Users/Pierre-Alexandre/Documents/NetBeansProjects/Prototype1/src/Prototype1Client.jar
23-Sep-2010 10:43:12 AM org.apache.cxf.dosgi.discovery.local.LocalDiscoveryService bundleChanged
INFO: bundle changed: null
23-Sep-2010 10:43:12 AM org.apache.cxf.dosgi.discovery.local.LocalDiscoveryService bundleChanged
INFO: bundle changed: null
23-Sep-2010 10:43:12 AM org.apache.cxf.dosgi.discovery.local.LocalDiscoveryService bundleChanged
INFO: bundle changed: null
org.osgi.framework.BundleException: Activator start error in bundle [131].
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1864)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1734)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
        at org.apache.felix.gogo.command.Basic.start(Basic.java:758)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:421)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:335)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:184)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:121)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:78)
        at org.apache.felix.gogo.shell.Console.run(Console.java:62)
        at org.apache.felix.gogo.shell.Shell.console(Shell.java:197)
        at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:123)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:421)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:335)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:184)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:121)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:78)
        at org.apache.felix.gogo.shell.Activator.run(Activator.java:72)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: javax/xml/ws/Service
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1829)
        at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:716)
        at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
        at java.lang.Class.getConstructor0(Unknown Source)
        at java.lang.Class.newInstance0(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:3659)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1812)
        ... 32 more
Caused by: java.lang.ClassNotFoundException: javax.xml.ws.Service
        at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:772)
        at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73)
        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 47 more

This is the content of my manifest file.

Bundle-Name: Prototype 1 Client
Bundle-Description: A bundle that calls a Web service published by a server.
Bundle-Vendor: Apache Felix
Bundle-Version: 1.0.0
Bundle-Activator: prototype1.client.Prototype1ClientActivator
Import-Package: org.osgi.framework,javax.xml.*
Export-Package: javax.xml.ws.Service

My additions to Import-Package and Export-Package are attempts to make it work.

This is …

GDICommander 54 Posting Whiz in Training

Finally, I implemented the operator <. Thread solved.

GDICommander 54 Posting Whiz in Training

I finally solved my problem: the jar I was creating did not have a directory for the package inside. So, I enter this command:

PS C:\Users\Pierre-Alexandre\workspace\ApacheFelixExample\src> jar cfm ServiceExpositionExample.jar ServiceExpositionExa
mple\manifest.mf .\ServiceExpositionExample\*.class

And it works! Hope that this solution can help others.

GDICommander 54 Posting Whiz in Training

I have verified the Bundle-Activator line in manifest.mf and unfortunately, it is ok. My Activator.class is in the Example2 package, according to the code I've posted.

I was thinking of a different loading order for .class files to see it if's the class loading for jar construction that, maybe, does not include the Activator class. I've tried to change the order and it does not work.

So, i'm still unable to make it work. Any other ideas?

GDICommander 54 Posting Whiz in Training

Hello, everyone!

I am unable to start a OSGI bundle. I'm using Apache Felix and this is my bundle:

1) Activator.java

package Example2;

import java.util.Properties;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

import Example2.Service.IDictionaryService;


/**
 * This is the bundle.
 * @author Pierre-Alexandre
 *
 */
public class Activator implements BundleActivator
{
	public Activator()
	{
		
	}
	
	@Override
	public void start(BundleContext context) throws Exception 
	{
		Properties props = new Properties();
		props.put("Language", "Hockey");
		context.registerService(IDictionaryService.class.getName(), new HockeyDictionary(), props);
	}

	@Override
	public void stop(BundleContext context) throws Exception
	{
	}

	/**
	 * This a private implementation of the IDictionaryService.
	 * @author Pierre-Alexandre
	 */
	private static class HockeyDictionary implements IDictionaryService
	{
		private String[] m_dictionary = { "kovalchuk", "crosby", "ovechkin", "malkin" };
		
		//-----------------------------------------------
		public boolean checkWord(String word) 
		{	
			for (String dictWord : m_dictionary)
			{
				if (word.equals(dictWord))
				{
					return true;
				}
			}
			
			return false;
		}
		
	}
}

2) IDictionaryService.java

package Example2.Service;

public interface IDictionaryService 
{
	public boolean checkWord(String word);
}

This is the manifest file that I'm using (it has a blank line at the end):

Bundle-Name: Hockey dictionary
Bundle-Description: A bundle that registers a hockey dictionary service
Bundle-Vendor: Apache Felix
Bundle-Version: 1.0.0
Bundle-Activator: Example2.Activator
Export-Package: Example2.Service
Import-Package: org.osgi.framework


Here are the commands that I enter:

This creates the .class files.

PS C:\Users\Pierre-Alexandre\workspace\ApacheFelixExample\src\Example2> javac -classpath '..\..\..\..\Documents\Études\U
niversité\Automne 2010\IFT697 - Projet\OSGI\felix-framework-3.0.2\bin\felix.jar' .\Activator.java .\Service\IDictionaryS
ervice.java

This creates the jar for launching the bundle.

PS C:\Users\Pierre-Alexandre\workspace\ApacheFelixExample\src\Example2> jar cfm example2.jar ./Service/manifest.mf './Ac
tivator$1.class' …

GDICommander 54 Posting Whiz in Training

You are copying the content of the cin stream, so it will never end until you press Enter, maybe. So it never ends.

GDICommander 54 Posting Whiz in Training

So, if there will be no add or remove of books, I suggest to use an array that you can allocate automatically, like this:

string myArray[300];

So, the construction of the array will be done at compile-time and there will be no construction cost at run-time.

If you're using std::vector, consider resizing the vector at the beginning to avoid memory reallocation costs when resizing is needed.

GDICommander 54 Posting Whiz in Training

The deference operator is used because m_pDlg is a pointer and it needs to be dereferenced to access the object at this location.

If the OnReceive method belongs to CDialog and m_pDlg is a CDialog, then you don't need to cast to ServerDlg.

GDICommander 54 Posting Whiz in Training

It depends on what you're planning to do with your book container:

-Do you want to find something inside lots of time? Consider using a set (O(log n) search time).
-Do you want to keep indexes or track of information inside your container. If yes, an array would be useful.

Are you planning of hardcoding your book array inside your code? I suggest that you put all the book names in a file and make your program read the file and fill the container. If you forgot a book, there's no need to recompile the program. If you don't know how to do file input in C++, Google (or any search engine) is your friend!

GDICommander 54 Posting Whiz in Training

Can you debug your application, step line by line, and tell us the line where the application closes immediately?

GDICommander 54 Posting Whiz in Training

I'm not sure to understand what you want to do....

Can you post your code so I can look at your program?

GDICommander 54 Posting Whiz in Training

Just put a try-catch with the correct exception, FormatException

try
{
//Convert text boxes
}
catch (FormatException e)
{
Console.WriteLine("Invalid text in boxes!");
}

GDICommander 54 Posting Whiz in Training

You can always modify your image to add borders that will solve your problem...

GDICommander 54 Posting Whiz in Training

Why you need to do this?