Есть код
[src=#cpp]
/*
* Copyright 2010-2011 napile
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <string>
#include <vector>
#include "config.h"
class ClasspathEntry
{
protected:
std:tring _path;
public:
ClasspathEntry();
virtual void addToClassPath(std::vector<std:tring> list) ;
};
[/src]
[src=#cpp]
/*
* Copyright 2010-2011 napile
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "ClasspathEntry.h"
class ClasspathDirectory : public ClasspathEntry
{
public:
std:tring _pattern;
ClasspathDirectory(std:tring path, std:tring patt);
void addToClassPath(std::vector<std:tring> list) override;
};
[/src]
и есть метод
[src=#cpp]
void JVMOptions::initClasspath()
{
_classpath.push_back(ClasspathDirectory("lib", "*"));
DEBUG("------------------------------------------------------------------");
DEBUG("Calling initClasspath " + StringUtils::toString(_classpath.size()));
std::vector<std:tring> list;
for(int i = 0; i < _classpath.size(); i++)
{
ClasspathEntry entry = _classpath[i];
entry.addToClassPath(list);
}
DEBUG("------------------------------------------------------------------");
}
[/src]
Итог я получаю
[src=#cpp]
void ClasspathEntry::addToClassPath(std::vector<std:tring> list)
{
DEBUG("Calling ClasspathEntry.addToClassPath");
}
[/src]
Как сделать что б вызывалось с детей, entry.addToClassPath(list);, а не с матери
Добавлено через 3 минуты
Ах да реализация
[src=#cpp]
/*
* Copyright 2010-2011 napile
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ClasspathDirectory.h"
#include "FileUtils.h"
#include "common.h"
ClasspathDirectory::ClasspathDirectory(std:tring path, std:tring patt)
{
_path = path;
_pattern = patt;
}
void ClasspathDirectory::addToClassPath(std::vector<std:tring> list)
{
std:tring currentPath = std:tring(EXE_MAKER_CURRENT_DIR);
if (!FileUtils::isAbsolute(currentPath))
currentPath = FileUtils::concFile(FileUtils::getExecutablePath(), currentPath);
DEBUG("Path to search " + currentPath + "; pattern " + _pattern);
}
[/src]
[src=#cpp]
/*
* Copyright 2010-2011 napile
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <string>
#include <vector>
#include "config.h"
class ClasspathEntry
{
protected:
std:tring _path;
public:
ClasspathEntry();
virtual void addToClassPath(std::vector<std:tring> list) ;
};
[/src]
[src=#cpp]
/*
* Copyright 2010-2011 napile
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "ClasspathEntry.h"
class ClasspathDirectory : public ClasspathEntry
{
public:
std:tring _pattern;
ClasspathDirectory(std:tring path, std:tring patt);
void addToClassPath(std::vector<std:tring> list) override;
};
[/src]
и есть метод
[src=#cpp]
void JVMOptions::initClasspath()
{
_classpath.push_back(ClasspathDirectory("lib", "*"));
DEBUG("------------------------------------------------------------------");
DEBUG("Calling initClasspath " + StringUtils::toString(_classpath.size()));
std::vector<std:tring> list;
for(int i = 0; i < _classpath.size(); i++)
{
ClasspathEntry entry = _classpath[i];
entry.addToClassPath(list);
}
DEBUG("------------------------------------------------------------------");
}
[/src]
Итог я получаю
[src=#cpp]
void ClasspathEntry::addToClassPath(std::vector<std:tring> list)
{
DEBUG("Calling ClasspathEntry.addToClassPath");
}
[/src]
Как сделать что б вызывалось с детей, entry.addToClassPath(list);, а не с матери
Добавлено через 3 минуты
Ах да реализация
[src=#cpp]
/*
* Copyright 2010-2011 napile
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ClasspathDirectory.h"
#include "FileUtils.h"
#include "common.h"
ClasspathDirectory::ClasspathDirectory(std:tring path, std:tring patt)
{
_path = path;
_pattern = patt;
}
void ClasspathDirectory::addToClassPath(std::vector<std:tring> list)
{
std:tring currentPath = std:tring(EXE_MAKER_CURRENT_DIR);
if (!FileUtils::isAbsolute(currentPath))
currentPath = FileUtils::concFile(FileUtils::getExecutablePath(), currentPath);
DEBUG("Path to search " + currentPath + "; pattern " + _pattern);
}
[/src]